From 52939ac7fe32e52dac9368f8bb1f7f1a337fdc87 Mon Sep 17 00:00:00 2001 From: Sumit Bose Date: Thu, 26 Jun 2014 11:59:55 +0200 Subject: [PATCH] LDAP: sdap_auth_send() properly initialize ppolicy In case of an error ppolicy might not be set to NULL and auth_bind_user_done() might show some unexpected debug messages. Additionally this patch fixes the usage of ppolicy in case of an error. --- src/providers/ldap/ldap_auth.c | 12 ++++++------ src/providers/ldap/sdap_async_connection.c | 6 ++++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/providers/ldap/ldap_auth.c b/src/providers/ldap/ldap_auth.c index 40f297c..20fa23a 100644 --- a/src/providers/ldap/ldap_auth.c +++ b/src/providers/ldap/ldap_auth.c @@ -825,14 +825,14 @@ static void auth_bind_user_done(struct tevent_req *subreq) ret = sdap_auth_recv(subreq, state, &ppolicy); talloc_zfree(subreq); - if (ppolicy != NULL) { - DEBUG(SSSDBG_TRACE_ALL,"Found ppolicy data, " - "assuming LDAP password policies are active.\n"); - state->pw_expire_type = PWEXPIRE_LDAP_PASSWORD_POLICY; - state->pw_expire_data = ppolicy; - } switch (ret) { case EOK: + if (ppolicy != NULL) { + DEBUG(SSSDBG_TRACE_ALL,"Found ppolicy data, " + "assuming LDAP password policies are active.\n"); + state->pw_expire_type = PWEXPIRE_LDAP_PASSWORD_POLICY; + state->pw_expire_data = ppolicy; + } break; case ETIMEDOUT: case ERR_NETWORK_IO: diff --git a/src/providers/ldap/sdap_async_connection.c b/src/providers/ldap/sdap_async_connection.c index a1f78c0..ade9879 100644 --- a/src/providers/ldap/sdap_async_connection.c +++ b/src/providers/ldap/sdap_async_connection.c @@ -1282,6 +1282,8 @@ struct tevent_req *sdap_auth_send(TALLOC_CTX *memctx, req = tevent_req_create(memctx, &state, struct sdap_auth_state); if (!req) return NULL; + state->ppolicy = NULL; + if (sasl_mech) { state->is_sasl = true; subreq = sasl_bind_send(state, ev, sh, sasl_mech, sasl_user, NULL); @@ -1370,12 +1372,12 @@ errno_t sdap_auth_recv(struct tevent_req *req, struct sdap_auth_state *state = tevent_req_data(req, struct sdap_auth_state); + TEVENT_REQ_RETURN_ON_ERROR(req); + if (ppolicy != NULL) { *ppolicy = talloc_steal(memctx, state->ppolicy); } - TEVENT_REQ_RETURN_ON_ERROR(req); - return EOK; } -- 1.8.3.1