Blame SOURCES/0018-ipa-do-not-add-guessed-principal-to-the-cache.patch

0034f4
From 29aa434816ce6ae2aaf3b0bcf24b89f05f426d1b Mon Sep 17 00:00:00 2001
0034f4
From: Sumit Bose <sbose@redhat.com>
0034f4
Date: Tue, 22 Nov 2022 13:39:26 +0100
0034f4
Subject: [PATCH 18/19] ipa: do not add guessed principal to the cache
0034f4
0034f4
Currently on IPA clients a calculated principal based on the user name
0034f4
and the Kerberos realm is added to the cached user object. This code is
0034f4
quite old and might have been necessary at times when sub-domain support
0034f4
was added to SSSD. But since quite some time SSSD is capable of
0034f4
generating the principal on the fly during authentication if nothing is
0034f4
stored in the cache.
0034f4
0034f4
Removing the code makes the cache more consistent with other use-cases,
0034f4
e.g. with the IPA server where this attribute is empty, and allows to
0034f4
properly detect a missing UPN, e.g. during the PAC validation.
0034f4
0034f4
Resolves: https://github.com/SSSD/sssd/issues/6451
0034f4
0034f4
(cherry picked from commit b3d7a4f6d4e1d4fa1bd33b296cd4301973f1860c)
0034f4
0034f4
Reviewed-by: Alexey Tikhonov <atikhono@redhat.com>
0034f4
---
0034f4
 src/providers/ipa/ipa_s2n_exop.c | 44 --------------------------------
0034f4
 1 file changed, 44 deletions(-)
0034f4
0034f4
diff --git a/src/providers/ipa/ipa_s2n_exop.c b/src/providers/ipa/ipa_s2n_exop.c
0034f4
index c68c1de26..81927a6b8 100644
0034f4
--- a/src/providers/ipa/ipa_s2n_exop.c
0034f4
+++ b/src/providers/ipa/ipa_s2n_exop.c
0034f4
@@ -2467,8 +2467,6 @@ static errno_t ipa_s2n_save_objects(struct sss_domain_info *dom,
0034f4
     time_t now;
0034f4
     struct sss_nss_homedir_ctx homedir_ctx;
0034f4
     char *name = NULL;
0034f4
-    char *realm;
0034f4
-    char *short_name = NULL;
0034f4
     char *upn = NULL;
0034f4
     gid_t gid;
0034f4
     gid_t orig_gid = 0;
0034f4
@@ -2607,48 +2605,6 @@ static errno_t ipa_s2n_save_objects(struct sss_domain_info *dom,
0034f4
                 goto done;
0034f4
             }
0034f4
 
0034f4
-            if (upn == NULL) {
0034f4
-                /* We also have to store a fake UPN here, because otherwise the
0034f4
-                 * krb5 child later won't be able to properly construct one as
0034f4
-                 * the username is fully qualified but the child doesn't have
0034f4
-                 * access to the regex to deconstruct it */
0034f4
-                /* FIXME: The real UPN is available from the PAC, we should get
0034f4
-                 * it from there. */
0034f4
-                realm = get_uppercase_realm(tmp_ctx, dom->name);
0034f4
-                if (!realm) {
0034f4
-                    DEBUG(SSSDBG_OP_FAILURE, "failed to get realm.\n");
0034f4
-                    ret = ENOMEM;
0034f4
-                    goto done;
0034f4
-                }
0034f4
-
0034f4
-                ret = sss_parse_internal_fqname(tmp_ctx, attrs->a.user.pw_name,
0034f4
-                                                &short_name, NULL);
0034f4
-                if (ret != EOK) {
0034f4
-                    DEBUG(SSSDBG_CRIT_FAILURE,
0034f4
-                          "Cannot parse internal name %s\n",
0034f4
-                          attrs->a.user.pw_name);
0034f4
-                    goto done;
0034f4
-                }
0034f4
-
0034f4
-                upn = talloc_asprintf(tmp_ctx, "%s@%s", short_name, realm);
0034f4
-                if (!upn) {
0034f4
-                    DEBUG(SSSDBG_OP_FAILURE, "failed to format UPN.\n");
0034f4
-                    ret = ENOMEM;
0034f4
-                    goto done;
0034f4
-                }
0034f4
-
0034f4
-                /* We might already have the SID or the UPN from other sources
0034f4
-                 * hence sysdb_attrs_add_string_safe is used to avoid double
0034f4
-                 * entries. */
0034f4
-                ret = sysdb_attrs_add_string_safe(attrs->sysdb_attrs, SYSDB_UPN,
0034f4
-                                                  upn);
0034f4
-                if (ret != EOK) {
0034f4
-                    DEBUG(SSSDBG_OP_FAILURE,
0034f4
-                          "sysdb_attrs_add_string failed.\n");
0034f4
-                    goto done;
0034f4
-                }
0034f4
-            }
0034f4
-
0034f4
             if (req_input->type == REQ_INP_SECID) {
0034f4
                 ret = sysdb_attrs_add_string_safe(attrs->sysdb_attrs,
0034f4
                                                   SYSDB_SID_STR,
0034f4
-- 
0034f4
2.37.3
0034f4