dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0078-LDAP-minor-refactoring-in-auth_send-to-conform-to-ou.patch

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