Blame SOURCES/0013-pam_sss-use-unique-id-for-gdm-choice-list.patch

b833e0
From 1b9b7f5a635ede8eee90d13bfe0e1f87e51191a9 Mon Sep 17 00:00:00 2001
b833e0
From: Sumit Bose <sbose@redhat.com>
b833e0
Date: Fri, 13 Nov 2020 12:59:39 +0100
b833e0
Subject: [PATCH 13/16] pam_sss: use unique id for gdm choice list
b833e0
b833e0
Currently the key-id read from the Smartcard is used as key value for
b833e0
the gdm choice list dialog. Since it might be possible that multiple
b833e0
certificates use the same key and hence the same key-id this is not a
b833e0
suitable value.
b833e0
b833e0
With this patch the string representation of a numerical counter is used.
b833e0
b833e0
Resolves: https://github.com/SSSD/sssd/issues/5400
b833e0
b833e0
Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
b833e0
---
b833e0
 src/sss_client/pam_sss.c | 14 ++++++++++++--
b833e0
 1 file changed, 12 insertions(+), 2 deletions(-)
b833e0
b833e0
diff --git a/src/sss_client/pam_sss.c b/src/sss_client/pam_sss.c
b833e0
index b844d257e..04dfdb55d 100644
b833e0
--- a/src/sss_client/pam_sss.c
b833e0
+++ b/src/sss_client/pam_sss.c
b833e0
@@ -128,6 +128,7 @@ struct cert_auth_info {
b833e0
     char *key_id;
b833e0
     char *prompt_str;
b833e0
     char *pam_cert_user;
b833e0
+    char *choice_list_id;
b833e0
     struct cert_auth_info *prev;
b833e0
     struct cert_auth_info *next;
b833e0
 };
b833e0
@@ -141,6 +142,7 @@ static void free_cai(struct cert_auth_info *cai)
b833e0
         free(cai->module_name);
b833e0
         free(cai->key_id);
b833e0
         free(cai->prompt_str);
b833e0
+        free(cai->choice_list_id);
b833e0
         free(cai);
b833e0
     }
b833e0
 }
b833e0
@@ -1698,7 +1700,15 @@ static int prompt_multi_cert_gdm(pam_handle_t *pamh, struct pam_items *pi)
b833e0
             ret = ENOMEM;
b833e0
             goto done;
b833e0
         }
b833e0
-        request->list.items[c].key = cai->key_id;
b833e0
+        free(cai->choice_list_id);
b833e0
+        ret = asprintf(&cai->choice_list_id, "%zu", c);
b833e0
+        if (ret == -1) {
b833e0
+            cai->choice_list_id = NULL;
b833e0
+            ret = ENOMEM;
b833e0
+            goto done;
b833e0
+        }
b833e0
+
b833e0
+        request->list.items[c].key = cai->choice_list_id;
b833e0
         request->list.items[c++].text = prompt;
b833e0
     }
b833e0
 
b833e0
@@ -1719,7 +1729,7 @@ static int prompt_multi_cert_gdm(pam_handle_t *pamh, struct pam_items *pi)
b833e0
     }
b833e0
 
b833e0
     DLIST_FOR_EACH(cai, pi->cert_list) {
b833e0
-        if (strcmp(response->key, cai->key_id) == 0) {
b833e0
+        if (strcmp(response->key, cai->choice_list_id) == 0) {
b833e0
             pam_info(pamh, "Certificate ā€˜%sā€™ selected", cai->key_id);
b833e0
             pi->selected_cert = cai;
b833e0
             ret = 0;
b833e0
-- 
b833e0
2.21.3
b833e0