Blame SOURCES/0046-SYSDB-Better-debugging-for-email-conflicts.patch

ced1f5
From de3b178ada423c10c8f14194a64c299ad96e7bf1 Mon Sep 17 00:00:00 2001
ced1f5
From: =?UTF-8?q?Michal=20=C5=BDidek?= <mzidek@redhat.com>
ced1f5
Date: Thu, 26 Oct 2017 18:38:42 +0200
ced1f5
Subject: [PATCH 46/46] SYSDB: Better debugging for email conflicts
ced1f5
MIME-Version: 1.0
ced1f5
Content-Type: text/plain; charset=UTF-8
ced1f5
Content-Transfer-Encoding: 8bit
ced1f5
ced1f5
Add DEBUG message when conflicts in FQ names or emails
ced1f5
are detected.
ced1f5
ced1f5
Also improve man page to hint on how to work around issue
ced1f5
with conflicting emails.
ced1f5
ced1f5
Note: We store emails in two different attributes in sysdb:
ced1f5
- SYSDB_USER_EMAIL
ced1f5
- SYSDB_NAME_ALIAS - this one is lowercased and used in getpwnam
ced1f5
                     searches.
ced1f5
ced1f5
Resolves:
ced1f5
https://fedorahosted.org/sssd/ticket/3293
ced1f5
ced1f5
Reviewed-by: Fabiano FidĂȘncio <fidencio@redhat.com>
ced1f5
(cherry picked from commit 39d6a3be119b050b0690152b6b443117c8617b1c)
ced1f5
---
ced1f5
 src/db/sysdb_ops.c      |  4 +++-
ced1f5
 src/db/sysdb_search.c   | 15 +++++++++++++++
ced1f5
 src/man/sssd-ldap.5.xml |  9 +++++++++
ced1f5
 3 files changed, 27 insertions(+), 1 deletion(-)
ced1f5
ced1f5
diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c
ced1f5
index 635c7db51f516e2217c93016409499e49289004c..1539c41c93e7d6ebd1e544abbb1707df5578cd72 100644
ced1f5
--- a/src/db/sysdb_ops.c
ced1f5
+++ b/src/db/sysdb_ops.c
ced1f5
@@ -640,7 +640,9 @@ int sysdb_search_user_by_upn_res(TALLOC_CTX *mem_ctx,
ced1f5
         goto done;
ced1f5
     } else if (res->count > 1) {
ced1f5
         DEBUG(SSSDBG_OP_FAILURE,
ced1f5
-              "Search for upn [%s] returns more than one result.\n", upn);
ced1f5
+              "Search for upn [%s] returns more than one result. One of the "
ced1f5
+              "possible reasons can be that several users share the same "
ced1f5
+              "email address.\n", upn);
ced1f5
         ret = EINVAL;
ced1f5
         goto done;
ced1f5
     }
ced1f5
diff --git a/src/db/sysdb_search.c b/src/db/sysdb_search.c
ced1f5
index f488442afcc6eef114437a7110722759f86fe19e..8083966900429b268a3b984f1cad3d47d1099198 100644
ced1f5
--- a/src/db/sysdb_search.c
ced1f5
+++ b/src/db/sysdb_search.c
ced1f5
@@ -218,6 +218,21 @@ int sysdb_getpwnam(TALLOC_CTX *mem_ctx,
ced1f5
         goto done;
ced1f5
     }
ced1f5
 
ced1f5
+    if (res->count > 1) {
ced1f5
+        /* We expected either 0 or 1 result for search with
ced1f5
+         * SYSDB_PWNAM_FILTER, but we got more. This error
ced1f5
+         * is handled individually depending on what function
ced1f5
+         * called sysdb_getpwnam, so we just print a message
ced1f5
+         * here and let the caller decide what error code to
ced1f5
+         * propagate based on res->count > 1. */
ced1f5
+        DEBUG(SSSDBG_CRIT_FAILURE,
ced1f5
+              "Search for [%s] returned multiple results. It can be an email "
ced1f5
+              "address shared among multiple users or an email address of a "
ced1f5
+              "user that conflicts with another user's fully qualified name. "
ced1f5
+              "SSSD will not be able to handle those users properly.\n",
ced1f5
+              sanitized_name);
ced1f5
+    }
ced1f5
+
ced1f5
     /* Merge in the timestamps from the fast ts db */
ced1f5
     ret = sysdb_merge_res_ts_attrs(domain->sysdb, res, attrs);
ced1f5
     if (ret != EOK) {
ced1f5
diff --git a/src/man/sssd-ldap.5.xml b/src/man/sssd-ldap.5.xml
ced1f5
index d38bac3607d294c53ea692130a6b93ced9b0ab82..de596f0da62be9eb61b880b6e1d4a0f33689e25a 100644
ced1f5
--- a/src/man/sssd-ldap.5.xml
ced1f5
+++ b/src/man/sssd-ldap.5.xml
ced1f5
@@ -878,6 +878,15 @@
ced1f5
                             address of the user.
ced1f5
                         </para>
ced1f5
                         <para>
ced1f5
+                            Note: If an email address of a user conflicts with
ced1f5
+                            an email address or fully qualified name of another
ced1f5
+                            user, then SSSD will not be able to serve those
ced1f5
+                            users properly. If for some reason several users
ced1f5
+                            need to share the same email address then set
ced1f5
+                            this option to a nonexistent attribute name in
ced1f5
+                            order to disable user lookup/login by email.
ced1f5
+                        </para>
ced1f5
+                        <para>
ced1f5
                             Default: mail
ced1f5
                         </para>
ced1f5
                     </listitem>
ced1f5
-- 
ced1f5
2.13.6
ced1f5