|
|
b2d430 |
From 24ed6bff6cf81c7ba732a5515a2194d9e32cf354 Mon Sep 17 00:00:00 2001
|
|
|
b2d430 |
From: Sumit Bose <sbose@redhat.com>
|
|
|
b2d430 |
Date: Mon, 20 Jun 2016 16:30:03 +0200
|
|
|
b2d430 |
Subject: [PATCH 56/62] LDAP/IPA: add local email address to aliases
|
|
|
b2d430 |
|
|
|
b2d430 |
Adding email-addresses from the local domain to the alias names is
|
|
|
b2d430 |
strictly not needed by might help to speed up lookups in the NSS
|
|
|
b2d430 |
responder.
|
|
|
b2d430 |
|
|
|
b2d430 |
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
b2d430 |
(cherry picked from commit 9a310913d696d190db14c625080678db853a33fd)
|
|
|
b2d430 |
---
|
|
|
b2d430 |
src/providers/ipa/ipa_s2n_exop.c | 49 ++++++++++++++++++++++++++++++++++++++++
|
|
|
b2d430 |
src/providers/ldap/sdap_utils.c | 22 ++++++++++++++++++
|
|
|
b2d430 |
2 files changed, 71 insertions(+)
|
|
|
b2d430 |
|
|
|
b2d430 |
diff --git a/src/providers/ipa/ipa_s2n_exop.c b/src/providers/ipa/ipa_s2n_exop.c
|
|
|
b2d430 |
index b28cc415b1c6dfcf06e0cb9769a36135da01b991..255dad45037a6cb8f399bf2df500215f6fb25b59 100644
|
|
|
b2d430 |
--- a/src/providers/ipa/ipa_s2n_exop.c
|
|
|
b2d430 |
+++ b/src/providers/ipa/ipa_s2n_exop.c
|
|
|
b2d430 |
@@ -1885,6 +1885,49 @@ done:
|
|
|
b2d430 |
return ret;
|
|
|
b2d430 |
}
|
|
|
b2d430 |
|
|
|
b2d430 |
+static errno_t add_emails_to_aliases(struct sysdb_attrs *attrs,
|
|
|
b2d430 |
+ struct sss_domain_info *dom)
|
|
|
b2d430 |
+{
|
|
|
b2d430 |
+ int ret;
|
|
|
b2d430 |
+ const char **emails;
|
|
|
b2d430 |
+ size_t c;
|
|
|
b2d430 |
+ TALLOC_CTX *tmp_ctx;
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ tmp_ctx = talloc_new(NULL);
|
|
|
b2d430 |
+ if (tmp_ctx == NULL) {
|
|
|
b2d430 |
+ DEBUG(SSSDBG_OP_FAILURE, "talloc_new failed.\n");
|
|
|
b2d430 |
+ return ENOMEM;
|
|
|
b2d430 |
+ }
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ ret = sysdb_attrs_get_string_array(attrs, SYSDB_USER_EMAIL, tmp_ctx,
|
|
|
b2d430 |
+ &emails);
|
|
|
b2d430 |
+ if (ret == EOK) {
|
|
|
b2d430 |
+ for (c = 0; emails[c] != NULL; c++) {
|
|
|
b2d430 |
+ if (is_email_from_domain(emails[c], dom)) {
|
|
|
b2d430 |
+ ret = sysdb_attrs_add_lc_name_alias_safe(attrs, emails[c]);
|
|
|
b2d430 |
+ if (ret != EOK) {
|
|
|
b2d430 |
+ DEBUG(SSSDBG_OP_FAILURE,
|
|
|
b2d430 |
+ "Failed to add lower-cased version of email [%s] "
|
|
|
b2d430 |
+ "into the alias list\n", emails[c]);
|
|
|
b2d430 |
+ goto done;
|
|
|
b2d430 |
+ }
|
|
|
b2d430 |
+ }
|
|
|
b2d430 |
+ }
|
|
|
b2d430 |
+ } else if (ret == ENOENT) {
|
|
|
b2d430 |
+ DEBUG(SSSDBG_TRACE_ALL, "No email addresses available.\n");
|
|
|
b2d430 |
+ } else {
|
|
|
b2d430 |
+ DEBUG(SSSDBG_OP_FAILURE,
|
|
|
b2d430 |
+ "sysdb_attrs_get_string_array failed, skipping ...\n");
|
|
|
b2d430 |
+ }
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ ret = EOK;
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+done:
|
|
|
b2d430 |
+ talloc_free(tmp_ctx);
|
|
|
b2d430 |
+
|
|
|
b2d430 |
+ return ret;
|
|
|
b2d430 |
+}
|
|
|
b2d430 |
+
|
|
|
b2d430 |
static errno_t ipa_s2n_save_objects(struct sss_domain_info *dom,
|
|
|
b2d430 |
struct req_input *req_input,
|
|
|
b2d430 |
struct resp_attrs *attrs,
|
|
|
b2d430 |
@@ -2030,6 +2073,12 @@ static errno_t ipa_s2n_save_objects(struct sss_domain_info *dom,
|
|
|
b2d430 |
goto done;
|
|
|
b2d430 |
}
|
|
|
b2d430 |
|
|
|
b2d430 |
+ ret = add_emails_to_aliases(attrs->sysdb_attrs, dom);
|
|
|
b2d430 |
+ if (ret != EOK) {
|
|
|
b2d430 |
+ DEBUG(SSSDBG_OP_FAILURE,
|
|
|
b2d430 |
+ "add_emails_to_aliases failed, skipping ...\n");
|
|
|
b2d430 |
+ }
|
|
|
b2d430 |
+
|
|
|
b2d430 |
if (upn == NULL) {
|
|
|
b2d430 |
/* We also have to store a fake UPN here, because otherwise the
|
|
|
b2d430 |
* krb5 child later won't be able to properly construct one as
|
|
|
b2d430 |
diff --git a/src/providers/ldap/sdap_utils.c b/src/providers/ldap/sdap_utils.c
|
|
|
b2d430 |
index 696af51d66e279d718e9af142ce5ed871eae7727..a3a9642171ca057be5a59dfae192803b84c501c8 100644
|
|
|
b2d430 |
--- a/src/providers/ldap/sdap_utils.c
|
|
|
b2d430 |
+++ b/src/providers/ldap/sdap_utils.c
|
|
|
b2d430 |
@@ -87,6 +87,7 @@ sdap_save_all_names(const char *name,
|
|
|
b2d430 |
int i;
|
|
|
b2d430 |
bool lowercase = !dom->case_sensitive;
|
|
|
b2d430 |
bool store_as_fqdn;
|
|
|
b2d430 |
+ const char **emails;
|
|
|
b2d430 |
|
|
|
b2d430 |
switch (entry_type) {
|
|
|
b2d430 |
case SYSDB_MEMBER_USER:
|
|
|
b2d430 |
@@ -143,6 +144,27 @@ sdap_save_all_names(const char *name,
|
|
|
b2d430 |
|
|
|
b2d430 |
}
|
|
|
b2d430 |
|
|
|
b2d430 |
+ ret = sysdb_attrs_get_string_array(ldap_attrs, SYSDB_USER_EMAIL, tmp_ctx,
|
|
|
b2d430 |
+ &emails);
|
|
|
b2d430 |
+ if (ret == EOK) {
|
|
|
b2d430 |
+ for (i = 0; emails[i] != NULL; i++) {
|
|
|
b2d430 |
+ if (is_email_from_domain(emails[i], dom)) {
|
|
|
b2d430 |
+ ret = sysdb_attrs_add_lc_name_alias_safe(attrs, emails[i]);
|
|
|
b2d430 |
+ if (ret) {
|
|
|
b2d430 |
+ DEBUG(SSSDBG_OP_FAILURE,
|
|
|
b2d430 |
+ "Failed to add lower-cased version of email [%s] "
|
|
|
b2d430 |
+ "into the alias list\n", emails[i]);
|
|
|
b2d430 |
+ goto done;
|
|
|
b2d430 |
+ }
|
|
|
b2d430 |
+ }
|
|
|
b2d430 |
+ }
|
|
|
b2d430 |
+ } else if (ret == ENOENT) {
|
|
|
b2d430 |
+ DEBUG(SSSDBG_TRACE_ALL, "No email addresses available.\n");
|
|
|
b2d430 |
+ } else {
|
|
|
b2d430 |
+ DEBUG(SSSDBG_OP_FAILURE,
|
|
|
b2d430 |
+ "sysdb_attrs_get_string_array failed, skipping ...\n");
|
|
|
b2d430 |
+ }
|
|
|
b2d430 |
+
|
|
|
b2d430 |
ret = EOK;
|
|
|
b2d430 |
done:
|
|
|
b2d430 |
talloc_free(tmp_ctx);
|
|
|
b2d430 |
--
|
|
|
b2d430 |
2.4.11
|
|
|
b2d430 |
|