dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0035-LDAP-Improve-error-treatment-from-sdap_cli_connect-i.patch

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