dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

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

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