Blame SOURCES/0015-Revert-LDAP-IPA-add-local-email-address-to-aliases.patch

cdf651
From 9efaade255e59b4a2f5cff2ab78c1db61132a40a Mon Sep 17 00:00:00 2001
cdf651
From: Jakub Hrozek <jhrozek@redhat.com>
cdf651
Date: Thu, 21 Jun 2018 12:27:32 +0200
cdf651
Subject: [PATCH] Revert "LDAP/IPA: add local email address to aliases"
cdf651
MIME-Version: 1.0
cdf651
Content-Type: text/plain; charset=UTF-8
cdf651
Content-Transfer-Encoding: 8bit
cdf651
cdf651
This reverts commit 9a310913d696d190db14c625080678db853a33fd.
cdf651
cdf651
Storing the e-mail address as a nameAlias was a performance optimization
cdf651
to avoid having to fall back to the UPN lookup, but had the disadvantage
cdf651
of returning multiple results for cases where an e-mail address is the
cdf651
same as a user's fully qualified name.
cdf651
cdf651
Since the e-mail lookups would still work without this optimization,
cdf651
just after one more lookup, let's revert the patch.
cdf651
cdf651
Resolves:
cdf651
https://pagure.io/SSSD/sssd/issue/3607
cdf651
cdf651
Reviewed-by: Fabiano FidĂȘncio <fidencio@redhat.com>
cdf651
(cherry picked from commit b0ec3875da281a9c29eda2cb19c1026510866d5b)
cdf651
cdf651
DOWNSTREAM:
cdf651
Resolves: rhbz#1527662 - Handle conflicting e-mail addresses more gracefully
cdf651
---
cdf651
 src/providers/ipa/ipa_s2n_exop.c | 49 --------------------------------
cdf651
 src/providers/ldap/sdap_utils.c  | 22 --------------
cdf651
 2 files changed, 71 deletions(-)
cdf651
cdf651
diff --git a/src/providers/ipa/ipa_s2n_exop.c b/src/providers/ipa/ipa_s2n_exop.c
cdf651
index 9cb735526293ff5a209d732366b86fdb95dc8679..6f3974637a08b9d70e32fb6d79724be4f6e8dbde 100644
cdf651
--- a/src/providers/ipa/ipa_s2n_exop.c
cdf651
+++ b/src/providers/ipa/ipa_s2n_exop.c
cdf651
@@ -2118,49 +2118,6 @@ done:
cdf651
     return ret;
cdf651
 }
cdf651
 
