From: Frederic Marchal Date: Wed, 22 Jul 2015 18:35:23 +0000 (+0200) Subject: Strip the user suffix from the redirector log X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=c6b23f2ea01504ca5d39e36b58969830db844e2a;p=thirdparty%2Fsarg.git Strip the user suffix from the redirector log User names are also truncated in the suffix is found in the redirector log. --- diff --git a/redirector.c b/redirector.c index d52f4ba..e7b89e0 100644 --- a/redirector.c +++ b/redirector.c @@ -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);