about summary refs log tree commit diff
path: root/nscd/nscd_stat.c
diff options
context:
space:
mode:
Diffstat (limited to 'nscd/nscd_stat.c')
-rw-r--r--nscd/nscd_stat.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/nscd/nscd_stat.c b/nscd/nscd_stat.c
index 7cfde982f6..f04e1972b5 100644
--- a/nscd/nscd_stat.c
+++ b/nscd/nscd_stat.c
@@ -114,6 +114,24 @@ receive_print_stats (void)
   ssize_t nbytes;
   int fd;
   int i;
+  uid_t uid = getuid ();
+
+  /* Find out whether there is another user but root allowed to
+     request statistics.  */
+  if (uid != 0)
+    {
+      /* User specified?  */
+      if(stat_user == NULL || stat_uid != uid)
+	{
+	  if (stat_user != NULL)
+	    error (EXIT_FAILURE, 0,
+		   _("Only root or %s is allowed to use this option!"),
+		   stat_user);
+	  else
+	    error (EXIT_FAILURE, 0,
+		   _("Only root is allowed to use this option!"));
+	}
+    }
 
   /* Open a socket to the running nscd.  */
   fd = nscd_open_socket ();