summary refs log tree commit diff
path: root/nscd/nscd.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2003-05-04 07:00:44 +0000
committerUlrich Drepper <drepper@redhat.com>2003-05-04 07:00:44 +0000
commita12ce44f6992d8249f779e95db730a9634571654 (patch)
tree27b9bac188927e65f23574bc15258aeac868ddff /nscd/nscd.c
parentf866314b89d56845f55e6f365e18b31ec978ec3a (diff)
downloadglibc-a12ce44f6992d8249f779e95db730a9634571654.tar.gz
glibc-a12ce44f6992d8249f779e95db730a9634571654.tar.xz
glibc-a12ce44f6992d8249f779e95db730a9634571654.zip
Update.
2003-05-03  Ulrich Drepper  <drepper@redhat.com>

	* nscd/nscd.c (main): Parse config file right after parsing
	parameters.  Then, if get_stats is true, call receive_print_stats.
	Drop parameter from nscd_init call.
	(get_stats): New variable.
	(parse_opt): Set get_stats, don't call receive_print_stats here.
	* nscd/nscd.h: Declare dbs, stat_user, and stat_uid.  Adjust nscd_init
	prototype.
	* nscd/connections.c (stat_user, stat_uid): New variables.
	(dbs): Make global.
	(nscd_init): Don't read configuration file here.  Drop parameter.
	(handle_request): Cleanup handling of non-database lookup requests.
	* nscd/nscd_conf.c (nscd_parse_file): Recognize stat-user entry.
	Get UID of the specified user.  Use xstrdup instead of strdup.
	* nscd/nscd_stat.c (receive_print_stats): Check UID.  If not zero,
	check stat_user.
	* nscd/Makefile (nscd-modules): Add xstrdup.
	* nscd/nscd.conf: Document stat-user entry.

2003-05-03  H.J. Lu  <hongjiu.lu@intel.com>

	* sysdeps/unix/sysv/linux/ia64/sysdep.h (__NR_semtimedop): Define
	if not defined.
Diffstat (limited to 'nscd/nscd.c')
-rw-r--r--nscd/nscd.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/nscd/nscd.c b/nscd/nscd.c
index 3d55741df1..69cfa90ab5 100644
--- a/nscd/nscd.c
+++ b/nscd/nscd.c
@@ -30,6 +30,7 @@
 #include <paths.h>
 #include <pthread.h>
 #include <signal.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -109,6 +110,9 @@ static struct argp argp =
   options, parse_opt, NULL, doc,
 };
 
+/* True if only statistics are requested.  */
+static bool get_stats;
+
 int
 main (int argc, char **argv)
 {
@@ -129,6 +133,20 @@ main (int argc, char **argv)
       exit (EXIT_FAILURE);
     }
 
+  /* Read the configuration file.  */
+  if (nscd_parse_file (conffile, dbs) != 0)
+    {
+      /* We couldn't read the configuration file.  We don't start the
+	 server.  */
+      dbg_log (_("cannot read configuration file; this is fatal"));
+      exit (1);
+    }
+
+  /* Do we only get statistics?  */
+  if (get_stats)
+    /* Does not return.  */
+    receive_print_stats ();
+
   /* Check if we are already running. */
   if (check_pid (_PATH_NSCDPID))
     error (EXIT_FAILURE, 0, _("already running"));
@@ -223,7 +241,7 @@ main (int argc, char **argv)
   __nss_disable_nscd ();
 
   /* Init databases.  */
-  nscd_init (conffile);
+  nscd_init ();
 
   /* Handle incoming requests */
   start_threads ();
@@ -268,10 +286,8 @@ parse_opt (int key, char *arg, struct argp_state *state)
       }
 
     case 'g':
-      if (getuid () != 0)
-	error (EXIT_FAILURE, 0, _("Only root is allowed to use this option!"));
-      receive_print_stats ();
-      /* Does not return.  */
+      get_stats = true;
+      break;
 
     case 'i':
       if (getuid () != 0)