empiredan commented on issue #1863:
URL:
https://github.com/apache/incubator-pegasus/issues/1863#issuecomment-1903816448
Have we tried to set `host` in `zoo_sasl_params_t` with `NULL` ?
```
typedef struct zoo_sasl_params {
const char *service; /*!< The service name, usually "zookeeper" */
const char *host; /*!< The server name, e.g. "zk-sasl-md5" */
const char *mechlist; /*!< Mechanisms to try, e.g. "DIGEST-MD5" */
const sasl_callback_t *callbacks; /*!< List of callbacks */
} zoo_sasl_params_t;
ZOOAPI zhandle_t *zookeeper_init_sasl(const char *host, watcher_fn fn,
int recv_timeout, const clientid_t *clientid, void *context, int flags,
log_callback_fn log_callback, zoo_sasl_params_t *sasl_params);
```
I found that `host` would be set automatically if it was `NULL`:
```c
int zoo_sasl_connect(zhandle_t *zh)
{
......
rc = _zsasl_getipport(zh, (const struct sockaddr *)&local_ip, salen,
iplocalport, NULL);
if (rc < 0) {
return _zsasl_fail(zh, rc);
}
salen = sizeof(remote_ip);
if (getpeername(zh->fd->sock, (struct sockaddr *)&remote_ip, &salen) <
0) {
LOG_ERROR(LOGCALLBACK(zh), "getpeername");
return _zsasl_fail(zh, ZSYSTEMERROR);
}
rc = _zsasl_getipport(zh, (const struct sockaddr *)&remote_ip, salen,
ipremoteport, host);
if (rc < 0) {
return _zsasl_fail(zh, rc);
}
......
/* client new connection */
sr = sasl_client_new(
sc->params.service,
sc->params.host ? sc->params.host : host,
iplocalport,
ipremoteport,
sc->params.callbacks,
/*secflags*/0,
&sc->conn);
if (sr != SASL_OK) {
LOG_ERROR(LOGCALLBACK(zh),
"allocating SASL connection state: %s",
sasl_errstring(sr, NULL, NULL));
return _zsasl_fail(zh, ZSYSTEMERROR);
}
return ZOK;
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]