about summary refs log tree commit diff
path: root/nscd/nscd.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1999-09-27 00:22:04 +0000
committerUlrich Drepper <drepper@redhat.com>1999-09-27 00:22:04 +0000
commit756409c4cffe5a4ad6ef965c7cf14eecc3bf5760 (patch)
tree1bbd17925a97ce9935231b2b3e034418d27dfad3 /nscd/nscd.c
parent6e42b0f1ac30da9806b6917378bf19335328096d (diff)
downloadglibc-756409c4cffe5a4ad6ef965c7cf14eecc3bf5760.tar.gz
glibc-756409c4cffe5a4ad6ef965c7cf14eecc3bf5760.tar.xz
glibc-756409c4cffe5a4ad6ef965c7cf14eecc3bf5760.zip
Update.
1999-09-26  Thorsten Kukuk  <kukuk@suse.de>

	* nscd/connections.c: Invalidate caches on request.
	* nscd/nscd-client.h: Add INVALIDATE to request_type.
	* nscd/nscd.c: Add invalidate cache option.
	* nscd/nscd.conf: Change log directory to /var/log (FHS).
Diffstat (limited to 'nscd/nscd.c')
-rw-r--r--nscd/nscd.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/nscd/nscd.c b/nscd/nscd.c
index 8c61406d2f..c4187f13bc 100644
--- a/nscd/nscd.c
+++ b/nscd/nscd.c
@@ -84,6 +84,8 @@ static const struct argp_option options[] =
   { "nthreads", 't', N_("NUMBER"), 0, N_("Start NUMBER threads") },
   { "shutdown", 'K', NULL, 0, N_("Shut the server down") },
   { "statistic", 'g', NULL, 0, N_("Print current configuration statistic") },
+  { "invalidate", 'i', N_("TABLE"), 0,
+    N_("Invalidate the specified cache") },
   { "secure", 'S', N_("TABLE,yes"), 0, N_("Use separate cache for each user")},
   { NULL, 0, NULL, 0, NULL }
 };
@@ -210,6 +212,44 @@ parse_opt (int key, char *arg, struct argp_state *state)
       receive_print_stats ();
       /* Does not return.  */
 
+    case 'i':
+      if (getuid () != 0)
+	error (EXIT_FAILURE, 0, _("Only root is allowed to use this option!"));
+      else
+	{
+	  int sock = nscd_open_socket ();
+	  request_header req;
+	  ssize_t nbytes;
+
+	  if (sock == -1)
+	    exit (EXIT_FAILURE);
+
+	  if (strcmp (arg, "passwd") == 0)
+	    req.key_len = sizeof "passwd";
+	  else if (strcmp (arg, "group") == 0)
+	    req.key_len = sizeof "group";
+	  else if (strcmp (arg, "hosts") == 0)
+	    req.key_len = sizeof "hosts";
+	  else
+	    return ARGP_ERR_UNKNOWN;
+
+	  req.version = NSCD_VERSION;
+	  req.type = INVALIDATE;
+	  nbytes = TEMP_FAILURE_RETRY (write (sock, &req,
+					      sizeof (request_header)));
+	  if (nbytes != sizeof (request_header))
+	    {
+	      close (sock);
+	      exit (EXIT_FAILURE);
+	    }
+
+	  nbytes = TEMP_FAILURE_RETRY (write (sock, (void *)arg, req.key_len));
+
+	  close (sock);
+
+	  exit (nbytes != req.key_len ? EXIT_FAILURE : EXIT_SUCCESS);
+	}
+
     case 't':
       nthreads = atol (arg);
       break;