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

Bug#486285: didiwiki: Didiwiki does not provide an access log [patch]



To obtain a simple access log in didiwiki 0.5-6 you could try to apply this patch to use syslogd.
For example:

$ cat /etc/rsyslog.d/didiwiki.conf
local0.*    /var/log/didiwiki.log

$ tail /var/log/didiwiki.log
Jul 12 15:54:22 hostname didiwiki: started with PID 9429
Jul 12 15:54:52 hostname didiwiki: page WikiHelp viewed from 127.0.0.1
Jul 12 15:54:58 hostname didiwiki: page WikiHelp modified from 127.0.0.1
Jul 12 15:54:58 hostname didiwiki: page WikiHelp viewed from 127.0.0.1
Jul 12 15:59:35 hostname didiwiki: page WikiHome viewed from 192.168.100.128
Jul 12 15:59:38 hostname didiwiki: page WikiHome modified from 192.168.100.128
Jul 12 15:59:38 hostname didiwiki: page WikiHome viewed from 192.168.100.128

Carlo

--- didi.h.orig	2009-07-14 10:01:57.000000000 +0200
+++ didi.h	2009-07-14 10:02:32.000000000 +0200
@@ -76,6 +76,7 @@
 #include <sys/stat.h>
 #include <dirent.h>
 #include <getopt.h>
+#include <syslog.h>
 
 #endif
 
--- http.h.orig	2009-07-14 16:02:12.000000000 +0200
+++ http.h	2009-07-14 15:44:27.000000000 +0200
@@ -23,6 +23,8 @@
 char*
 http_request_get_query_string(HttpRequest *req);
 
+char*
+http_request_get_ip_src(HttpRequest *req);
 
 HttpResponse*
 http_response_new(HttpRequest *req);
--- http.c.orig	2009-07-14 16:02:00.000000000 +0200
+++ http.c	2009-07-14 15:32:28.000000000 +0200
@@ -30,6 +30,7 @@
   char             *uri;
   char             *path_info;
   char             *query_string;
+  char             *ip_src;
 };
 
 struct HttpResponse 
@@ -170,6 +171,12 @@
   return req->query_string;
 }
 
+char*
+http_request_get_ip_src(HttpRequest *req)
+{
+  return req->ip_src;
+}
+
 
 /*
  * This routine handles a single HTTP request which is coming in on
@@ -226,7 +233,10 @@
     req->query_string = strdup(&token[i]);
 
   if( getpeername(fileno(stdin), (struct sockaddr*)&remoteName, &size) >=0 )
+    {
     putenv(util_mprintf("REMOTE_ADDR=%s", inet_ntoa(remoteName.sin_addr)));
+    req->ip_src = inet_ntoa(remoteName.sin_addr);
+    }
 
   /* Get all the optional fields that follow the first line.
   */
@@ -488,6 +498,9 @@
   fprintf(stderr,"Success! \n");
   
   fprintf(stderr,"DidiWiki Started. Please point your browser at http://localhost:%i\n";, iPort);
+
+  openlog("didiwiki", 0, 0);
+  syslog(LOG_LOCAL0|LOG_INFO, "started with PID %d", getpid());
   
   listen(listener,10);
   
--- wiki.c.orig	2009-07-14 10:03:57.000000000 +0200
+++ wiki.c	2009-07-14 16:20:26.000000000 +0200
@@ -1002,11 +1002,13 @@
       if ( (wikitext = http_request_param_get(req, "wikitext")) != NULL)
 	{
 	  file_write(page, wikitext);	      
+	  syslog(LOG_LOCAL0|LOG_INFO, "page %s modified from %s", page ,http_request_get_ip_src(req));
 	}
 
       if (access(page, R_OK) == 0) 	/* page exists */
 	{
 	  wikitext = file_read(page);
+          syslog(LOG_LOCAL0|LOG_INFO, "page %s viewed from %s", page, http_request_get_ip_src(req));
 	  
 	  if (!strcmp(command, "edit"))
 	    {

Reply to: