From: Frédéric Marchal Date: Sun, 24 Apr 2011 07:43:51 +0000 (+0000) Subject: Use anonymous file and directory names X-Git-Tag: v2.3.2~59 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=829a53c25b456b30bc3db9edecf1240503cadfa1;p=thirdparty%2Fsarg.git Use anonymous file and directory names 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. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b2cc7c..8ab0964 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/ChangeLog b/ChangeLog index 1fc79bc..bf1c37d 100644 --- 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. diff --git a/getconf.c b/getconf.c index 3d675be..f26cc80 100644 --- 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) { diff --git a/include/conf.h b/include/conf.h index c486c45..3ed4a95 100755 --- a/include/conf.h +++ b/include/conf.h @@ -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]; diff --git a/include/info.h b/include/info.h index 2f77f54..dfc5b68 100755 --- a/include/info.h +++ b/include/info.h @@ -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 111d9db..6d276f9 100644 --- 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; diff --git a/sarg.conf b/sarg.conf index 6d5a787..3c29f12 100644 --- a/sarg.conf +++ b/sarg.conf @@ -119,6 +119,17 @@ # #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 diff --git a/userinfo.c b/userinfo.c index a217623..b76ba1f 100644 --- a/userinfo.c +++ b/userinfo.c @@ -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] && jfilename[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] && jfilename[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 ; ifilename,group->list[i].filename)==0) { - clen=sprintf(cstr,"-%04X",count++); - if (flen+clenfilename+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 ; ifilename,group->list[i].filename)==0) { + clen=sprintf(cstr,"-%04X",count++); + if (flen+clenfilename+flen,cstr); + else + strcpy(user->filename+MAX_USER_FNAME_LEN-clen,cstr); + } } } }