Sophie

Sophie

distrib > Mandriva > 2007.0 > x86_64 > media > main-release-src > by-pkgid > f01202932fbd367fcf86f895d058ab36 > files > 8

shadow-utils-4.0.12-3mdv2007.0.src.rpm

--- shadow-4.0.12/lib/nscd.c.nscd	2005-07-08 20:04:04.000000000 +0200
+++ shadow-4.0.12/lib/nscd.c	2005-09-13 15:52:49.000000000 +0200
@@ -1,3 +1,30 @@
+/* club nscd so it invalidates its cache */
+/* notting@redhat.com 19990408           */
+
+#include <signal.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+
+
+int hup_nscd() {
+    FILE *pidfile;
+    char *pidbuf=calloc(256,sizeof(char));
+    int pid;
+    
+    if ((pidfile=fopen("/var/run/nscd/nscd.pid","r"))!=NULL) {
+	pidbuf=fgets(pidbuf,256,pidfile);
+	fclose(pidfile);
+	if (pidbuf!=NULL) {
+	    pid=atoi(pidbuf);
+	    free(pidbuf);
+	    if (pid>0) {
+		return kill(pid,SIGHUP);
+	    }
+	}
+    }
+    return -1;
+}
 /* Copyright (c) 1999 SuSE GmbH Nuerenberg, Germany
    Author: Thorsten Kukuk <kukuk@suse.de> */
 
--- shadow-4.0.12/src/groupmod.c.nscd	2005-08-02 19:49:17.000000000 +0200
+++ shadow-4.0.12/src/groupmod.c	2005-09-13 15:52:49.000000000 +0200
@@ -511,6 +511,8 @@
 
 	close_files ();
 
+        hup_nscd ();
+
 #ifdef USE_PAM
 	if (retval == PAM_SUCCESS) {
 		retval = pam_chauthtok (pamh, 0);
--- shadow-4.0.12/src/groupdel.c.nscd	2005-08-11 18:23:34.000000000 +0200
+++ shadow-4.0.12/src/groupdel.c	2005-09-13 15:52:49.000000000 +0200
@@ -325,6 +325,8 @@
 	nscd_flush_cache ("group");
 
 	close_files ();
+        
+	hup_nscd ();
 
 #ifdef USE_PAM
 	if (retval == PAM_SUCCESS) {
--- shadow-4.0.12/src/userdel.c.nscd	2005-09-13 15:52:49.000000000 +0200
+++ shadow-4.0.12/src/userdel.c	2005-09-13 15:52:49.000000000 +0200
@@ -781,6 +781,8 @@
 
 	user_cancel (user_name);
 	close_files ();
+
+	hup_nscd ();
 #ifdef USE_PAM
 	if (retval == PAM_SUCCESS) {
 		retval = pam_chauthtok (pamh, 0);
--- shadow-4.0.12/src/gpasswd.c.nscd	2005-08-09 18:40:07.000000000 +0200
+++ shadow-4.0.12/src/gpasswd.c	2005-09-13 16:05:03.000000000 +0200
@@ -617,5 +617,6 @@
 
 	nscd_flush_cache ("group");
 
+        hup_nscd ();
 	exit (E_SUCCESS);
 }
--- shadow-4.0.12/src/newusers.c.nscd	2005-08-11 18:23:34.000000000 +0200
+++ shadow-4.0.12/src/newusers.c	2005-09-13 15:52:49.000000000 +0200
@@ -560,6 +560,7 @@
 	if (is_shadow)
 		spw_unlock ();
 	(void) pw_unlock ();
+        hup_nscd ();
 
 #ifdef USE_PAM
 	if (retval == PAM_SUCCESS) {
--- shadow-4.0.12/src/useradd.c.nscd	2005-09-13 15:52:49.000000000 +0200
+++ shadow-4.0.12/src/useradd.c	2005-09-13 15:52:49.000000000 +0200
@@ -1841,6 +1841,7 @@
 	nscd_flush_cache ("group");
 
 	close_files ();
+        hup_nscd ();
 
 #ifdef USE_PAM
 	if (retval == PAM_SUCCESS) {
--- shadow-4.0.12/src/usermod.c.nscd	2005-08-11 18:23:34.000000000 +0200
+++ shadow-4.0.12/src/usermod.c	2005-09-13 15:52:49.000000000 +0200
@@ -1260,6 +1260,7 @@
 	if (pampw == NULL) {
 		retval = PAM_USER_UNKNOWN;
 	}
+        hup_nscd();
 
 	if (retval == PAM_SUCCESS) {
 		retval = pam_start ("usermod", pampw->pw_name, &conv, &pamh);
--- shadow-4.0.12/src/groupadd.c.nscd	2005-09-13 15:52:49.000000000 +0200
+++ shadow-4.0.12/src/groupadd.c	2005-09-13 15:52:49.000000000 +0200
@@ -550,6 +550,8 @@
 	nscd_flush_cache ("group");
 
 	close_files ();
+        
+	hup_nscd ();
 
 #ifdef USE_PAM
 	if (retval == PAM_SUCCESS) {