Blame SOURCES/shadow-4.6-sssd-flush.patch

5ab9c0
From 4aaf05d72e9d6daf348cefb8a6ad35d2966cbe9b Mon Sep 17 00:00:00 2001
5ab9c0
From: Jakub Hrozek <jakub.hrozek@posteo.se>
5ab9c0
Date: Wed, 12 Sep 2018 14:22:11 +0200
5ab9c0
Subject: [PATCH] Flush sssd caches in addition to nscd caches
5ab9c0
5ab9c0
Some distributions, notably Fedora, have the following order of nsswitch
5ab9c0
modules by default:
5ab9c0
    passwd: sss files
5ab9c0
    group:  sss files
5ab9c0
5ab9c0
The advantage of serving local users through SSSD is that the nss_sss
5ab9c0
module has a fast mmapped-cache that speeds up NSS lookups compared to
5ab9c0
accessing the disk an opening the files on each NSS request.
5ab9c0
5ab9c0
Traditionally, this has been done with the help of nscd, but using nscd
5ab9c0
in parallel with sssd is cumbersome, as both SSSD and nscd use their own
5ab9c0
independent caching, so using nscd in setups where sssd is also serving
5ab9c0
users from some remote domain (LDAP, AD, ...) can result in a bit of
5ab9c0
unpredictability.
5ab9c0
5ab9c0
More details about why Fedora chose to use sss before files can be found
5ab9c0
on e.g.:
5ab9c0
    https://fedoraproject.org//wiki/Changes/SSSDCacheForLocalUsers
5ab9c0
or:
5ab9c0
    https://docs.pagure.org/SSSD.sssd/design_pages/files_provider.html
5ab9c0
5ab9c0
Now, even though sssd watches the passwd and group files with the help
5ab9c0
of inotify, there can still be a small window where someone requests a
5ab9c0
user or a group, finds that it doesn't exist, adds the entry and checks
5ab9c0
again. Without some support in shadow-utils that would explicitly drop
5ab9c0
the sssd caches, the inotify watch can fire a little late, so a
5ab9c0
combination of commands like this:
5ab9c0
    getent passwd user || useradd user; getent passwd user
5ab9c0
can result in the second getent passwd not finding the newly added user
5ab9c0
as the racy behaviour might still return the cached negative hit from
5ab9c0
the first getent passwd.
5ab9c0
5ab9c0
This patch more or less copies the already existing support that
5ab9c0
shadow-utils had for dropping nscd caches, except using the "sss_cache"
5ab9c0
tool that sssd ships.
5ab9c0
---
5ab9c0
 configure.ac    | 10 +++++++
5ab9c0
 lib/Makefile.am |  2 ++
5ab9c0
 lib/commonio.c  |  2 ++
5ab9c0
 lib/sssd.c      | 75 +++++++++++++++++++++++++++++++++++++++++++++++++
5ab9c0
 lib/sssd.h      | 17 +++++++++++
5ab9c0
 src/chfn.c      |  2 ++
5ab9c0
 src/chgpasswd.c |  2 ++
5ab9c0
 src/chpasswd.c  |  2 ++
5ab9c0
 src/chsh.c      |  2 ++
5ab9c0
 src/gpasswd.c   |  2 ++
5ab9c0
 src/groupadd.c  |  2 ++
5ab9c0
 src/groupdel.c  |  2 ++
5ab9c0
 src/groupmod.c  |  2 ++
5ab9c0
 src/grpck.c     |  2 ++
5ab9c0
 src/grpconv.c   |  2 ++
5ab9c0
 src/grpunconv.c |  2 ++
5ab9c0
 src/newusers.c  |  2 ++
5ab9c0
 src/passwd.c    |  2 ++
5ab9c0
 src/pwck.c      |  2 ++
5ab9c0
 src/pwconv.c    |  2 ++
5ab9c0
 src/pwunconv.c  |  2 ++
5ab9c0
 src/useradd.c   |  2 ++
5ab9c0
 src/userdel.c   |  2 ++
5ab9c0
 src/usermod.c   |  2 ++
5ab9c0
 src/vipw.c      |  2 ++
5ab9c0
 25 files changed, 146 insertions(+)
5ab9c0
 create mode 100644 lib/sssd.c
5ab9c0
 create mode 100644 lib/sssd.h
5ab9c0
5ab9c0
diff --git a/configure.ac b/configure.ac
5ab9c0
index 41068a5d..10ad70cf 100644
5ab9c0
--- a/configure.ac
5ab9c0
+++ b/configure.ac
5ab9c0
@@ -280,6 +280,9 @@ AC_ARG_WITH(sha-crypt,
5ab9c0
 AC_ARG_WITH(nscd,
5ab9c0
 	[AC_HELP_STRING([--with-nscd], [enable support for nscd @<:@default=yes@:>@])],
5ab9c0
 	[with_nscd=$withval], [with_nscd=yes])
5ab9c0
+AC_ARG_WITH(sssd,
5ab9c0
+	[AC_HELP_STRING([--with-sssd], [enable support for flushing sssd caches @<:@default=yes@:>@])],
5ab9c0
+	[with_sssd=$withval], [with_sssd=yes])
5ab9c0
 AC_ARG_WITH(group-name-max-length,
5ab9c0
 	[AC_HELP_STRING([--with-group-name-max-length], [set max group name length @<:@default=16@:>@])],
5ab9c0
 	[with_group_name_max_length=$withval], [with_group_name_max_length=yes])
5ab9c0
@@ -304,6 +307,12 @@ if test "$with_nscd" = "yes"; then
5ab9c0
 	              [AC_MSG_ERROR([posix_spawn is needed for nscd support])])
5ab9c0
 fi
5ab9c0
 
5ab9c0
+if test "$with_sssd" = "yes"; then
5ab9c0
+	AC_CHECK_FUNC(posix_spawn,
5ab9c0
+	              [AC_DEFINE(USE_SSSD, 1, [Define to support flushing of sssd caches])],
5ab9c0
+	              [AC_MSG_ERROR([posix_spawn is needed for sssd support])])
5ab9c0
+fi
5ab9c0
+
5ab9c0
 dnl Check for some functions in libc first, only if not found check for
5ab9c0
 dnl other libraries.  This should prevent linking libnsl if not really
5ab9c0
 dnl needed (Linux glibc, Irix), but still link it if needed (Solaris).
5ab9c0
@@ -679,5 +688,6 @@ echo "	shadow group support:		$enable_shadowgrp"
5ab9c0
 echo "	S/Key support:			$with_skey"
5ab9c0
 echo "	SHA passwords encryption:	$with_sha_crypt"
5ab9c0
 echo "	nscd support:			$with_nscd"
5ab9c0
+echo "	sssd support:			$with_sssd"
5ab9c0
 echo "	subordinate IDs support:	$enable_subids"
5ab9c0
 echo
5ab9c0
diff --git a/lib/Makefile.am b/lib/Makefile.am
5ab9c0
index 6db86cd6..fd634542 100644
5ab9c0
--- a/lib/Makefile.am
5ab9c0
+++ b/lib/Makefile.am
5ab9c0
@@ -30,6 +30,8 @@ libshadow_la_SOURCES = \
5ab9c0
 	lockpw.c \
5ab9c0
 	nscd.c \
5ab9c0
 	nscd.h \
5ab9c0
+	sssd.c \
5ab9c0
+	sssd.h \
5ab9c0
 	pam_defs.h \
5ab9c0
 	port.c \
5ab9c0
 	port.h \
5ab9c0
diff --git a/lib/commonio.c b/lib/commonio.c
5ab9c0
index d06b8e7d..96f2d5f7 100644
5ab9c0
--- a/lib/commonio.c
5ab9c0
+++ b/lib/commonio.c
5ab9c0
@@ -45,6 +45,7 @@
5ab9c0
 #include <stdio.h>
5ab9c0
 #include <signal.h>
5ab9c0
 #include "nscd.h"
5ab9c0
+#include "sssd.h"
5ab9c0
 #ifdef WITH_TCB
5ab9c0
 #include <tcb.h>
5ab9c0
 #endif				/* WITH_TCB */
5ab9c0
@@ -485,6 +486,7 @@ static void dec_lock_count (void)
5ab9c0
 			if (nscd_need_reload) {
5ab9c0
 				nscd_flush_cache ("passwd");
5ab9c0
 				nscd_flush_cache ("group");
5ab9c0
+				sssd_flush_cache (SSSD_DB_PASSWD | SSSD_DB_GROUP);
5ab9c0
 				nscd_need_reload = false;
5ab9c0
 			}
5ab9c0
 #ifdef HAVE_LCKPWDF
