summaryrefslogtreecommitdiff
path: root/nscd
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2004-09-22 21:21:10 +0000
committerRoland McGrath <roland@gnu.org>2004-09-22 21:21:10 +0000
commitb5707b44d25d7af61b0338c2a2206c036eaf7337 (patch)
treed8b9e865cbc78d64835a63959370865a2a043223 /nscd
parent4ff389feb39f2eb649530b843d478c80c27ab4cf (diff)
Changes and additions migrated from cvs.devel.redhat.com:/cvs/devel/glibc to fedora-branch
Diffstat (limited to 'nscd')
-rw-r--r--nscd/Makefile47
-rw-r--r--nscd/connections.c16
-rw-r--r--nscd/nscd.c8
-rw-r--r--nscd/nscd.conf4
-rw-r--r--nscd/nscd_conf.c5
5 files changed, 55 insertions, 25 deletions
diff --git a/nscd/Makefile b/nscd/Makefile
index d24bf9c2a6..8ae0e3f939 100644
--- a/nscd/Makefile
+++ b/nscd/Makefile
@@ -67,29 +67,34 @@ CFLAGS-nscd_getpw_r.c = -fexceptions
CFLAGS-nscd_getgr_r.c = -fexceptions
CFLAGS-nscd_gethst_r.c = -fexceptions
+nscd-cflags = -DIS_IN_nscd=1
ifeq (yesyes,$(have-fpie)$(build-shared))
-CFLAGS-nscd.c = -fpie
-CFLAGS-connections.c = -fpie
-CFLAGS-pwdcache.c = -fpie
-CFLAGS-getpwnam_r.c = -fpie
-CFLAGS-getpwuid_r.c = -fpie
-CFLAGS-grpcache.c = -fpie
-CFLAGS-getgrnam_r.c = -fpie
-CFLAGS-getgrgid_r.c = -fpie
-CFLAGS-hstcache.c = -fpie
-CFLAGS-gethstbyad_r.c = -fpie
-CFLAGS-gethstbynm2_r.c = -fpie
-CFLAGS-dbg_log.c = -fpie
-CFLAGS-nscd_conf.c = -fpie
-CFLAGS-nscd_stat.c = -fpie
-CFLAGS-cache.c = -fpie
-CFLAGS-xmalloc.c = -fpie
-CFLAGS-xstrdup.c = -fpie
-CFLAGS-mem.c = -fpie
-CFLAGS-nscd_setup_thread.c = -fpie
-CFLAGS-aicache.c = -fpie
-CFLAGS-selinux.c = -fpie
+nscd-cflags += -fpie
+endif
+
+CFLAGS-nscd.c = $(nscd-cflags)
+CFLAGS-connections.c = $(nscd-cflags)
+CFLAGS-pwdcache.c = $(nscd-cflags)
+CFLAGS-getpwnam_r.c = $(nscd-cflags)
+CFLAGS-getpwuid_r.c = $(nscd-cflags)
+CFLAGS-grpcache.c = $(nscd-cflags)
+CFLAGS-getgrnam_r.c = $(nscd-cflags)
+CFLAGS-getgrgid_r.c = $(nscd-cflags)
+CFLAGS-hstcache.c = $(nscd-cflags)
+CFLAGS-gethstbyad_r.c = $(nscd-cflags)
+CFLAGS-gethstbynm2_r.c = $(nscd-cflags)
+CFLAGS-dbg_log.c = $(nscd-cflags)
+CFLAGS-nscd_conf.c = $(nscd-cflags)
+CFLAGS-nscd_stat.c = $(nscd-cflags)
+CFLAGS-cache.c = $(nscd-cflags)
+CFLAGS-xmalloc.c = $(nscd-cflags)
+CFLAGS-xstrdup.c = $(nscd-cflags)
+CFLAGS-mem.c = $(nscd-cflags)
+CFLAGS-nscd_setup_thread.c = $(nscd-cflags)
+CFLAGS-aicache.c = $(nscd-cflags)
+CFLAGS-selinux.c = $(nscd-cflags)
+ifeq (yesyes,$(have-fpie)$(build-shared))
$(objpfx)nscd: $(addprefix $(objpfx),$(nscd-modules:=.o))
$(LINK.o) -pie -Wl,-O1 \
$(sysdep-LDFLAGS) $(config-LDFLAGS) \
diff --git a/nscd/connections.c b/nscd/connections.c
index 164fdfbc84..fe65b661d7 100644
--- a/nscd/connections.c
+++ b/nscd/connections.c
@@ -984,7 +984,6 @@ start_threads (void)
nscd_run ((void *) 0);
}
-
/* Look up the uid, gid, and supplementary groups to run nscd as. When
this function is called, we are not listening on the nscd socket yet so
we can just use the ordinary lookup functions without causing a lockup */
@@ -1046,3 +1045,18 @@ finish_drop_privileges (void)
exit (1);
}
}
+
+/* Handle the HUP signal which will force a dump of the cache */
+void
+sighup_handler (int signum)
+{
+ /* Prune the password database */
+ prune_cache (&dbs[pwddb], LONG_MAX);
+
+ /* Prune the group database */
+ prune_cache (&dbs[grpdb], LONG_MAX);
+
+ /* Prune the host database */
+ prune_cache (&dbs[hstdb], LONG_MAX);
+}
+
diff --git a/nscd/nscd.c b/nscd/nscd.c
index 4586cf04c9..7f8f58fde6 100644
--- a/nscd/nscd.c
+++ b/nscd/nscd.c
@@ -115,9 +115,16 @@ static struct argp argp =
options, parse_opt, NULL, doc,
};
+/* The SIGHUP handler is extern to this file */
+extern void sighup_handler(int signum);
+
/* True if only statistics are requested. */
static bool get_stats;
+#ifdef atomic_init_nscd
+atomic_init_nscd
+#endif
+
int
main (int argc, char **argv)
{
@@ -256,6 +263,7 @@ main (int argc, char **argv)
signal (SIGINT, termination_handler);
signal (SIGQUIT, termination_handler);
signal (SIGTERM, termination_handler);
+ signal (SIGHUP, sighup_handler);
signal (SIGPIPE, SIG_IGN);
/* Cleanup files created by a previous 'bind'. */
diff --git a/nscd/nscd.conf b/nscd/nscd.conf
index f972851116..0560beba0d 100644
--- a/nscd/nscd.conf
+++ b/nscd/nscd.conf
@@ -27,8 +27,8 @@
# logfile /var/log/nscd.log
# threads 6
-# server-user nobody
-# stat-user somebody
+ server-user nscd
+# stat-user nocpulse
debug-level 0
# reload-count 5
diff --git a/nscd/nscd_conf.c b/nscd/nscd_conf.c
index 2e6f8127a7..8a312ff459 100644
--- a/nscd/nscd_conf.c
+++ b/nscd/nscd_conf.c
@@ -224,7 +224,10 @@ nscd_parse_file (const char *fname, struct database_dyn dbs[lastdb])
if (strcmp (arg2, "no") == 0)
dbs[cnt].shared = 0;
else if (strcmp (arg2, "yes") == 0)
- dbs[cnt].shared = 1;
+#ifndef atomic_supports_shared
+#define atomic_supports_shared 1
+#endif
+ dbs[cnt].shared = atomic_supports_shared;
break;
}
if (cnt == lastdb)