]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Use anonymous file and directory names
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Sun, 24 Apr 2011 07:43:51 +0000 (07:43 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Sun, 24 Apr 2011 07:43:51 +0000 (07:43 +0000)
The files and directories are named after the user whose report is
about. Therefore, even if the administrator tries to hide the user's
identity with a useratb file, the real identity is still visible in the
URL.

To solve this problem, option anonymous_output_files was added to
sarg.conf. When it is on, each user's file is named using a unique
number that can't be traced back to the real user.

This patch also allows to shorten the URL of the report.

Thanks to dbmaxpayne for suggesting this feature.

CMakeLists.txt
ChangeLog
getconf.c
include/conf.h
include/info.h
log.c
sarg.conf
userinfo.c

index 8b2cc7c5b07191ecb7624c4680fd64b1a742a2e1..8ab0964eb0a089ea87b86207ae8b9afbcea653aa 100755 (executable)
@@ -3,7 +3,7 @@ PROJECT(sarg C)
 SET(sarg_VERSION 2)
 SET(sarg_REVISION "3.2-pre1")
 SET(sarg_BUILD "")
-SET(sarg_BUILDDATE "Feb-02-2011")
+SET(sarg_BUILDDATE "Apr-24-2011")
 
 INCLUDE(AddFileDependencies)
 INCLUDE(CheckIncludeFile)
index 1fc79bc277ba64aaecbebdc440e7f9d0abec9b31..bf1c37d8e32102b4b29041a7b752e20de45cc927 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,6 @@
 SARG ChangeLog
 
-Jan-25-2011 Version 2.3.2-pre1
+Apr-24-2011 Version 2.3.2-pre1
                - Add support for sorttable.js (http://www.kryogenix.org/code/browser/sorttable/) to dynamically sort some tables (thanks to Éric).
                - Add the two command line options --lastlog and --keeplogs to set the number of reports to keep or to keep all the reports respectively (thanks to Emmanuel Lacour for the suggestion).
                - Report the user ID in the e-mail report.
@@ -8,6 +8,11 @@ Jan-25-2011 Version 2.3.2-pre1
                - Delete unused files from the directory containing the user report (thanks to alf-man).
                - Add the index_fields option to hide the directory size column in the index sorted by date.
                - Split the input log file in several files each containing one day worth of data (thanks to Mauricio Silveira).
+               - Take the date_format into account when converting a log file.
+               - Accept IPv6 addresses in the realtime report.
+               - Don't fail for an empty report directory when building the index.
+               - Fix a read error when parsing the time of a common log format.
+               - Use anonymous file and directory names in the report to hide the identity of the user whose report is displayed and shorten the total path length.
 
 Sep-18-2010 Version 2.3.1
                - Remove the distinct printf for the alpha architecture as it doesn't work anymore and is not necessary anyway.
index 3d675bee6fbd463a8ee2b6981fc762bc1b280282..f26cc8072369802dddb19917485c9b85442722a6 100644 (file)
--- a/getconf.c
+++ b/getconf.c
@@ -533,6 +533,8 @@ static void parmtest(char *buf)
 
        if (getparam_string("output_dir",buf,OutputDir,sizeof(OutputDir))>0) return;
 
+       if (getparam_bool("anonymous_output_files",buf,&AnonymousOutputFiles)>0) return;
+
        if (getparam_string("output_email",buf,OutputEmail,sizeof(OutputEmail))>0) return;
 
        if (getparam_2words("per_user_limit",buf,PerUserLimitFile,sizeof(PerUserLimitFile),wbuf,sizeof(wbuf))>0) {
index c486c459df070d08092f4ae1d63488d29c7766ea..3ed4a95d834cc0b0381f8bb4c62aba487dc7208d 100755 (executable)
@@ -390,6 +390,8 @@ unsigned long int IndexTree;
 unsigned long int IndexFields;
 bool UserAuthentication;
 char AuthUserTemplateFile[1024];
+//! \c True to use anonymous file and directory names in the report.
+bool AnonymousOutputFiles;
 char val1[MAXLEN];
 char val2[MAXLEN];
 char val3[MAXLEN];
index 2f77f547b4f203406af3e7d1e22ab90020f33ca5..dfc5b68d9d49be6c96add8dbd4fb2f385fcd8991 100755 (executable)
@@ -1,3 +1,3 @@
-#define VERSION PACKAGE_VERSION" Feb-02-2011"
+#define VERSION PACKAGE_VERSION" Apr-24-2011"
 #define PGM PACKAGE_NAME
 #define URL "http://sarg.sourceforge.net"
diff --git a/log.c b/log.c
index 111d9db9ce8f8040677aac6012014e6f0fc6055d..6d276f9bd06456f6e6e86fcdbf5b68fa357b59ee 100644 (file)
--- a/log.c
+++ b/log.c
@@ -225,6 +225,7 @@ int main(int argc,char *argv[])
        strcpy(FontSize,"9px");
        strcpy(TempDir,"/tmp");
        strcpy(OutputDir,"/var/www/html/squid-reports");
+       AnonymousOutputFiles=false;
        Ip2Name=false;
        strcpy(DateFormat,"u");
        OverwriteReport=false;
index 6d5a7876f660e3f4c8b6e582aa64986ac7188eda..3c29f12ff1175533a1207cabe658e63442ab3ff6 100644 (file)
--- a/sarg.conf
+++ b/sarg.conf
 #
 #output_dir /var/www/html/squid-reports
 
+# TAG:  anonymous_output_files yes/no
+#       Use anonymous file and directory names in the report. If it is set to
+#       no (the default), the user id/ip/name is slightly mangled to create a
+#       suitable file name to store the report of the user but the user's
+#       identity can easily be guessed from the mangled name. If this option is
+#       set, any file or directory belonging to the user is replaced by a short
+#       number.  The purpose is to hide the identity of the user when looking
+#       at the report file names but it may serve to shorten the path too.
+#
+#anonymous_output_files no
+
 # TAG:  output_email
 #       Email address to send the reports. If you use this tag, no html reports will be generated.
 #       sarg -e email
index a217623f174633f59a3e75b211bb2ebbcc6ca5bc..b76ba1fdb119eca815e52010045e3b60bb41d609 100644 (file)
@@ -56,6 +56,8 @@ struct userscanstruct
 
 //! The first group of users.
 static struct usergroupstruct *first_user_group=NULL;
+//! The counter to generate unique user number when ::AnonymousOutputFiles is set.
+static int AnonymousCounter=0;
 
 struct userinfostruct *userinfo_create(const char *userid)
 {
@@ -90,32 +92,36 @@ struct userinfostruct *userinfo_create(const char *userid)
        strncpy(user->id,userid,MAX_USER_LEN-1);
        user->id[MAX_USER_LEN-1]='\0';
 
-       skip=0;
-       j=0;
-       for (i=0 ; userid[i] && j<MAX_USER_FNAME_LEN-1 ; i++) {
-               if (isalnum(userid[i]) || userid[i]=='-' || userid[i]=='_') {
-                       user->filename[j++]=userid[i];
-                       skip=0;
-               } else {
-                       if (!skip) {
-                               user->filename[j++]='_';
-                               skip=1;
+       if (AnonymousOutputFiles) {
+               snprintf(user->filename,sizeof(user->filename),"%d",AnonymousCounter++);
+       } else {
+               skip=0;
+               j=0;
+               for (i=0 ; userid[i] && j<MAX_USER_FNAME_LEN-1 ; i++) {
+                       if (isalnum(userid[i]) || userid[i]=='-' || userid[i]=='_') {
+                               user->filename[j++]=userid[i];
+                               skip=0;
+                       } else {
+                               if (!skip) {
+                                       user->filename[j++]='_';
+                                       skip=1;
+                               }
                        }
                }
-       }
-       user->filename[j]='\0';
-       flen=i;
-
-       count=0;
-       for (group=first_user_group ; group ; group=group->next) {
-               lastuser=(group->next) ? group->nusers : group->nusers-1;
-               for (i=0 ; i<lastuser ; i++) {
-                       if (strcasecmp(user->filename,group->list[i].filename)==0) {
-                               clen=sprintf(cstr,"-%04X",count++);
-                               if (flen+clen<MAX_USER_FNAME_LEN)
-                                       strcpy(user->filename+flen,cstr);
-                               else
-                                       strcpy(user->filename+MAX_USER_FNAME_LEN-clen,cstr);
+               user->filename[j]='\0';
+               flen=i;
+
+               count=0;
+               for (group=first_user_group ; group ; group=group->next) {
+                       lastuser=(group->next) ? group->nusers : group->nusers-1;
+                       for (i=0 ; i<lastuser ; i++) {
+                               if (strcasecmp(user->filename,group->list[i].filename)==0) {
+                                       clen=sprintf(cstr,"-%04X",count++);
+                                       if (flen+clen<MAX_USER_FNAME_LEN)
+                                               strcpy(user->filename+flen,cstr);
+                                       else
+                                               strcpy(user->filename+MAX_USER_FNAME_LEN-clen,cstr);
+                               }
                        }
                }
        }