]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Strip the user suffix from the redirector log
authorFrederic Marchal <fmarchal@users.sourceforge.net>
Wed, 22 Jul 2015 18:35:23 +0000 (20:35 +0200)
committerFrederic Marchal <fmarchal@users.sourceforge.net>
Wed, 22 Jul 2015 18:35:23 +0000 (20:35 +0200)
User names are also truncated in the suffix is found in the redirector log.

redirector.c

index d52f4ba624555198119048c776914895fc22e358..e7b89e0ab3ebea9d188da458d1699600b1ff8ee1 100644 (file)
@@ -34,6 +34,10 @@ static int nfiles_done = 0;
 static int RedirectorErrors=0;
 //! The file containing the sorted entries.
 static char redirector_sorted[MAXLEN]="";
+//! Length of the suffix to strip from the user name.
+static int StripSuffixLen;
+
+extern char StripUserSuffix[MAX_USER_LEN];
 
 static void parse_log(FILE *fp_ou,char *buf,int dfrom,int duntil)
 {
@@ -186,6 +190,12 @@ static void parse_log(FILE *fp_ou,char *buf,int dfrom,int duntil)
                        return;
        }
 
+       if (StripSuffixLen>0)
+       {
+               int x=strlen(user);
+               if (x>StripSuffixLen && strcasecmp(user+(x-StripSuffixLen),StripUserSuffix)==0)
+                       user[x-StripSuffixLen]='\0';
+       }
        if(UserIp) {
                strcpy(user,ip);
                id_is_ip=true;
@@ -273,6 +283,7 @@ static void read_log(const char *wentp, FILE *fp_ou,int dfrom,int duntil)
                debuga(__FILE__,__LINE__,_("Not enough memory to read file \"%s\"\n"),wentp);
                exit(EXIT_FAILURE);
        }
+       StripSuffixLen=strlen(StripUserSuffix);
 
        while ((buf=longline_read(fp_in,line)) != NULL) {
                parse_log(fp_ou,buf,dfrom,duntil);