5ab9c0
diff --git a/lib/sssd.c b/lib/sssd.c
5ab9c0
new file mode 100644
5ab9c0
index 00000000..80e49e55
5ab9c0
--- /dev/null
5ab9c0
+++ b/lib/sssd.c
5ab9c0
@@ -0,0 +1,75 @@
5ab9c0
+/* Author: Peter Vrabec <pvrabec@redhat.com> */
5ab9c0
+
5ab9c0
+#include <config.h>
5ab9c0
+#ifdef USE_SSSD
5ab9c0
+
5ab9c0
+#include <stdio.h>
5ab9c0
+#include <sys/wait.h>
5ab9c0
+#include <sys/types.h>
5ab9c0
+#include "exitcodes.h"
5ab9c0
+#include "defines.h"
5ab9c0
+#include "prototypes.h"
5ab9c0
+#include "sssd.h"
5ab9c0
+
5ab9c0
+#define MSG_SSSD_FLUSH_CACHE_FAILED "%s: Failed to flush the sssd cache.\n"
5ab9c0
+
5ab9c0
+int sssd_flush_cache (int dbflags)
5ab9c0
+{
5ab9c0
+	int status, code, rv;
5ab9c0
+	const char *cmd = "/usr/sbin/sss_cache";
5ab9c0
+	char *sss_cache_args = NULL;
5ab9c0
+	const char *spawnedArgs[] = {"sss_cache", NULL, NULL};
5ab9c0
+	const char *spawnedEnv[] = {NULL};
5ab9c0
+	int i = 0;
5ab9c0
+
5ab9c0
+	sss_cache_args = malloc(4);
5ab9c0
+	if (sss_cache_args == NULL) {
5ab9c0
+	    return -1;
5ab9c0
+	}
5ab9c0
+
5ab9c0
+	sss_cache_args[i++] = '-';
5ab9c0
+	if (dbflags & SSSD_DB_PASSWD) {
5ab9c0
+		sss_cache_args[i++] = 'U';
5ab9c0
+	}
5ab9c0
+	if (dbflags & SSSD_DB_GROUP) {
5ab9c0
+		sss_cache_args[i++] = 'G';
5ab9c0
+	}
5ab9c0
+	sss_cache_args[i++] = '\0';
5ab9c0
+	if (i == 2) {
5ab9c0
+		/* Neither passwd nor group, nothing to do */
5ab9c0
+		free(sss_cache_args);
5ab9c0
+		return 0;
5ab9c0
+	}
5ab9c0
+	spawnedArgs[1] = sss_cache_args;
5ab9c0
+
5ab9c0
+	rv = run_command (cmd, spawnedArgs, spawnedEnv, &status);
5ab9c0
+	free(sss_cache_args);
5ab9c0
+	if (rv != 0) {
5ab9c0
+		/* run_command writes its own more detailed message. */
5ab9c0
+		(void) fprintf (stderr, _(MSG_SSSD_FLUSH_CACHE_FAILED), Prog);
5ab9c0
+		return -1;
5ab9c0
+	}
5ab9c0
+
5ab9c0
+	code = WEXITSTATUS (status);
5ab9c0
+	if (!WIFEXITED (status)) {
5ab9c0
+		(void) fprintf (stderr,
5ab9c0
+		                _("%s: sss_cache did not terminate normally (signal %d)\n"),
5ab9c0
+		                Prog, WTERMSIG (status));
5ab9c0
+		return -1;
5ab9c0
+	} else if (code == E_CMD_NOTFOUND) {
5ab9c0
+		/* sss_cache is not installed, or it is installed but uses an
5ab9c0
+		   interpreter that is missing.  Probably the former. */
5ab9c0
+		return 0;
5ab9c0
+	} else if (code != 0) {
5ab9c0
+		(void) fprintf (stderr, _("%s: sss_cache exited with status %d\n"),
5ab9c0
+		                Prog, code);
5ab9c0
+		(void) fprintf (stderr, _(MSG_SSSD_FLUSH_CACHE_FAILED), Prog);
5ab9c0
+		return -1;
5ab9c0
+	}
5ab9c0
+
5ab9c0
+	return 0;
5ab9c0
+}
5ab9c0
+#else				/* USE_SSSD */
5ab9c0
+extern int errno;		/* warning: ANSI C forbids an empty source file */
5ab9c0
+#endif				/* USE_SSSD */
5ab9c0
+
5ab9c0
diff --git a/lib/sssd.h b/lib/sssd.h
5ab9c0
new file mode 100644
5ab9c0
index 00000000..00ff2a8a
5ab9c0
--- /dev/null
5ab9c0
+++ b/lib/sssd.h
5ab9c0
@@ -0,0 +1,17 @@
5ab9c0
+#ifndef _SSSD_H_
5ab9c0
+#define _SSSD_H_
5ab9c0
+
5ab9c0
+#define SSSD_DB_PASSWD	0x001
5ab9c0
+#define SSSD_DB_GROUP	0x002
5ab9c0
+
5ab9c0
+/*
5ab9c0
+ * sssd_flush_cache - flush specified service buffer in sssd cache
5ab9c0
+ */
5ab9c0
+#ifdef	USE_SSSD
5ab9c0
+extern int sssd_flush_cache (int dbflags);
5ab9c0
+#else
5ab9c0
+#define sssd_flush_cache(service) (0)
5ab9c0
+#endif
5ab9c0
+
5ab9c0
+#endif
5ab9c0
+
5ab9c0
diff --git a/src/chfn.c b/src/chfn.c
5ab9c0
index 18aa3de7..0725e1c7 100644
5ab9c0
--- a/src/chfn.c
5ab9c0
+++ b/src/chfn.c
5ab9c0
@@ -47,6 +47,7 @@
5ab9c0
 #include "defines.h"
