|
|
0d602d |
From 876f1cb87d1649d0681bf6475ab589287f15babb Mon Sep 17 00:00:00 2001
|
|
|
0d602d |
From: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
0d602d |
Date: Thu, 22 Nov 2018 12:51:14 +0100
|
|
|
0d602d |
Subject: [PATCH 52/54] LDAP: minor refactoring in auth_send() to conform to
|
|
|
0d602d |
our coding style
|
|
|
0d602d |
|
|
|
0d602d |
Related:
|
|
|
0d602d |
https://pagure.io/SSSD/sssd/issue/3451
|
|
|
0d602d |
|
|
|
0d602d |
A tevent _send() function should only return NULL on ENOMEM, otherwise
|
|
|
0d602d |
it should mark the request as failed but return the req pointer. This
|
|
|
0d602d |
was not much of an issue, before, but the next patch will add another
|
|
|
0d602d |
function call to the auth_send call which would make error handling
|
|
|
0d602d |
awkward.
|
|
|
0d602d |
|
|
|
0d602d |
Reviewed-by: Sumit Bose <sbose@redhat.com>
|
|
|
0d602d |
(cherry picked from commit 09091b4b60456a989ecc8c3b6f76661a14c108ba)
|
|
|
0d602d |
---
|
|
|
0d602d |
src/providers/ldap/ldap_auth.c | 17 +++++++++++------
|
|
|
0d602d |
1 file changed, 11 insertions(+), 6 deletions(-)
|
|
|
0d602d |
|
|
|
0d602d |
diff --git a/src/providers/ldap/ldap_auth.c b/src/providers/ldap/ldap_auth.c
|
|
|
0d602d |
index d40bc9414..c409353d9 100644
|
|
|
0d602d |
--- a/src/providers/ldap/ldap_auth.c
|
|
|
0d602d |
+++ b/src/providers/ldap/ldap_auth.c
|
|
|
0d602d |
@@ -636,6 +636,7 @@ static struct tevent_req *auth_send(TALLOC_CTX *memctx,
|
|
|
0d602d |
{
|
|
|
0d602d |
struct tevent_req *req;
|
|
|
0d602d |
struct auth_state *state;
|
|
|
0d602d |
+ errno_t ret;
|
|
|
0d602d |
|
|
|
0d602d |
req = tevent_req_create(memctx, &state, struct auth_state);
|
|
|
0d602d |
if (!req) return NULL;
|
|
|
0d602d |
@@ -645,11 +646,11 @@ static struct tevent_req *auth_send(TALLOC_CTX *memctx,
|
|
|
0d602d |
if (sss_authtok_get_type(authtok) == SSS_AUTHTOK_TYPE_SC_PIN
|
|
|
0d602d |
|| sss_authtok_get_type(authtok) == SSS_AUTHTOK_TYPE_SC_KEYPAD) {
|
|
|
0d602d |
/* Tell frontend that we do not support Smartcard authentication */
|
|
|
0d602d |
- tevent_req_error(req, ERR_SC_AUTH_NOT_SUPPORTED);
|
|
|
0d602d |
+ ret = ERR_SC_AUTH_NOT_SUPPORTED;
|
|
|
0d602d |
} else {
|
|
|
0d602d |
- tevent_req_error(req, ERR_AUTH_FAILED);
|
|
|
0d602d |
+ ret = ERR_AUTH_FAILED;
|
|
|
0d602d |
}
|
|
|
0d602d |
- return tevent_req_post(req, ev);
|
|
|
0d602d |
+ goto fail;
|
|
|
0d602d |
}
|
|
|
0d602d |
|
|
|
0d602d |
state->ev = ev;
|
|
|
0d602d |
@@ -663,13 +664,17 @@ static struct tevent_req *auth_send(TALLOC_CTX *memctx,
|
|
|
0d602d |
state->sdap_service = ctx->service;
|
|
|
0d602d |
}
|
|
|
0d602d |
|
|
|
0d602d |
- if (!auth_connect_send(req)) goto fail;
|
|
|
0d602d |
+ if (auth_connect_send(req) == NULL) {
|
|
|
0d602d |
+ ret = ENOMEM;
|
|
|
0d602d |
+ goto fail;
|
|
|
0d602d |
+ }
|
|
|
0d602d |
|
|
|
0d602d |
return req;
|
|
|
0d602d |
|
|
|
0d602d |
fail:
|
|
|
0d602d |
- talloc_zfree(req);
|
|
|
0d602d |
- return NULL;
|
|
|
0d602d |
+ tevent_req_error(req, ret);
|
|
|
0d602d |
+ tevent_req_post(req, ev);
|
|
|
0d602d |
+ return req;
|
|
|
0d602d |
}
|
|
|
0d602d |
|
|
|
0d602d |
static struct tevent_req *auth_connect_send(struct tevent_req *req)
|
|
|
0d602d |
--
|
|
|
0d602d |
2.19.1
|
|
|
0d602d |
|