From 294cb3d71be49fc71bd77ac9627924eabf18e172 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Marchal?= Date: Mon, 7 Sep 2009 13:13:51 +0000 Subject: [PATCH] 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. --- log.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) 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); -- 2.47.2