numlist weekdays = { { 0, 1, 2, 3, 4, 5, 6 }, 7 };
numlist hours = { { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23 }, 24 };
+//! Domain suffix to strip from the user name.
+char StripUserSuffix[MAX_USER_LEN]="";
extern char *userfile;
extern FileListObject AccessLog;
char smartfilter[MAXLEN];
const char *url;
const char *user;
+ const char *UserPtr;
int OutputNonZero = REPORT_EVERY_X_LINES ;
int idata=0;
int x;
int hmr;
int nopen;
+ int StripSuffixLen;
int maxopenfiles=MAX_OPEN_USER_FILES;
unsigned long int recs1=0UL;
unsigned long int recs2=0UL;
recs1=0UL;
recs2=0UL;
+ StripSuffixLen=strlen(StripUserSuffix);
// pre-read the file only if we have to show stats
if (ShowReadStatistics && ShowReadPercent && fp_in->Rewind) {
continue;
}
-
+ if (StripSuffixLen>0)
+ {
+ x=strlen(log_entry.User);
+ if (x>StripSuffixLen && strcasecmp(log_entry.User+(x-StripSuffixLen),StripUserSuffix)==0)
+ log_entry.User[x-StripSuffixLen]='\0';
+ }
if(strlen(log_entry.User) > MAX_USER_LEN) {
if (debugz>=LogLevel_Process) debuga(__FILE__,__LINE__,_("User ID too long: %s\n"),log_entry.User);
excluded_count[ER_UserNameTooLong]++;
}
if(UserIp) {
- log_entry.User=log_entry.Ip;
+ UserPtr=log_entry.Ip;
id_is_ip=true;
} else {
+ UserPtr=log_entry.User;
id_is_ip=false;
- if ((log_entry.User[0]=='\0') || (log_entry.User[1]=='\0' && (log_entry.User[0]=='-' || log_entry.User[0]==' '))) {
+ if ((UserPtr[0]=='\0') || (UserPtr[1]=='\0' && (UserPtr[0]=='-' || UserPtr[0]==' '))) {
if(RecordsWithoutUser == RECORDWITHOUTUSER_IP) {
- log_entry.User=log_entry.Ip;
+ UserPtr=log_entry.Ip;
id_is_ip=true;
}
if(RecordsWithoutUser == RECORDWITHOUTUSER_IGNORE) {
continue;
}
if(RecordsWithoutUser == RECORDWITHOUTUSER_EVERYBODY)
- log_entry.User="everybody";
+ UserPtr="everybody";
} else {
if(NtlmUserFormat == NTLMUSERFORMAT_USER) {
- if ((str=strchr(log_entry.User,'+'))!=NULL || (str=strchr(log_entry.User,'\\'))!=NULL || (str=strchr(log_entry.User,'_'))!=NULL) {
- log_entry.User=str+1;
+ if ((str=strchr(UserPtr,'+'))!=NULL || (str=strchr(UserPtr,'\\'))!=NULL || (str=strchr(UserPtr,'_'))!=NULL) {
+ UserPtr=str+1;
}
}
}
}
if(us[0] != '\0'){
- if(strcmp(log_entry.User,us)!=0) {
+ if(strcmp(UserPtr,us)!=0) {
excluded_count[ER_UntrackedUser]++;
continue;
}
}
if(Filter->SysUsers) {
- snprintf(wuser,sizeof(wuser),":%s:",log_entry.User);
+ snprintf(wuser,sizeof(wuser),":%s:",UserPtr);
if(strstr(userfile, wuser) == 0) {
excluded_count[ER_SysUser]++;
continue;
}
if(Filter->UserFilter) {
- if(!vuexclude(log_entry.User)) {
- if (debugz>=LogLevel_Process) debuga(__FILE__,__LINE__,_("Excluded user: %s\n"),log_entry.User);
+ if(!vuexclude(UserPtr)) {
+ if (debugz>=LogLevel_Process) debuga(__FILE__,__LINE__,_("Excluded user: %s\n"),UserPtr);
excluded_count[ER_IgnoredUser]++;
totregsx++;
continue;
}
}
- user=process_user(log_entry.User);
- if (log_entry.User!=user) {
- log_entry.User=user;
+ user=process_user(UserPtr);
+ if (UserPtr!=user)
+ {
+ UserPtr=user;
id_is_ip=false;
}
- if (log_entry.User[0]=='\0' || (log_entry.User[1]=='\0' && (log_entry.User[0]=='-' ||
- log_entry.User[0]==' ' || log_entry.User[0]==':'))) {
+ if (UserPtr[0]=='\0' || (UserPtr[1]=='\0' && (UserPtr[0]=='-' || UserPtr[0]==' ' || UserPtr[0]==':'))) {
excluded_count[ER_NoUser]++;
continue;
}
nopen=0;
prev_ufile=NULL;
- for (ufile=first_user_file ; ufile && strcmp(log_entry.User,ufile->user->id)!=0 ; ufile=ufile->next) {
+ for (ufile=first_user_file ; ufile && strcmp(UserPtr,ufile->user->id)!=0 ; ufile=ufile->next) {
prev_ufile=ufile;
if (ufile->file) nopen++;
}
if (!ufile) {
ufile=malloc(sizeof(*ufile));
if (!ufile) {
- debuga(__FILE__,__LINE__,_("Not enough memory to store the user %s\n"),log_entry.User);
+ debuga(__FILE__,__LINE__,_("Not enough memory to store the user %s\n"),UserPtr);
exit(EXIT_FAILURE);
}
memset(ufile,0,sizeof(*ufile));
* This id_is_ip stuff is just to store the string only once if the user is
* identified by its IP address instead of a distinct ID and IP address.
*/
- uinfo=userinfo_create(log_entry.User,(id_is_ip) ? NULL : log_entry.Ip);
+ uinfo=userinfo_create(UserPtr,(id_is_ip) ? NULL : log_entry.Ip);
ufile->user=uinfo;
nusers++;
} else {
if (fprintf(ufile->file, "%s\t%s\t%s\t%s\t%"PRIu64"\t%s\t%ld\t%s\n",dia,hora,
log_entry.Ip,url,(uint64_t)log_entry.DataSize,
log_entry.HttpCode,log_entry.ElapsedTime,smartfilter)<=0) {
- debuga(__FILE__,__LINE__,_("Write error in the log file of user %s\n"),log_entry.User);
+ debuga(__FILE__,__LINE__,_("Write error in the log file of user %s\n"),UserPtr);
exit(EXIT_FAILURE);
}
records_kept++;
if (fp_log && log_line.current_format!=&ReadSargLog) {
fprintf(fp_log, "%s\t%s\t%s\t%s\t%s\t%"PRIu64"\t%s\t%ld\t%s\n",dia,hora,
- log_entry.User,log_entry.Ip,url,(uint64_t)log_entry.DataSize,
+ UserPtr,log_entry.Ip,url,(uint64_t)log_entry.DataSize,
log_entry.HttpCode,log_entry.ElapsedTime,smartfilter);
}
if (debugz>=LogLevel_Data){
printf("IP=\t%s\n",log_entry.Ip);
- printf("USER=\t%s\n",log_entry.User);
+ printf("USER=\t%s\n",UserPtr);
printf("ELAP=\t%ld\n",log_entry.ElapsedTime);
printf("DATE=\t%s\n",dia);
printf("TIME=\t%s\n",hora);