5ab9c0
 #include "getdef.h"
5ab9c0
 #include "nscd.h"
5ab9c0
+#include "sssd.h"
5ab9c0
 #ifdef USE_PAM
5ab9c0
 #include "pam_defs.h"
5ab9c0
 #endif
5ab9c0
@@ -746,6 +747,7 @@ int main (int argc, char **argv)
5ab9c0
 	SYSLOG ((LOG_INFO, "changed user '%s' information", user));
5ab9c0
 
5ab9c0
 	nscd_flush_cache ("passwd");
5ab9c0
+	sssd_flush_cache (SSSD_DB_PASSWD);
5ab9c0
 
5ab9c0
 	closelog ();
5ab9c0
 	exit (E_SUCCESS);
5ab9c0
diff --git a/src/chgpasswd.c b/src/chgpasswd.c
5ab9c0
index 13203a46..e5f2eb7e 100644
5ab9c0
--- a/src/chgpasswd.c
5ab9c0
+++ b/src/chgpasswd.c
5ab9c0
@@ -46,6 +46,7 @@
5ab9c0
 #endif				/* ACCT_TOOLS_SETUID */
5ab9c0
 #include "defines.h"
5ab9c0
 #include "nscd.h"
5ab9c0
+#include "sssd.h"
5ab9c0
 #include "prototypes.h"
5ab9c0
 #include "groupio.h"
5ab9c0
 #ifdef	SHADOWGRP
5ab9c0
@@ -581,6 +582,7 @@ int main (int argc, char **argv)
5ab9c0
 	close_files ();
5ab9c0
 
5ab9c0
 	nscd_flush_cache ("group");
5ab9c0
+	sssd_flush_cache (SSSD_DB_GROUP);
5ab9c0
 
5ab9c0
 	return (0);
5ab9c0
 }
5ab9c0
diff --git a/src/chpasswd.c b/src/chpasswd.c
5ab9c0
index 918b27ee..49e79cdb 100644
5ab9c0
--- a/src/chpasswd.c
5ab9c0
+++ b/src/chpasswd.c
5ab9c0
@@ -44,6 +44,7 @@
5ab9c0
 #endif				/* USE_PAM */
5ab9c0
 #include "defines.h"
5ab9c0
 #include "nscd.h"
5ab9c0
+#include "sssd.h"
5ab9c0
 #include "getdef.h"
5ab9c0
 #include "prototypes.h"
5ab9c0
 #include "pwio.h"
5ab9c0
@@ -624,6 +625,7 @@ int main (int argc, char **argv)
5ab9c0
 	}
5ab9c0
 
5ab9c0
 	nscd_flush_cache ("passwd");
5ab9c0
+	sssd_flush_cache (SSSD_DB_PASSWD);
5ab9c0
 
5ab9c0
 	return (0);
5ab9c0
 }
5ab9c0
diff --git a/src/chsh.c b/src/chsh.c
5ab9c0
index c89708b9..910e3dd4 100644
5ab9c0
--- a/src/chsh.c
5ab9c0
+++ b/src/chsh.c
5ab9c0
@@ -46,6 +46,7 @@
5ab9c0
 #include "defines.h"
