4c9df62
From 1e50148c7eadeff96b96811ede747399628a06c6 Mon Sep 17 00:00:00 2001
4c9df62
From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fidencio@redhat.com>
4c9df62
Date: Tue, 7 Nov 2017 23:34:42 +0100
4c9df62
Subject: [PATCH 41/79] LDAP: Improve error treatment from sdap_cli_connect()
4c9df62
 in ldap_auth
4c9df62
MIME-Version: 1.0
4c9df62
Content-Type: text/plain; charset=UTF-8
4c9df62
Content-Transfer-Encoding: 8bit
4c9df62
4c9df62
Because we weren't treating the errors coming from
4c9df62
sdap_cli_connect_recv() properly we ended up introducing a regression in
4c9df62
the commit add72860c7, related to offline authentication.
4c9df62
4c9df62
From now on, let's properly treat errors coming from auth_connect_send(),
4c9df62
which were treated before by going offline when be_resolve_server_recv()
4c9df62
failed, and propagate ETIMEDOUT to the request, thus going offline and
4c9df62
allowing offline authentication on those cases.
4c9df62
4c9df62
Related:
4c9df62
https://pagure.io/SSSD/sssd/issue/3451
4c9df62
4c9df62
Signed-off-by: Fabiano FidĂȘncio <fidencio@redhat.com>
4c9df62
Reviewed-by: Sumit Bose <sbose@redhat.com>
4c9df62
---
4c9df62
 src/providers/ldap/ldap_auth.c | 16 ++++++++++++++--
4c9df62
 1 file changed, 14 insertions(+), 2 deletions(-)
4c9df62
4c9df62
diff --git a/src/providers/ldap/ldap_auth.c b/src/providers/ldap/ldap_auth.c
4c9df62
index a3b1480aae4272d2e10f105a1eaf3a5816c3487c..2e0e2cfd6f8af2bf0c9ad15bd956a55a34777a3c 100644
4c9df62
--- a/src/providers/ldap/ldap_auth.c
4c9df62
+++ b/src/providers/ldap/ldap_auth.c
4c9df62
@@ -716,8 +716,20 @@ static void auth_connect_done(struct tevent_req *subreq)
4c9df62
     ret = sdap_cli_connect_recv(subreq, state, NULL, &state->sh, NULL);
4c9df62
     talloc_zfree(subreq);
4c9df62
     if (ret != EOK) {
4c9df62
-        if (auth_connect_send(req) == NULL) {
4c9df62
-            tevent_req_error(req, ENOMEM);
4c9df62
+        /* As sdap_cli_connect_recv() returns EIO in case all the servers are
4c9df62
+         * down and we have to go offline, let's treat it accordingly here and
4c9df62
+         * allow the PAM responder to with to offline authentication.
4c9df62
+         *
4c9df62
+         * Unfortunately, there's not much pattern within our code and the way
4c9df62
+         * to indicate we're going down in this part of the code is returning
4c9df62
+         * an ETIMEDOUT.
4c9df62
+         */
4c9df62
+        if (ret == EIO) {
4c9df62
+            tevent_req_error(req, ETIMEDOUT);
4c9df62
+        } else {
4c9df62
+            if (auth_connect_send(req) == NULL) {
4c9df62
+                tevent_req_error(req, ENOMEM);
4c9df62
+            }
4c9df62
         }
4c9df62
         return;
4c9df62
     }
4c9df62
-- 
4c9df62
2.15.1
4c9df62