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

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