5ab9c0
 #include "getdef.h"
5ab9c0
 #include "nscd.h"
5ab9c0
+#include "sssd.h"
5ab9c0
 #include "prototypes.h"
5ab9c0
 #include "pwauth.h"
5ab9c0
 #include "pwio.h"
5ab9c0
@@ -557,6 +558,7 @@ int main (int argc, char **argv)
5ab9c0
 	SYSLOG ((LOG_INFO, "changed user '%s' shell to '%s'", user, loginsh));
5ab9c0
 
5ab9c0
 	nscd_flush_cache ("passwd");
5ab9c0
+	sssd_flush_cache (SSSD_DB_PASSWD);
5ab9c0
 
5ab9c0
 	closelog ();
5ab9c0
 	exit (E_SUCCESS);
5ab9c0
diff --git a/src/gpasswd.c b/src/gpasswd.c
5ab9c0
index c4a492b1..4d75af96 100644
5ab9c0
--- a/src/gpasswd.c
5ab9c0
+++ b/src/gpasswd.c
5ab9c0
@@ -45,6 +45,7 @@
5ab9c0
 #include "defines.h"
5ab9c0
 #include "groupio.h"
5ab9c0
 #include "nscd.h"
5ab9c0
+#include "sssd.h"
5ab9c0
 #include "prototypes.h"
5ab9c0
 #ifdef SHADOWGRP
5ab9c0
 #include "sgroupio.h"
5ab9c0
@@ -1201,6 +1202,7 @@ int main (int argc, char **argv)
5ab9c0
 	close_files ();
5ab9c0
 
5ab9c0
 	nscd_flush_cache ("group");
5ab9c0
+	sssd_flush_cache (SSSD_DB_GROUP);
5ab9c0
 
5ab9c0
 	exit (E_SUCCESS);
5ab9c0
 }
5ab9c0
diff --git a/src/groupadd.c b/src/groupadd.c
5ab9c0
index b57006c5..2dd8eec9 100644
5ab9c0
--- a/src/groupadd.c
5ab9c0
+++ b/src/groupadd.c
5ab9c0
@@ -51,6 +51,7 @@
5ab9c0
 #include "getdef.h"
5ab9c0
 #include "groupio.h"
5ab9c0
 #include "nscd.h"
5ab9c0
+#include "sssd.h"
5ab9c0
 #include "prototypes.h"
5ab9c0
 #ifdef	SHADOWGRP
5ab9c0
 #include "sgroupio.h"
5ab9c0
@@ -625,6 +626,7 @@ int main (int argc, char **argv)
5ab9c0
 	close_files ();
5ab9c0
 
5ab9c0
 	nscd_flush_cache ("group");
5ab9c0
+	sssd_flush_cache (SSSD_DB_GROUP);
5ab9c0
 
5ab9c0
 	return E_SUCCESS;
5ab9c0
 }
5ab9c0
diff --git a/src/groupdel.c b/src/groupdel.c
5ab9c0
index 70bed010..f941a84a 100644
5ab9c0
--- a/src/groupdel.c
5ab9c0
+++ b/src/groupdel.c
5ab9c0
@@ -49,6 +49,7 @@
5ab9c0
 #include "defines.h"
5ab9c0
 #include "groupio.h"
5ab9c0
 #include "nscd.h"
5ab9c0
+#include "sssd.h"
5ab9c0
 #include "prototypes.h"
5ab9c0
 #ifdef	SHADOWGRP
5ab9c0
 #include "sgroupio.h"
5ab9c0
@@ -492,6 +493,7 @@ int main (int argc, char **argv)
5ab9c0
 	close_files ();
5ab9c0
 
5ab9c0
 	nscd_flush_cache ("group");
5ab9c0
+	sssd_flush_cache (SSSD_DB_GROUP);
5ab9c0
 
5ab9c0
 	return E_SUCCESS;
5ab9c0
 }
5ab9c0
diff --git a/src/groupmod.c b/src/groupmod.c
5ab9c0
index b293b98f..1dca5fc9 100644
5ab9c0
--- a/src/groupmod.c
5ab9c0
+++ b/src/groupmod.c
5ab9c0
@@ -51,6 +51,7 @@
5ab9c0
 #include "groupio.h"
5ab9c0
 #include "pwio.h"
5ab9c0
 #include "nscd.h"
