From: Frédéric Marchal Date: Mon, 7 Sep 2009 13:13:51 +0000 (+0000) Subject: Don't reopen the denied.log and authfail.log when parsing a new access.log file as... X-Git-Tag: v2_2_6~32 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=294cb3d71be49fc71bd77ac9627924eabf18e172;p=thirdparty%2Fsarg.git Don't reopen the denied.log and authfail.log when parsing a new access.log file as that truncates the two files and produces empty results. --- diff --git a/log.c b/log.c index 1d489dc..3092133 100644 --- a/log.c +++ b/log.c @@ -677,6 +677,22 @@ int main(int argc,char *argv[]) sprintf ( sz_Download_Unsort , "%s/sarg/download.unsort", tmp); bool_ShowReadStatistics = ( strcmp(ShowReadStatistics,"yes") == 0 ) ; + if(strstr(ReportType,"denied") != 0) { + if((fp_denied=MY_FOPEN(tmp4,"w"))==NULL) { + fprintf(stderr, "%s: (log) %s: %s - %s\n",argv[0],text[45],tmp4,strerror(errno)); + exit(1); + } + } + + if(DataFile[0]=='\0') { + if(strstr(ReportType,"denied") != 0 || strstr(ReportType,"auth_failures") != 0) { + if((fp_authfail=MY_FOPEN(tmp6,"w"))==NULL) { + fprintf(stderr, "%s: (log) %s: %s - %s\n",argv[0],text[45],tmp6,strerror(errno)); + exit(1); + } + } + } + while(narq--) { strcpy(arq,warq[iarq]); iarq++; @@ -716,22 +732,6 @@ int main(int argc,char *argv[]) fputs("*** SARG Log ***\n",fp_log); } - if(strstr(ReportType,"denied") != 0) { - if((fp_denied=MY_FOPEN(tmp4,"w"))==NULL) { - fprintf(stderr, "%s: (log) %s: %s - %s\n",argv[0],text[45],tmp4,strerror(errno)); - exit(1); - } - } - - if(DataFile[0]=='\0') { - if(strstr(ReportType,"denied") != 0 || strstr(ReportType,"auth_failures") != 0) { - if((fp_authfail=MY_FOPEN(tmp6,"w"))==NULL) { - fprintf(stderr, "%s: (log) %s: %s - %s\n",argv[0],text[45],tmp6,strerror(errno)); - exit(1); - } - } - } - // pre-Read the file only if I have to show stats if(bool_ShowReadStatistics) { rewind(fp_in);