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

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