It is not possible to remove user enumeration cache. When I delete a user at the ldap server, I can remove the cache for a single user, but afterwards the deleted user is still in the users enumeration (getent passwd). sss_cache -E does not affect the user enumeration. I use sssd-1.16.0 on a homebrew linux from scratch.
sss_cache -E
steps to reproduce: root:~$ date ; id testuser1 Fr Feb 2 11:36:30 MET 2018 uid=516(testuser1) gid=100(user) groups=100(user) context=root:user_r:admin_t root:~$ date ; getent passwd | grep testuser1 Fr Feb 2 11:36:44 MET 2018 testuser1:*:516:100:New user:/home/testuser1:/bin/sh
root:~$ date ; id testuser1
Fr Feb 2 11:36:30 MET 2018
uid=516(testuser1) gid=100(user) groups=100(user) context=root:user_r:admin_t
root:~$ date ; getent passwd | grep testuser1
Fr Feb 2 11:36:44 MET 2018
testuser1:*:516:100:New user:/home/testuser1:/bin/sh
root:~$ #remove user on ldap server
root:~$ date ; id testuser1 Fr Feb 2 11:38:00 MET 2018 uid=516(testuser1) gid=100(user) groups=100(user) context=root:user_r:admin_t root:~$ date ; getent passwd | grep testuser1 Fr Feb 2 11:38:07 MET 2018 testuser1:*:516:100:New user:/home/testuser1:/bin/sh
Fr Feb 2 11:38:00 MET 2018
Fr Feb 2 11:38:07 MET 2018
root:~$ sss_cache -E root:~$ date ; id testuser1 Fr Feb 2 11:38:16 MET 2018 id: unknown user testuser1 root:~$ date ; getent passwd | grep testuser1 Fr Feb 2 11:38:21 MET 2018 testuser1:*:516:100:New user:/home/testuser1:/bin/sh
root:~$ sss_cache -E
Fr Feb 2 11:38:16 MET 2018
id: unknown user testuser1
Fr Feb 2 11:38:21 MET 2018
root:~$ #wait some time root:~$ date ; getent passwd | grep testuser1 Fr Feb 2 11:39:14 MET 2018 root:~$
root:~$ #wait some time
Fr Feb 2 11:39:14 MET 2018
root:~$
Here is my sssd.conf:
[sssd] config_file_version = 2 services = nss, pam, ifp domains = shadowutils
[nss] override_homedir = /home/%u override_shell = /bin/sh timeout = 10 memcache_timeout = 30
[pam] timeout = 10 offline_credentials_expiration = 3
[domain/shadowutils] id_provider = proxy proxy_lib_name = files
auth_provider = proxy proxy_pam_target = sssd-shadowutils
proxy_fast_alias = True
[ifp] allowed_uids = 0
[sssd] domains = HEROS5-LDAP services = nss, pam
[domain/HEROS5-LDAP] max_id = 32564 id_provider = ldap auth_provider = ldap chpass_provider = ldap ldap_uri = ldaps://ldapserver.domain.net ldap_search_base = ou=Users,o=HEROS5-LDAP ldap_netgroup_search_base = ou=Netgroups,o=HEROS5-LDAP ldap_referrals = false ldap_id_use_start_tls = True ldap_schema = rfc2307bis ldap_tls_cacertdir = /etc/openldap/certs ldap_pwd_policy = shadow enumerate = true ldap_chpass_update_last_change = true ldap_default_bind_dn = cn=ldapadmin,ou=Admins,o=HEROS5-LDAP ldap_default_authtok = ******* entry_cache_timeout = 30 ldap_tls_reqcert = try cache_credentials = true ldap_purge_cache_timeout=5
Just a note that sss_cache does not remove anything from sssd cache. It only invalidates entries there.
sss_cache
BTW I think you did not wait sufficient time for next enumeration which would remove user from cache.
man sssd-ldap says:
ldap_enumeration_refresh_timeout (integer) Specifies how many seconds SSSD has to wait before refreshing its cache of enumerated records. Default: 300 ldap_purge_cache_timeout (integer) Determine how often to check the cache for inactive entries (such as groups with no members and users who have never logged in) and remove them to save space. Setting this option to zero will disable the cache cleanup operation. Please note that if enumeration is enabled, the cleanup task is required in order to detect entries removed from the server and can't be disabled. By default, the cleanup task will run every 3 hours with enumeration enabled. Default: 0 (disabled)
Looking at the very low ID of the user, I wonder if the user who is still showing up comes from the LDAP domain or the files/proxy domain? Because I saw some strange things with enumeration and the files domain, but I didn't file even a ticket so far..
@jhrozek: The userid 516 is ok, all users from passwd are below 500 and users from ldap are starting with 500.
@lslebodn: Yes when I'm set ldap_purge_cache_timeout to a low value (e.g. 5) the deleted testuser1 vanishes from enumeration shortly after it is not reachable via getent passwd testuser1. My questions now:
ldap_purge_cache_timeout
getent passwd testuser1
Is it useful to set ldap_purge_cache_timeout to 5 sec? Is there a command to clear enumeration cache in sssd manually like sss_cache -E?
@lslebodn: Yes when I'm set ldap_purge_cache_timeout to a low value (e.g. 5) the deleted testuser1 vanishes from enumeration shortly after it is not reachable via getent passwd testuser1. My questions now: Is it useful to set ldap_purge_cache_timeout to 5 sec?
It depends on your use-case. But usually it should be enough to wait maximall y 300 seconds for next enumeration.
I am not sure why do you want to purge users from cache so fast. Maybe it would help to describe use-case and not intermediate steps.
On the other side, if 5 seconds to periodic clean-up task does not cause any problem(hight load, slow response ...) then I cannot see any issue with using it.
Is there a command to clear enumeration cache in sssd manually like sss_cache -E?
Unfortunately, no.
The use-case: I have a GUI user administration tool, which shows all enumerated users (glibc function getpwent is used). In this application users can be deleted or created on the ldap server (ldapmodify calls are used). The problem is now, that when you e.g. delete a user via the gui, this user is still in the users list. Here would it be very nice, if I can invalidate the enumeration cache after deleting the user on the server. Some would suggest now to use ldapsearch for building the user list: This is problematic, because the tool has also a "read-only-mode", where no direct ldap access to the server exists.
My workaround solution would be: Stopping sssd, removing all /var/lib/sss/db/* and starting sssd again.
I am not sure why do you want to purge users from cache so fast. Maybe it would help to describe use-case and not intermediate steps. The use-case: I have a GUI user administration tool, which shows all enumerated users (glibc function getpwent is used). In this application users can be deleted or created on the ldap server (ldapmodify calls are used). The problem is now, that when you e.g. delete a user via the gui, this user is still in the users list. Here would it be very nice, if I can invalidate the enumeration cache after deleting the user on the server. Some would suggest now to use ldapsearch for building the user list: This is problematic, because the tool has also a "read-only-mode", where no direct ldap access to the server exists. My workaround solution would be: Stopping sssd, removing all /var/lib/sss/db/* and starting sssd again.
The use-case: I have a GUI user administration tool, which shows all enumerated users (glibc function getpwent is used). In this application users can be deleted or created on the ldap server (ldapmodify calls are used). The problem is now, that when you e.g. delete a user via the gui, this user is still in the users list. Here would it be very nice, if I can invalidate the enumeration cache after deleting the user on the server. Some would suggest now to use ldapsearch for building the user list: This is problematic, because the tool has also a "read-only-mode", where no direct ldap access to the server exists. My workaround solution would be: Stopping sssd, removing all /var/lib/sss/db/* and starting sssd again.
Thank you very much for explanation. I cannot image more suitable and reliable workaround for your use-case.
BTW such approach for user administration tool will not scale. it take some time do download 1000+ users for sssd.
BTW guys in 389-ds (one of implementation of LDAP server) are doing GUI for management os entries which will be part of Cockpit. It is not ready. But you can ask them about timeframe or help them :-)
I know it is a little bit off-topic. But at least you will know about such effort :-)
https://pagure.io/389-ds-base/issues?status=Open&search_pattern=ockpit
Thank you for your hints, Cockpit is interesting, but a little to fat. The use of my GUI is up to 100 users. You helped me and I think I will set ldap_purge_cache_timeout to 5 sec. The reason for this issue is, that it is not obvious why getent passwd testuser and getent passwd | grep testuser different results have
getent passwd testuser
getent passwd | grep testuser
Metadata Update from @jhrozek: - Issue set to the milestone: SSSD Future releases (no date set yet)
Metadata Update from @thalman: - Issue tagged with: Canditate to close
Thank you for taking time to submit this request for SSSD. Unfortunately this issue was not given priority and the team lacks the capacity to work on it at this time.
Given that we are unable to fulfill this request I am closing the issue as wontfix.
If the issue still persist on recent SSSD you can request re-consideration of this decision by reopening this issue. Please provide additional technical details about its importance to you.
Thank you for understanding.
Metadata Update from @pbrezina: - Issue close_status updated to: wontfix - Issue status updated to: Closed (was: Open)
SSSD is moving from Pagure to Github. This means that new issues and pull requests will be accepted only in SSSD's github repository.
This issue has been cloned to Github and is available here: - https://github.com/SSSD/sssd/issues/4649
If you want to receive further updates on the issue, please navigate to the github issue and click on subscribe button.
subscribe
Thank you for understanding. We apologize for all inconvenience.