5ab9c0
+#include "sssd.h"
5ab9c0
 #include "prototypes.h"
5ab9c0
 #ifdef	SHADOWGRP
5ab9c0
 #include "sgroupio.h"
5ab9c0
@@ -877,6 +878,7 @@ int main (int argc, char **argv)
5ab9c0
 	close_files ();
5ab9c0
 
5ab9c0
 	nscd_flush_cache ("group");
5ab9c0
+	sssd_flush_cache (SSSD_DB_GROUP);
5ab9c0
 
5ab9c0
 	return E_SUCCESS;
5ab9c0
 }
5ab9c0
diff --git a/src/grpck.c b/src/grpck.c
5ab9c0
index ea5d3b39..6140b10d 100644
5ab9c0
--- a/src/grpck.c
5ab9c0
+++ b/src/grpck.c
5ab9c0
@@ -45,6 +45,7 @@
5ab9c0
 #include "defines.h"
5ab9c0
 #include "groupio.h"
5ab9c0
 #include "nscd.h"
5ab9c0
+#include "sssd.h"
5ab9c0
 #include "prototypes.h"
5ab9c0
 
5ab9c0
 #ifdef SHADOWGRP
5ab9c0
@@ -870,6 +871,7 @@ int main (int argc, char **argv)
5ab9c0
 	close_files (changed);
5ab9c0
 
5ab9c0
 	nscd_flush_cache ("group");
5ab9c0
+	sssd_flush_cache (SSSD_DB_GROUP);
5ab9c0
 
5ab9c0
 	/*
5ab9c0
 	 * Tell the user what we did and exit.
5ab9c0
diff --git a/src/grpconv.c b/src/grpconv.c
5ab9c0
index f95f4960..5e5eaaca 100644
5ab9c0
--- a/src/grpconv.c
5ab9c0
+++ b/src/grpconv.c
5ab9c0
@@ -48,6 +48,7 @@
5ab9c0
 #include <unistd.h>
5ab9c0
 #include <getopt.h>
5ab9c0
 #include "nscd.h"
5ab9c0
+#include "sssd.h"
5ab9c0
 #include "prototypes.h"
5ab9c0
 /*@-exitarg@*/
5ab9c0
 #include "exitcodes.h"
5ab9c0
@@ -273,6 +274,7 @@ int main (int argc, char **argv)
5ab9c0
 	}
5ab9c0
 
5ab9c0
 	nscd_flush_cache ("group");
5ab9c0
+	sssd_flush_cache (SSSD_DB_GROUP);
5ab9c0
 
5ab9c0
 	return 0;
5ab9c0
 }
5ab9c0
diff --git a/src/grpunconv.c b/src/grpunconv.c
5ab9c0
index 253f06f5..e4105c26 100644
5ab9c0
--- a/src/grpunconv.c
5ab9c0
+++ b/src/grpunconv.c
5ab9c0
@@ -48,6 +48,7 @@
5ab9c0
 #include <grp.h>
5ab9c0
 #include <getopt.h>
5ab9c0
 #include "nscd.h"
5ab9c0
+#include "sssd.h"
5ab9c0
 #include "prototypes.h"
5ab9c0
 /*@-exitarg@*/
5ab9c0
 #include "exitcodes.h"
5ab9c0
@@ -236,6 +237,7 @@ int main (int argc, char **argv)
5ab9c0
 	}
5ab9c0
 
5ab9c0
 	nscd_flush_cache ("group");
5ab9c0
+	sssd_flush_cache (SSSD_DB_GROUP);
5ab9c0
 
5ab9c0
 	return 0;
5ab9c0
 }
5ab9c0
diff --git a/src/newusers.c b/src/newusers.c
5ab9c0
index 8e4bef97..7c3bb1c2 100644
5ab9c0
--- a/src/newusers.c
5ab9c0
+++ b/src/newusers.c
5ab9c0
@@ -62,6 +62,7 @@
5ab9c0
 #include "getdef.h"
5ab9c0
 #include "groupio.h"
5ab9c0
 #include "nscd.h"
5ab9c0
+#include "sssd.h"
5ab9c0
 #include "pwio.h"
5ab9c0
 #include "sgroupio.h"
5ab9c0
 #include "shadowio.h"
5ab9c0
@@ -1233,6 +1234,7 @@ int main (int argc, char **argv)
5ab9c0
 
5ab9c0
 	nscd_flush_cache ("passwd");
5ab9c0
 	nscd_flush_cache ("group");
