Blame SOURCES/0050-FILES-The-files-provider-should-not-enumerate.patch

71e593
From c26e713307339699dd26b17f11a2f3136d334ba8 Mon Sep 17 00:00:00 2001
71e593
From: Jakub Hrozek <jhrozek@redhat.com>
71e593
Date: Mon, 15 Oct 2018 22:26:07 +0200
71e593
Subject: [PATCH 50/57] FILES: The files provider should not enumerate
71e593
MIME-Version: 1.0
71e593
Content-Type: text/plain; charset=UTF-8
71e593
Content-Transfer-Encoding: 8bit
71e593
71e593
Resolves:
71e593
https://pagure.io/SSSD/sssd/issue/3849
71e593
71e593
For reason I cannot explain now, the files provider always enumerates.
71e593
There is commit a60e6ec which implements this, but it's clearly wrong,
71e593
because then the plain getent passwd output contains duplicates from
71e593
nss_files and nss_sss:
71e593
71e593
$ getent passwd | sort
71e593
adm:x:3:4:adm:/var/adm:/sbin/nologin
71e593
adm:x:3:4:adm:/var/adm:/sbin/nologin
71e593
bin:x:1:1:bin:/bin:/sbin/nologin
71e593
bin:x:1:1:bin:/bin:/sbin/nologin
71e593
certuser:x:10329:10330::/home/certuser:/bin/bash
71e593
certuser:x:10329:10330::/home/certuser:/bin/bash
71e593
chrony:x:997:994::/var/lib/chrony:/sbin/nologin
71e593
chrony:x:997:994::/var/lib/chrony:/sbin/nologin
71e593
daemon:x:2:2:daemon:/sbin:/sbin/nologin
71e593
daemon:x:2:2:daemon:/sbin:/sbin/nologin
71e593
71e593
Reviewed-by: Michal Židek <mzidek@redhat.com>
71e593
---
71e593
 src/confdb/confdb.c                   |  5 +----
71e593
 src/tests/intg/test_files_provider.py | 22 ----------------------
71e593
 2 files changed, 1 insertion(+), 26 deletions(-)
71e593
71e593
diff --git a/src/confdb/confdb.c b/src/confdb/confdb.c
71e593
index 2f3d90087e640f77835400b11184b684852d7fda..fdc61226fd7d8e078dd7eb7eb532c11be3cc05ec 100644
71e593
--- a/src/confdb/confdb.c
71e593
+++ b/src/confdb/confdb.c
71e593
@@ -875,7 +875,6 @@ static int confdb_get_domain_internal(struct confdb_ctx *cdb,
71e593
     char *default_domain;
71e593
     bool fqnames_default = false;
71e593
     int memcache_timeout;
71e593
-    bool enum_default;
71e593
 
71e593
     tmp_ctx = talloc_new(mem_ctx);
71e593
     if (!tmp_ctx) return ENOMEM;
71e593
@@ -1009,10 +1008,8 @@ static int confdb_get_domain_internal(struct confdb_ctx *cdb,
71e593
                   "Interpreting as true\n", domain->name);
71e593
         domain->enumerate = true;
71e593
     } else { /* assume the new format */
71e593
-        enum_default = is_files_provider(domain);
71e593
-
71e593
         ret = get_entry_as_bool(res->msgs[0], &domain->enumerate,
71e593
-                                CONFDB_DOMAIN_ENUMERATE, enum_default);
71e593
+                                CONFDB_DOMAIN_ENUMERATE, 0);
71e593
         if(ret != EOK) {
71e593
             DEBUG(SSSDBG_FATAL_FAILURE,
71e593
                   "Invalid value for %s\n", CONFDB_DOMAIN_ENUMERATE);
71e593
diff --git a/src/tests/intg/test_files_provider.py b/src/tests/intg/test_files_provider.py
71e593
index ead1cc4c34a8027f74f2a9564863159defce02ef..f0155a2f7e26f17e84e93eab2b99ab72f31d297d 100644
71e593
--- a/src/tests/intg/test_files_provider.py
71e593
+++ b/src/tests/intg/test_files_provider.py
71e593
@@ -32,7 +32,6 @@ import ent
71e593
 import sssd_id
71e593
 from sssd_nss import NssReturnCode
71e593
 from sssd_passwd import (call_sssd_getpwnam,
71e593
-                         call_sssd_enumeration,
71e593
                          call_sssd_getpwuid)
71e593
 from sssd_group import call_sssd_getgrnam, call_sssd_getgrgid
71e593
 from files_ops import passwd_ops_setup, group_ops_setup, PasswdOps, GroupOps
71e593
@@ -633,27 +632,6 @@ def test_mod_user_shell(add_user_with_canary, files_domain_only):
71e593
     check_user(moduser)
71e593
 
71e593
 
71e593
-def test_enum_users(setup_pw_with_canary, files_domain_only):
71e593
-    """
71e593
-    Test that enumerating all users works with the default configuration. Also
71e593
-    test that removing all entries and then enumerating again returns an empty
71e593
-    set
71e593
-    """
71e593
-    num_users = 10
71e593
-    for i in range(1, num_users+1):
71e593
-        user = user_generator(i)
71e593
-        setup_pw_with_canary.useradd(**user)
71e593
-
71e593
-    # syncing with the help of the canary is not reliable after adding
71e593
-    # multiple users because the canary might still be in some caches so that
71e593
-    # the data is not refreshed properly.
71e593
-    subprocess.call(["sss_cache", "-E"])
71e593
-    sssd_getpwnam_sync(CANARY["name"])
71e593
-    user_list = call_sssd_enumeration()
71e593
-    # +1 because the canary is added
71e593
-    assert len(user_list) == num_users+1
71e593
-
71e593
-
71e593
 def incomplete_user_setup(pwd_ops, del_field, exp_field):
71e593
     adduser = dict(USER1)
71e593
     del adduser[del_field]
71e593
-- 
71e593
2.14.4
71e593