Skip to content

Commit

Permalink
LDAP: minor refactoring in auth_send() to conform to our coding style
Browse files Browse the repository at this point in the history
Related:
https://pagure.io/SSSD/sssd/issue/3451

A tevent _send() function should only return NULL on ENOMEM, otherwise
it should mark the request as failed but return the req pointer. This
was not much of an issue, before, but the next patch will add another
function call to the auth_send call which would make error handling
awkward.

Reviewed-by: Sumit Bose <sbose@redhat.com>
  • Loading branch information
jhrozek committed Nov 26, 2018
1 parent 1617f3e commit 09091b4
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/providers/ldap/ldap_auth.c
Expand Up @@ -636,6 +636,7 @@ static struct tevent_req *auth_send(TALLOC_CTX *memctx,
{
struct tevent_req *req;
struct auth_state *state;
errno_t ret;

req = tevent_req_create(memctx, &state, struct auth_state);
if (!req) return NULL;
Expand All @@ -645,11 +646,11 @@ static struct tevent_req *auth_send(TALLOC_CTX *memctx,
if (sss_authtok_get_type(authtok) == SSS_AUTHTOK_TYPE_SC_PIN
|| sss_authtok_get_type(authtok) == SSS_AUTHTOK_TYPE_SC_KEYPAD) {
/* Tell frontend that we do not support Smartcard authentication */
tevent_req_error(req, ERR_SC_AUTH_NOT_SUPPORTED);
ret = ERR_SC_AUTH_NOT_SUPPORTED;
} else {
tevent_req_error(req, ERR_AUTH_FAILED);
ret = ERR_AUTH_FAILED;
}
return tevent_req_post(req, ev);
goto fail;
}

state->ev = ev;
Expand All @@ -663,13 +664,17 @@ static struct tevent_req *auth_send(TALLOC_CTX *memctx,
state->sdap_service = ctx->service;
}

if (!auth_connect_send(req)) goto fail;
if (auth_connect_send(req) == NULL) {
ret = ENOMEM;
goto fail;
}

return req;

fail:
talloc_zfree(req);
return NULL;
tevent_req_error(req, ret);
tevent_req_post(req, ev);
return req;
}

static struct tevent_req *auth_connect_send(struct tevent_req *req)
Expand Down

0 comments on commit 09091b4

Please sign in to comment.