5ab9c0
+	sssd_flush_cache (SSSD_DB_PASSWD | SSSD_DB_GROUP);
5ab9c0
 
5ab9c0
 #ifdef USE_PAM
5ab9c0
 	unsigned int i;
5ab9c0
diff --git a/src/passwd.c b/src/passwd.c
5ab9c0
index 3af3e651..5bea2765 100644
5ab9c0
--- a/src/passwd.c
5ab9c0
+++ b/src/passwd.c
5ab9c0
@@ -51,6 +51,7 @@
5ab9c0
 #include "defines.h"
5ab9c0
 #include "getdef.h"
5ab9c0
 #include "nscd.h"
5ab9c0
+#include "sssd.h"
5ab9c0
 #include "prototypes.h"
5ab9c0
 #include "pwauth.h"
5ab9c0
 #include "pwio.h"
5ab9c0
@@ -1150,6 +1151,7 @@ int main (int argc, char **argv)
5ab9c0
 
5ab9c0
 	nscd_flush_cache ("passwd");
5ab9c0
 	nscd_flush_cache ("group");
5ab9c0
+	sssd_flush_cache (SSSD_DB_PASSWD | SSSD_DB_GROUP);
5ab9c0
 
5ab9c0
 	SYSLOG ((LOG_INFO, "password for '%s' changed by '%s'", name, myname));
5ab9c0
 	closelog ();
5ab9c0
diff --git a/src/pwck.c b/src/pwck.c
5ab9c0
index 05df68ec..0ffb711e 100644
5ab9c0
--- a/src/pwck.c
5ab9c0
+++ b/src/pwck.c
5ab9c0
@@ -48,6 +48,7 @@
5ab9c0
 #include "shadowio.h"
5ab9c0
 #include "getdef.h"
5ab9c0
 #include "nscd.h"
5ab9c0
+#include "sssd.h"
5ab9c0
 #ifdef WITH_TCB
5ab9c0
 #include "tcbfuncs.h"
5ab9c0
 #endif				/* WITH_TCB */
5ab9c0
@@ -877,6 +878,7 @@ int main (int argc, char **argv)
5ab9c0
 	close_files (changed);
5ab9c0
 
5ab9c0
 	nscd_flush_cache ("passwd");
5ab9c0
+	sssd_flush_cache (SSSD_DB_PASSWD);
5ab9c0
 
