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

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