bug-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

New feature proposal: syslog all pserver commands


From: Thomas Quinot
Subject: New feature proposal: syslog all pserver commands
Date: Fri, 7 Feb 2003 16:27:23 +0100
User-agent: Mutt/1.4i

Dear CVS developers,

As operator of an anonymous CVS pserver, I found myself needing a log
of all actions performed on the server, and came up with the patch
below. I would like to offer it to the community, in the hope that
others will find it useful, and that eventually it gets integrated
in the mainstream CVS sources.

Enjoy,
Thomas.

Index: src/server.c
===================================================================
RCS file: /cvsroot/ccvs/src/server.c,v
retrieving revision 1.285
diff -u -r1.285 server.c
--- src/server.c        3 Feb 2003 17:53:23 -0000       1.285
+++ src/server.c        7 Feb 2003 15:22:43 -0000
@@ -63,6 +63,8 @@
 # ifndef LOG_DAEMON   /* for ancient syslogs */
 #  define LOG_DAEMON 0
 # endif
+#else
+# undef LOG_COMMAND
 #endif
 
 #ifdef HAVE_KERBEROS
@@ -2605,6 +2607,37 @@
 static int flowcontrol_pipe[2];
 #endif /* SERVER_FLOWCONTROL */
 
+#ifdef LOG_COMMAND
+static void
+log_command (cmd_name, argc, argv)
+    char *cmd_name;
+    int  argc;
+    char **argv;
+{
+    int i, len;
+    char *msg;
+
+    if (!argv)
+      return;
+
+    for (len = 0, i = 0; i < argc; i++)
+      len += strlen (argv[i]) + 1;
+
+    if (!(msg = malloc (len)))
+      return;
+
+    *msg = '\0';
+    for (i = 0; i < argc; i++) {
+      if (i > 0)
+        strcat (msg, " ");
+      strcat (msg, argv[i]);
+    }
+
+    syslog (LOG_INFO, "%s: %s", cmd_name, msg);
+    free (msg);
+}
+#endif
+
 static void
 do_cvs_command (cmd_name, command)
     char *cmd_name;
@@ -2629,6 +2662,10 @@
     int dev_null_fd = -1;
 
     int errs;
+
+#ifdef LOG_COMMAND
+    log_command (cmd_name, argument_count, argument_vector);
+#endif
 
     command_pid = -1;
     stdout_pipe[0] = -1;

-- 
    address@hidden




reply via email to

[Prev in Thread] Current Thread [Next in Thread]