5ab9c0
 	/*
5ab9c0
 	 * Tell the user what we did and exit.
5ab9c0
diff --git a/src/pwconv.c b/src/pwconv.c
5ab9c0
index d6ee31a8..9c69fa13 100644
5ab9c0
--- a/src/pwconv.c
5ab9c0
+++ b/src/pwconv.c
5ab9c0
@@ -72,6 +72,7 @@
5ab9c0
 #include "pwio.h"
5ab9c0
 #include "shadowio.h"
5ab9c0
 #include "nscd.h"
5ab9c0
+#include "sssd.h"
5ab9c0
 
5ab9c0
 /*
5ab9c0
  * exit status values
5ab9c0
@@ -328,6 +329,7 @@ int main (int argc, char **argv)
5ab9c0
 	}
5ab9c0
 
5ab9c0
 	nscd_flush_cache ("passwd");
5ab9c0
+	sssd_flush_cache (SSSD_DB_PASSWD);
5ab9c0
 
5ab9c0
 	return E_SUCCESS;
5ab9c0
 }
5ab9c0
diff --git a/src/pwunconv.c b/src/pwunconv.c
5ab9c0
index fabf0237..e11ea494 100644
5ab9c0
--- a/src/pwunconv.c
5ab9c0
+++ b/src/pwunconv.c
5ab9c0
@@ -42,6 +42,7 @@
5ab9c0
 #include <getopt.h>
5ab9c0
 #include "defines.h"
5ab9c0
 #include "nscd.h"
5ab9c0
+#include "sssd.h"
5ab9c0
 #include "prototypes.h"
5ab9c0
 #include "pwio.h"
5ab9c0
 #include "shadowio.h"
5ab9c0
@@ -250,6 +251,7 @@ int main (int argc, char **argv)
5ab9c0
 	}
5ab9c0
 
5ab9c0
 	nscd_flush_cache ("passwd");
5ab9c0
+	sssd_flush_cache (SSSD_DB_PASSWD);
5ab9c0
 
5ab9c0
 	return 0;
5ab9c0
 }
5ab9c0
diff --git a/src/useradd.c b/src/useradd.c
5ab9c0
index ca90f076..b0c2224d 100644
5ab9c0
--- a/src/useradd.c
5ab9c0
+++ b/src/useradd.c
5ab9c0
@@ -60,6 +60,7 @@
5ab9c0
 #include "getdef.h"
5ab9c0
 #include "groupio.h"
5ab9c0
 #include "nscd.h"
5ab9c0
+#include "sssd.h"
5ab9c0
 #include "prototypes.h"
5ab9c0
 #include "pwauth.h"
5ab9c0
 #include "pwio.h"
5ab9c0
@@ -2425,6 +2426,7 @@ int main (int argc, char **argv)
5ab9c0
 
5ab9c0
 	nscd_flush_cache ("passwd");
5ab9c0
 	nscd_flush_cache ("group");
5ab9c0
+	sssd_flush_cache (SSSD_DB_PASSWD | SSSD_DB_GROUP);
5ab9c0
 
5ab9c0
 	/*
5ab9c0
 	 * tallylog_reset needs to be able to lookup
5ab9c0
diff --git a/src/userdel.c b/src/userdel.c
5ab9c0
index c8de1d31..0715e4fe 100644
5ab9c0
--- a/src/userdel.c
5ab9c0
+++ b/src/userdel.c
5ab9c0
@@ -53,6 +53,7 @@
5ab9c0
 #include "getdef.h"
5ab9c0
 #include "groupio.h"
5ab9c0
 #include "nscd.h"
5ab9c0
+#include "sssd.h"
5ab9c0
 #include "prototypes.h"
5ab9c0
 #include "pwauth.h"
5ab9c0
 #include "pwio.h"
5ab9c0
@@ -1328,6 +1329,7 @@ int main (int argc, char **argv)
5ab9c0
 
5ab9c0
 	nscd_flush_cache ("passwd");
5ab9c0
 	nscd_flush_cache ("group");
5ab9c0
+	sssd_flush_cache (SSSD_DB_PASSWD | SSSD_DB_GROUP);
5ab9c0
 
5ab9c0
 	return ((0 != errors) ? E_HOMEDIR : E_SUCCESS);
5ab9c0
 }
5ab9c0
diff --git a/src/usermod.c b/src/usermod.c
5ab9c0
index 7355ad31..fd9a98a6 100644
5ab9c0
--- a/src/usermod.c
5ab9c0
+++ b/src/usermod.c
5ab9c0
@@ -57,6 +57,7 @@
5ab9c0
 #include "getdef.h"
5ab9c0
 #include "groupio.h"
5ab9c0
 #include "nscd.h"
5ab9c0
+#include "sssd.h"
5ab9c0
 #include "prototypes.h"
5ab9c0
 #include "pwauth.h"
5ab9c0
 #include "pwio.h"
5ab9c0
@@ -2255,6 +2256,7 @@ int main (int argc, char **argv)
5ab9c0
 
5ab9c0
 	nscd_flush_cache ("passwd");
5ab9c0
 	nscd_flush_cache ("group");
5ab9c0
+	sssd_flush_cache (SSSD_DB_PASSWD | SSSD_DB_GROUP);
5ab9c0
 
5ab9c0
 #ifdef WITH_SELINUX
5ab9c0
 	if (Zflg) {
5ab9c0
diff --git a/src/vipw.c b/src/vipw.c
5ab9c0
index 6d730f65..2cfac6b4 100644
5ab9c0
--- a/src/vipw.c
5ab9c0
+++ b/src/vipw.c
5ab9c0
@@ -42,6 +42,7 @@
5ab9c0
 #include "defines.h"
5ab9c0
 #include "groupio.h"
5ab9c0
 #include "nscd.h"
5ab9c0
+#include "sssd.h"
5ab9c0
 #include "prototypes.h"
5ab9c0
 #include "pwio.h"
5ab9c0
 #include "sgroupio.h"
5ab9c0
@@ -556,6 +557,7 @@ int main (int argc, char **argv)
5ab9c0
 
5ab9c0
 	nscd_flush_cache ("passwd");
5ab9c0
 	nscd_flush_cache ("group");
5ab9c0
+	sssd_flush_cache (SSSD_DB_PASSWD | SSSD_DB_GROUP);
5ab9c0
 
5ab9c0
 	return E_SUCCESS;
5ab9c0
 }