]> granicus.if.org Git - shadow/commit
Flush sssd caches in addition to nscd caches
authorJakub Hrozek <jakub.hrozek@posteo.se>
Wed, 12 Sep 2018 12:22:11 +0000 (14:22 +0200)
committerJakub Hrozek <jakub.hrozek@posteo.se>
Thu, 13 Sep 2018 12:20:02 +0000 (14:20 +0200)
commit4aaf05d72e9d6daf348cefb8a6ad35d2966cbe9b
tree878dfdf5cfd4bf2fdf1f2ff56450f053d535bc42
parent6bf2d74dfc6adf5f41a4ddab326b06a93e9746ec
Flush sssd caches in addition to nscd caches

Some distributions, notably Fedora, have the following order of nsswitch
modules by default:
    passwd: sss files
    group:  sss files

The advantage of serving local users through SSSD is that the nss_sss
module has a fast mmapped-cache that speeds up NSS lookups compared to
accessing the disk an opening the files on each NSS request.

Traditionally, this has been done with the help of nscd, but using nscd
in parallel with sssd is cumbersome, as both SSSD and nscd use their own
independent caching, so using nscd in setups where sssd is also serving
users from some remote domain (LDAP, AD, ...) can result in a bit of
unpredictability.

More details about why Fedora chose to use sss before files can be found
on e.g.:
    https://fedoraproject.org//wiki/Changes/SSSDCacheForLocalUsers
or:
    https://docs.pagure.org/SSSD.sssd/design_pages/files_provider.html

Now, even though sssd watches the passwd and group files with the help
of inotify, there can still be a small window where someone requests a
user or a group, finds that it doesn't exist, adds the entry and checks
again. Without some support in shadow-utils that would explicitly drop
the sssd caches, the inotify watch can fire a little late, so a
combination of commands like this:
    getent passwd user || useradd user; getent passwd user
can result in the second getent passwd not finding the newly added user
as the racy behaviour might still return the cached negative hit from
the first getent passwd.

This patch more or less copies the already existing support that
shadow-utils had for dropping nscd caches, except using the "sss_cache"
tool that sssd ships.
25 files changed:
configure.ac
lib/Makefile.am
lib/commonio.c
lib/sssd.c [new file with mode: 0644]
lib/sssd.h [new file with mode: 0644]
src/chfn.c
src/chgpasswd.c
src/chpasswd.c
src/chsh.c
src/gpasswd.c
src/groupadd.c
src/groupdel.c
src/groupmod.c
src/grpck.c
src/grpconv.c
src/grpunconv.c
src/newusers.c
src/passwd.c
src/pwck.c
src/pwconv.c
src/pwunconv.c
src/useradd.c
src/userdel.c
src/usermod.c
src/vipw.c