ROPTIONAL(RDEBUG4, DEBUG4, "%s: Timeout settings", prefix);
- if (timeout) {
+ if (fr_time_delta_ispos(timeout)) {
ROPTIONAL(RDEBUG4, DEBUG4, "Client side result timeout (ovr): %pVs",
fr_box_time_delta(timeout));
} else {
ldap_get_option(conn->handle, LDAP_OPT_ERROR_NUMBER, &lib_errno);
if (lib_errno != LDAP_SUCCESS) return fr_ldap_error_check(NULL, conn, NULL, dn);
- if (!timeout) our_timeout = conn->config->res_timeout;
+ if (!fr_time_delta_ispos(timeout)) our_timeout = conn->config->res_timeout;
/*
* Now retrieve the result and check for errors
/* We got a valid message ID */
if ((ret == 0) && (msgid >= 0)) ROPTIONAL(RDEBUG2, DEBUG2, "Waiting for bind result...");
- status = fr_ldap_result(NULL, NULL, *pconn, msgid, 0, dn, 0);
+ status = fr_ldap_result(NULL, NULL, *pconn, msgid, 0, dn, fr_time_delta_wrap(0));
}
switch (status) {
fr_assert(*pconn && (*pconn)->handle);
if (DEBUG_ENABLED4 || (request && RDEBUG_ENABLED4)) {
- fr_ldap_timeout_debug(request, *pconn, 0, __FUNCTION__);
+ fr_ldap_timeout_debug(request, *pconn, fr_time_delta_wrap(0), __FUNCTION__);
}
/*
if ((*pconn)->rebound) {
status = fr_ldap_bind(request, pconn,
(*pconn)->config->admin_identity, (*pconn)->config->admin_password,
- &(*pconn)->config->admin_sasl, 0,
+ &(*pconn)->config->admin_sasl, fr_time_delta_wrap(0),
NULL, NULL);
if (status != LDAP_PROC_SUCCESS) return LDAP_PROC_ERROR;
0, our_serverctrls, our_clientctrls, NULL, 0, &msgid);
ROPTIONAL(RDEBUG2, DEBUG2, "Waiting for search result...");
- status = fr_ldap_result(&our_result, NULL, *pconn, msgid, 1, dn, 0);
+ status = fr_ldap_result(&our_result, NULL, *pconn, msgid, 1, dn, fr_time_delta_wrap(0));
switch (status) {
case LDAP_PROC_SUCCESS:
break;
fr_assert(*pconn && (*pconn)->handle);
- if (DEBUG_ENABLED4 || (request && RDEBUG_ENABLED4)) fr_ldap_timeout_debug(request, *pconn, 0, __FUNCTION__);
+ if (DEBUG_ENABLED4 || (request && RDEBUG_ENABLED4)) {
+ fr_ldap_timeout_debug(request, *pconn, fr_time_delta_wrap(0), __FUNCTION__);
+ }
/*
* OpenLDAP library doesn't declare attrs array as const, but
if ((*pconn)->rebound) {
status = fr_ldap_bind(request, pconn,
(*pconn)->config->admin_identity, (*pconn)->config->admin_password,
- &(*pconn)->config->admin_sasl, 0,
+ &(*pconn)->config->admin_sasl, fr_time_delta_wrap(0),
NULL, NULL);
if (status != LDAP_PROC_SUCCESS) return LDAP_PROC_ERROR;
fr_assert(*pconn && (*pconn)->handle);
- if (RDEBUG_ENABLED4) fr_ldap_timeout_debug(request, *pconn, 0, __FUNCTION__);
+ if (RDEBUG_ENABLED4) fr_ldap_timeout_debug(request, *pconn, fr_time_delta_wrap(0), __FUNCTION__);
/*
* Perform all modifications as the admin user.
status = fr_ldap_bind(request, pconn,
(*pconn)->config->admin_identity, (*pconn)->config->admin_password,
&(*pconn)->config->admin_sasl,
- 0, NULL, NULL);
+ fr_time_delta_wrap(0), NULL, NULL);
if (status != LDAP_PROC_SUCCESS) {
return LDAP_PROC_ERROR;
}
(void) ldap_modify_ext((*pconn)->handle, dn, mods, our_serverctrls, our_clientctrls, &msgid);
RDEBUG2("Waiting for modify result...");
- status = fr_ldap_result(NULL, NULL, *pconn, msgid, 0, dn, 0);
+ status = fr_ldap_result(NULL, NULL, *pconn, msgid, 0, dn, fr_time_delta_wrap(0));
switch (status) {
case LDAP_PROC_SUCCESS:
break;
/*
* We're I/O driven, if there's no data someone lied to us
*/
- status = fr_ldap_result(NULL, NULL, c, bind_ctx->msgid, LDAP_MSG_ALL, bind_ctx->bind_dn, 0);
+ status = fr_ldap_result(NULL, NULL, c, bind_ctx->msgid, LDAP_MSG_ALL,
+ bind_ctx->bind_dn, fr_time_delta_wrap(0));
talloc_free(bind_ctx); /* Also removes fd events */
switch (status) {
* Set timeout to be 0.0, which is the magic
* non-blocking value.
*/
- (void) ldap_set_option(c->handle, LDAP_OPT_NETWORK_TIMEOUT, &fr_time_delta_to_timeval(0));
+ (void) ldap_set_option(c->handle, LDAP_OPT_NETWORK_TIMEOUT, &fr_time_delta_to_timeval(fr_time_delta_wrap(0)));
if (bind_ctx->password) {
memcpy(&cred.bv_val, &bind_ctx->password, sizeof(cred.bv_val));
}
status = fr_ldap_bind(NULL, &conn, admin_identity, admin_password,
- &conn->config->admin_sasl, 0, NULL, NULL);
+ &conn->config->admin_sasl, fr_time_delta_wrap(0), NULL, NULL);
if (status != LDAP_PROC_SUCCESS) {
ldap_get_option(handle, LDAP_OPT_ERROR_NUMBER, &ldap_errno);
goto error;\
}
+DIAG_OFF(unused-macros)
#define maybe_ldap_option(_option, _name, _value) \
if (_value) do_ldap_option(_option, _name, _value)
+DIAG_ON(unused-macros)
/*
* Leave "dereference" unset to use the OpenLDAP default.
* libldap requires tv_sec to be -1 to mean that.
*/
do_ldap_option(LDAP_OPT_NETWORK_TIMEOUT, "net_timeout",
- (config->net_timeout ? &fr_time_delta_to_timeval(config->net_timeout) :
- &(struct timeval) { .tv_sec = -1, .tv_usec = 0 }));
+ (fr_time_delta_ispos(config->net_timeout) ?
+ &fr_time_delta_to_timeval(config->net_timeout) :
+ &(struct timeval) { .tv_sec = -1, .tv_usec = 0 }));
#endif
do_ldap_option(LDAP_OPT_TIMELIMIT, "srv_timelimit", &fr_time_delta_to_timeval(config->srv_timelimit));
#endif
#ifdef LDAP_OPT_X_KEEPALIVE_PROBES
- do_ldap_option(LDAP_OPT_X_KEEPALIVE_PROBES, "keepalive_probes",
- &fr_time_delta_to_timeval(config->keepalive_probes));
+ do_ldap_option(LDAP_OPT_X_KEEPALIVE_PROBES, "keepalive_probes", config->keepalive_probes);
#endif
#ifdef LDAP_OPT_X_KEEPALIVE_INTERVAL
do_ldap_option(LDAP_OPT_X_KEEPALIVE_INTERVAL, "keepalive_interval",
- &fr_time_delta_to_timeval(config->keepalive_interval));
+ fr_time_delta_to_sec(config->keepalive_interval));
#endif
#ifdef HAVE_LDAP_START_TLS_S
/* Don't block */
if (ldap_set_option(c->handle, LDAP_OPT_CONNECT_ASYNC, LDAP_OPT_ON) != LDAP_OPT_SUCCESS) goto error;
- fr_ldap_connection_timeout_set(c, 0); /* Forces LDAP_X_CONNECTING */
+ fr_ldap_connection_timeout_set(c, fr_time_delta_wrap(0)); /* Forces LDAP_X_CONNECTING */
state = fr_ldap_state_next(c);
if (state == FR_LDAP_STATE_ERROR) goto error;
* libldap requires tv_sec to be -1 to mean that.
*/
do_ldap_option(LDAP_OPT_NETWORK_TIMEOUT, "net_timeout",
- (timeout ? &fr_time_delta_to_timeval(timeout) :
- &(struct timeval) { .tv_sec = -1, .tv_usec = 0 }));
+ (fr_time_delta_ispos(timeout) ?
+ &fr_time_delta_to_timeval(timeout) :
+ &(struct timeval) { .tv_sec = -1, .tv_usec = 0 }));
#endif
return 0;
* libldap requires tv_sec to be -1 to mean that.
*/
do_ldap_option(LDAP_OPT_NETWORK_TIMEOUT, "net_timeout",
- (c->config->net_timeout ? &fr_time_delta_to_timeval(c->config->net_timeout) :
- &(struct timeval) { .tv_sec = -1, .tv_usec = 0 }));
+ (fr_time_delta_ispos(c->config->net_timeout) ?
+ &fr_time_delta_to_timeval(c->config->net_timeout) :
+ &(struct timeval) { .tv_sec = -1, .tv_usec = 0 }));
#endif
return 0;
/*
* We're I/O driven, if there's no data someone lied to us
*/
- status = fr_ldap_result(NULL, NULL, c, tls_ctx->msgid, LDAP_MSG_ALL, NULL, 0);
+ status = fr_ldap_result(NULL, NULL, c, tls_ctx->msgid, LDAP_MSG_ALL, NULL, fr_time_delta_wrap(0));
talloc_free(tls_ctx); /* Free explicitly so we don't accumulate contexts */
switch (status) {
* Set timeout to be 0.0, which is the magic
* non-blocking value.
*/
- (void) ldap_set_option(c->handle, LDAP_OPT_NETWORK_TIMEOUT, &fr_time_delta_to_timeval(0));
+ (void) ldap_set_option(c->handle, LDAP_OPT_NETWORK_TIMEOUT, &fr_time_delta_to_timeval(fr_time_delta_wrap(0)));
ret = ldap_start_tls(c->handle, our_serverctrls, our_clientctrls, &tls_ctx->msgid);
/*
* If the handle was not connected, this operation
* - 0 on success.
* - -1 on failure.
*/
-int fr_ldap_parse_url_extensions(LDAPControl **sss, request_t *request, fr_ldap_connection_t *conn, char **extensions)
+int fr_ldap_parse_url_extensions(LDAPControl **sss, request_t *request,
+#ifndef HAVE_LDAP_CREATE_SORT_CONTROL
+ UNUSED
+#endif
+ fr_ldap_connection_t *conn, char **extensions)
{
int i;
&inst->conn,
inst->conn->config->admin_identity, inst->conn->config->admin_password,
&(inst->conn->config->admin_sasl),
- 0,
+ fr_time_delta_wrap(0),
NULL, NULL);
if (status != LDAP_PROC_SUCCESS) goto error;
&conn,
dn, password->vp_strvalue,
inst->user_sasl.mech ? &sasl : NULL,
- 0,
+ fr_time_delta_wrap(0),
NULL, NULL);
switch (status) {
case LDAP_PROC_SUCCESS:
* Bind as the user
*/
conn->rebound = true;
- status = fr_ldap_bind(request, &conn, dn, vp->vp_strvalue, NULL, 0, NULL, NULL);
+ status = fr_ldap_bind(request, &conn, dn, vp->vp_strvalue, NULL,
+ fr_time_delta_wrap(0), NULL, NULL);
switch (status) {
case LDAP_PROC_SUCCESS:
rcode = RLM_MODULE_OK;
if ((*pconn)->rebound) {
status = fr_ldap_bind(request, pconn, (*pconn)->config->admin_identity,
(*pconn)->config->admin_password, &(*pconn)->config->admin_sasl,
- 0, NULL, NULL);
+ fr_time_delta_wrap(0), NULL, NULL);
if (status != LDAP_PROC_SUCCESS) {
*rcode = RLM_MODULE_FAIL;
return NULL;