summaryrefslogtreecommitdiff
path: root/zookeeper-client
diff options
context:
space:
mode:
authorDamien Diederen <dd@crosstwine.com>2020-10-12 06:42:46 +0000
committerMate Szalay-Beko <symat@apache.org>2020-10-12 06:42:46 +0000
commit064d8f91ae95b05b65a0a897238d77d2ade941d2 (patch)
tree907a439ac2a7d8f197cd3a14575bee1138849a85 /zookeeper-client
parent6b222fbca9da8795bbf71c7533e5da220831fe92 (diff)
downloadzookeeper-064d8f91ae95b05b65a0a897238d77d2ade941d2.tar.gz
ZOOKEEPER-3951: C Client: Fix compilation with SASL disabled
The `sasl_client` field doesn't exist when configured without SASL. Use an accessor outside of the blocks already guarded by `HAVE_CYRUS_SASL_H`. (Reported by [Parag](https://issues.apache.org/jira/browse/ZOOKEEPER-3951).) Author: Damien Diederen <dd@crosstwine.com> Reviewers: Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org> Closes #1477 from ztzg/ZOOKEEPER-3951-no-sasl-compilation
Diffstat (limited to 'zookeeper-client')
-rw-r--r--zookeeper-client/zookeeper-client-c/src/zookeeper.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/zookeeper-client/zookeeper-client-c/src/zookeeper.c b/zookeeper-client/zookeeper-client-c/src/zookeeper.c
index 132781610..2b881cb9f 100644
--- a/zookeeper-client/zookeeper-client-c/src/zookeeper.c
+++ b/zookeeper-client/zookeeper-client-c/src/zookeeper.c
@@ -333,6 +333,18 @@ static void zookeeper_set_sock_timeout(zhandle_t *, socket_t, int);
static socket_t zookeeper_connect(zhandle_t *, struct sockaddr_storage *, socket_t);
/*
+ * return 1 if zh has a SASL client configured, 0 otherwise.
+ */
+static int has_sasl_client(zhandle_t* zh)
+{
+#ifdef HAVE_CYRUS_SASL_H
+ return zh->sasl_client != NULL;
+#else /* !HAVE_CYRUS_SASL_H */
+ return 0;
+#endif /* HAVE_CYRUS_SASL_H */
+}
+
+/*
* return 1 if zh has a SASL client performing authentication, 0 otherwise.
*/
static int is_sasl_auth_in_progress(zhandle_t* zh)
@@ -2846,7 +2858,7 @@ static void finalize_session_establishment(zhandle_t *zh) {
zh->input_buffer = 0; // just in case the watcher calls zookeeper_process() again
PROCESS_SESSION_EVENT(zh, zh->state);
- if (zh->sasl_client) {
+ if (has_sasl_client(zh)) {
/* some packets might have been delayed during SASL negotiaton. */
adaptor_send_queue(zh, 0);
}
@@ -5077,7 +5089,7 @@ int zoo_add_auth(zhandle_t *zh,const char* scheme,const char* cert,
// negotiation is planned. (Such packets would be queued in
// front of SASL packets, which is forbidden, and SASL
// completion is followed by a 'send_auth_info' anyway.)
- (zh->state == ZOO_ASSOCIATING_STATE && !zh->sasl_client)) {
+ (zh->state == ZOO_ASSOCIATING_STATE && !has_sasl_client(zh))) {
return send_last_auth_info(zh);
}