Blame SOURCES/0042-pam-refresh-certificate-maps-at-the-end-of-initial-d.patch

b833e0
From cb936e92041d63f79a74c30bae8140c74a18dbc0 Mon Sep 17 00:00:00 2001
b833e0
From: Sumit Bose <sbose@redhat.com>
b833e0
Date: Wed, 20 Jan 2021 18:25:04 +0100
b833e0
Subject: [PATCH 42/42] pam: refresh certificate maps at the end of initial
b833e0
 domains lookup
b833e0
MIME-Version: 1.0
b833e0
Content-Type: text/plain; charset=UTF-8
b833e0
Content-Transfer-Encoding: 8bit
b833e0
b833e0
During startup SSSD's responders send a getDomains request to all
b833e0
backends to refresh some domain related needed by the responders.
b833e0
b833e0
The PAM responder specifically needs the certificate mapping and
b833e0
matching rules when Smartcard authentication is enable. Currently the
b833e0
rules are not refreshed at the end of the initial request but the code
b833e0
assumed that the related structures are initialized after the request
b833e0
finished.
b833e0
b833e0
To avoid a race condition this patch adds a callback to the end of the
b833e0
request to make sure the rules are properly refreshed even if they are
b833e0
already initialized before.
b833e0
b833e0
Resolves: https://github.com/SSSD/sssd/issues/5469
b833e0
b833e0
Reviewed-by: Tomáš Halman <thalman@redhat.com>
b833e0
---
b833e0
 src/responder/pam/pamsrv.c | 14 +++++++++++++-
b833e0
 1 file changed, 13 insertions(+), 1 deletion(-)
b833e0
b833e0
diff --git a/src/responder/pam/pamsrv.c b/src/responder/pam/pamsrv.c
b833e0
index 8b1ce2e92..65370662d 100644
b833e0
--- a/src/responder/pam/pamsrv.c
b833e0
+++ b/src/responder/pam/pamsrv.c
b833e0
@@ -154,6 +154,18 @@ static errno_t get_app_services(struct pam_ctx *pctx)
b833e0
     return EOK;
b833e0
 }
b833e0
 
b833e0
+static void pam_get_domains_callback(void *pvt)
b833e0
+{
b833e0
+    struct pam_ctx *pctx;
b833e0
+    int ret;
b833e0
+
b833e0
+    pctx = talloc_get_type(pvt, struct pam_ctx);
b833e0
+    ret = p11_refresh_certmap_ctx(pctx, pctx->rctx->domains);
b833e0
+    if (ret != EOK) {
b833e0
+        DEBUG(SSSDBG_OP_FAILURE, "p11_refresh_certmap_ctx failed.\n");
b833e0
+    }
b833e0
+}
b833e0
+
b833e0
 static int pam_process_init(TALLOC_CTX *mem_ctx,
b833e0
                             struct tevent_context *ev,
b833e0
                             struct confdb_ctx *cdb,
b833e0
@@ -247,7 +259,7 @@ static int pam_process_init(TALLOC_CTX *mem_ctx,
b833e0
     responder_set_fd_limit(fd_limit);
b833e0
 
b833e0
     ret = schedule_get_domains_task(rctx, rctx->ev, rctx, pctx->rctx->ncache,
b833e0
-                                    NULL, NULL);
b833e0
+                                    pam_get_domains_callback, pctx);
b833e0
     if (ret != EOK) {
b833e0
         DEBUG(SSSDBG_FATAL_FAILURE, "schedule_get_domains_tasks failed.\n");
b833e0
         goto done;
b833e0
-- 
b833e0
2.21.3
b833e0