bug-cvs
[Top][All Lists]
Advanced

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

New feature: syslog all pserver commands


From: Thomas Quinot
Subject: New feature: syslog all pserver commands
Date: Wed, 16 Jun 2004 12:23:50 +0200
User-agent: Mutt/1.5.6i

I sent the following proposal in early 2003, but never got any feedback,
so I am resubmitting it:

« 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. »

This updated patch applies to cvs 1.12.9.

Thomas.

diff -ur cvs-1.12.9/src/server.c cvs-1.12.9.patch/src/server.c
--- cvs-1.12.9/src/server.c     Wed Jun  9 16:52:39 2004
+++ cvs-1.12.9.patch/src/server.c       Wed Jun 16 12:22:23 2004
@@ -8,6 +8,7 @@
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.  */
 
+#include <syslog.h>
 #include "cvs.h"
 #include "watch.h"
 #include "edit.h"
@@ -2681,6 +2682,43 @@
 }
 
 
+  
+static void
+log_command (cmd_name, argc, argv)
+    char *cmd_name;
+    int  argc;
+    char **argv;
+{
+    static int log_opened = 0;
+    int i, len;
+    char *msg;
+
+    if (!argv)
+      return;
+
+    if (!log_opened) {
+      openlog ("cvspservd", LOG_PID, LOG_AUTHPRIV);
+      log_opened = 1;
+    }
+
+    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, "[%u] %s: %s", getppid (), cmd_name, msg);
+    free (msg);
+}
+
+
 
 static void
 do_cvs_command (char *cmd_name, int (*command) (int, char **))
@@ -2704,6 +2742,8 @@
     int dev_null_fd = -1;
 
     int errs;
+
+    log_command (cmd_name, argument_count, argument_vector);
 
     TRACE (TRACE_FUNCTION, "do_cvs_command (%s)", cmd_name);
 
-- 
    Thomas.Quinot@Cuivre.FR.EU.ORG




reply via email to

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