cdf651
-static errno_t add_emails_to_aliases(struct sysdb_attrs *attrs,
cdf651
-                                     struct sss_domain_info *dom)
cdf651
-{
cdf651
-    int ret;
cdf651
-    const char **emails;
cdf651
-    size_t c;
cdf651
-    TALLOC_CTX *tmp_ctx;
cdf651
-
cdf651
-    tmp_ctx = talloc_new(NULL);
cdf651
-    if (tmp_ctx == NULL) {
cdf651
-        DEBUG(SSSDBG_OP_FAILURE, "talloc_new failed.\n");
cdf651
-        return ENOMEM;
cdf651
-    }
cdf651
-
cdf651
-    ret = sysdb_attrs_get_string_array(attrs, SYSDB_USER_EMAIL, tmp_ctx,
cdf651
-                                       &emails);
cdf651
-    if (ret == EOK) {
cdf651
-        for (c = 0; emails[c] != NULL; c++) {
cdf651
-            if (is_email_from_domain(emails[c], dom)) {
cdf651
-                ret = sysdb_attrs_add_lc_name_alias_safe(attrs, emails[c]);
cdf651
-                if (ret != EOK) {
cdf651
-                    DEBUG(SSSDBG_OP_FAILURE,
cdf651
-                          "Failed to add lower-cased version of email [%s] "
cdf651
-                          "into the alias list\n", emails[c]);
cdf651
-                    goto done;
cdf651
-                }
cdf651
-            }
cdf651
-        }
cdf651
-    } else if (ret == ENOENT) {
cdf651
-        DEBUG(SSSDBG_TRACE_ALL, "No email addresses available.\n");
cdf651
-    } else {
cdf651
-        DEBUG(SSSDBG_OP_FAILURE,
cdf651
-              "sysdb_attrs_get_string_array failed, skipping ...\n");
cdf651
-    }
cdf651
-
cdf651
-    ret = EOK;
cdf651
-
cdf651
-done:
cdf651
-    talloc_free(tmp_ctx);
cdf651
-
cdf651
-    return ret;
cdf651
-}
cdf651
-
cdf651
 static errno_t ipa_s2n_save_objects(struct sss_domain_info *dom,
cdf651
                                     struct req_input *req_input,
cdf651
                                     struct resp_attrs *attrs,
cdf651
@@ -2314,12 +2271,6 @@ static errno_t ipa_s2n_save_objects(struct sss_domain_info *dom,
cdf651
                 goto done;
cdf651
             }
cdf651
 
cdf651
-            ret = add_emails_to_aliases(attrs->sysdb_attrs, dom);
cdf651
-            if (ret != EOK) {
cdf651
-                DEBUG(SSSDBG_OP_FAILURE,
cdf651
-                      "add_emails_to_aliases failed, skipping ...\n");
cdf651
-            }
cdf651
-
cdf651
             if (upn == NULL) {
cdf651
                 /* We also have to store a fake UPN here, because otherwise the
cdf651
                  * krb5 child later won't be able to properly construct one as
cdf651
diff --git a/src/providers/ldap/sdap_utils.c b/src/providers/ldap/sdap_utils.c
cdf651
index 0ac3ab2e416d887d00480b5123859c611f514274..6d543101f06ce3cd3925a675af6cabdacb8ebcaa 100644
cdf651
--- a/src/providers/ldap/sdap_utils.c
cdf651
+++ b/src/providers/ldap/sdap_utils.c
cdf651
@@ -87,7 +87,6 @@ sdap_save_all_names(const char *name,
cdf651
     int i;
cdf651
     bool lowercase = !dom->case_sensitive;
cdf651
     bool store_as_fqdn;
cdf651
-    const char **emails;
cdf651
 
cdf651
     switch (entry_type) {
cdf651
     case SYSDB_MEMBER_USER:
cdf651
@@ -144,27 +143,6 @@ sdap_save_all_names(const char *name,
cdf651
 
cdf651
     }
cdf651
 
cdf651
-    ret = sysdb_attrs_get_string_array(ldap_attrs, SYSDB_USER_EMAIL, tmp_ctx,
cdf651
-                                       &emails);
cdf651
-    if (ret == EOK) {
cdf651
-        for (i = 0; emails[i] != NULL; i++) {
cdf651
-            if (is_email_from_domain(emails[i], dom)) {
cdf651
-                ret = sysdb_attrs_add_lc_name_alias_safe(attrs, emails[i]);
cdf651
-                if (ret) {
cdf651
-                    DEBUG(SSSDBG_OP_FAILURE,
cdf651
-                          "Failed to add lower-cased version of email [%s] "
cdf651
-                          "into the alias list\n", emails[i]);
cdf651
-                    goto done;
cdf651
-                }
cdf651
-            }
cdf651
-        }
cdf651
-    } else if (ret == ENOENT) {
cdf651
-        DEBUG(SSSDBG_TRACE_ALL, "No email addresses available.\n");
cdf651
-    } else {
cdf651
-        DEBUG(SSSDBG_OP_FAILURE,
cdf651
-              "sysdb_attrs_get_string_array failed, skipping ...\n");
cdf651
-    }
cdf651
-
cdf651
     ret = EOK;
cdf651
 done:
cdf651
     talloc_free(tmp_ctx);
cdf651
-- 
cdf651
2.17.1
cdf651