]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Output only two sets of messages when fclose fails
authorFrederic Marchal <fmarchal@users.sourceforge.net>
Sat, 25 Apr 2015 19:29:28 +0000 (21:29 +0200)
committerFrederic Marchal <fmarchal@users.sourceforge.net>
Sat, 25 Apr 2015 19:29:28 +0000 (21:29 +0200)
One message is for write errors and the other is for read errors. Read
errors were mostly not detected before this change.

29 files changed:
auth.c
authfail.c
convlog.c
dansguardian_log.c
dansguardian_report.c
datafile.c
denied.c
download.c
email.c
exclude.c
getconf.c
grepday.c
html.c
index.c
log.c
readlog.c
realtime.c
redirector.c
repday.c
report.c
siteuser.c
splitlog.c
topsites.c
topuser.c
url.c
useragent.c
userinfo.c
usertab.c
util.c

diff --git a/auth.c b/auth.c
index bf54d619f3eab7c4b5a7feaf753a6adeb814c6da..ed043b5c6862e257da916b9aec8575da91c53a81 100644 (file)
--- a/auth.c
+++ b/auth.c
@@ -66,7 +66,10 @@ void htaccess(const struct userinfostruct *uinfo)
                debuga(_("Write error in \"%s\": %s\n"),htname,strerror(errno));
                exit(EXIT_FAILURE);
        }
-       fclose(fp_in);
+       if (fclose(fp_in)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),AuthUserTemplateFile,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
 
        return;
 }
index 1214d09b0eefea59edcd1c63e5e9faa1d7e2c1e6..467fd42be75b4d3a35882f480df6efa8a6bdc155 100644 (file)
@@ -264,7 +264,10 @@ void authfail_report(void)
                output_html_link(fp_ou,url,100);
                fputs("</td></th>\n",fp_ou);
        }
-       fclose(fp_in);
+       if (fclose(fp_in)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),authfail_sort,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
        longline_destroy(&line);
 
        if(count>AuthfailReportLimit && AuthfailReportLimit>0)
index 9c60515343538443c52c1e686c5f7fab0e1aa890..170b9f414bc56d9ee26deeada22f41fc260ca8e8 100644 (file)
--- a/convlog.c
+++ b/convlog.c
@@ -79,7 +79,7 @@ void convlog(const char *arq, char df, int dfrom, int duntil)
 
        longline_destroy(&line);
        if (fclose(fp_in)==EOF) {
-               debuga(_("Failed to close file \"%s\": %s\n"),arq,strerror(errno));
+               debuga(_("Read error in \"%s\": %s\n"),arq,strerror(errno));
                exit(EXIT_FAILURE);
        }
 }
index 399e684fa45d9cd9d3399058fd3f1052bd8d0eb4..54dff8cb2f65dc3a6c9ae52ba15187280c0c2d66 100644 (file)
@@ -82,6 +82,10 @@ void dansguardian_log(void)
                        break;
                }
        }
+       if (fclose(fp_guard)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),DansGuardianConf,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
 
        if(debug)
                debuga(_("Reading DansGuardian log file: %s\n"),loglocation);
@@ -140,8 +144,10 @@ void dansguardian_log(void)
                dansguardian_count++;
        }
 
-       if(fp_in) fclose(fp_in);
-       if(fp_guard) fclose(fp_guard);
+       if (fclose(fp_in)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),loglocation,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
        if (fclose(fp_ou)==EOF) {
                debuga(_("Write error in \"%s\": %s\n"),guard_in,strerror(errno));
                exit(EXIT_FAILURE);
index 57e032998468f49802fcc1ce6962f6a458a33e6f..f76878207fbddb8363616b479b2ef1fe0a09bfb0 100644 (file)
@@ -159,7 +159,10 @@ void dansguardian_report(void)
                output_html_link(fp_ou,url,100);
                fprintf(fp_ou,"</td><td class=\"data2\">%s</td></tr>\n",rule);
        }
-       fclose(fp_in);
+       if (fclose(fp_in)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),dansguardian_in,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
 
        if(count>DansGuardianReportLimit && DansGuardianReportLimit>0)
                show_ignored_dansguardian(fp_ou,count-DansGuardianReportLimit);
index 1a62f6bf419c4bf2f7c26192c3d2af9676dfec39..c8489c7083a0a9b5a79d0783cec465bd0c5f7682 100644 (file)
@@ -190,7 +190,10 @@ void data_file(char *tmp)
                        strcpy(oldacchora,acchora);
                }
 
-               fclose(fp_in);
+               if (fclose(fp_in)==EOF) {
+                       debuga(_("Read error in \"%s\": %s\n"),tmp3,strerror(errno));
+                       exit(EXIT_FAILURE);
+               }
                longline_destroy(&line);
        }
        userinfo_stopscan(uscan);
index 532ac6f437ade91ee4d38570c266d95a5bb63e4b..8b621dec72ba3bec250171821c63d36347fd8a73 100644 (file)
--- a/denied.c
+++ b/denied.c
@@ -262,7 +262,10 @@ void gen_denied_report(void)
                output_html_link(fp_ou,url,100);
                fputs("</td></tr>\n",fp_ou);
        }
-       fclose(fp_in);
+       if (fclose(fp_in)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),denied_sort,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
        longline_destroy(&line);
 
        if(count>DeniedReportLimit && DeniedReportLimit>0)
index d464cf309501696d9a71a7d6740059dcd20af1f0..b3ae0c1544d18137b2a5cdc0b34039c6bb061cc7 100644 (file)
@@ -296,7 +296,10 @@ void download_report(void)
                output_html_link(fp_ou,url,100);
                fputs("</td></tr>\n",fp_ou);
        }
-       fclose(fp_in);
+       if (fclose(fp_in)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),report_in,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
        longline_destroy(&line);
 
        fputs("</table></div>\n",fp_ou);
diff --git a/email.c b/email.c
index 5f639c24bd20887327b555c1071531bcf42756df..2055a632f433344a0a7c6e51d9a1d311259ab503 100644 (file)
--- a/email.c
+++ b/email.c
@@ -102,7 +102,10 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
                tnacc+=item.nacc;
                tnelap+=item.nelap;
        }
-       fclose(fp_in);
+       if (fclose(fp_in)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),wger,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
        longline_destroy(&line);
 
        if (olduser[0] != '\0') {
@@ -249,7 +252,10 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
        fprintf(fp_top3,"%-7s %20s %8"PRIu64" %15s %8s %9s %10"PRIu64"\n",strip1," ",(uint64_t)avgacc,fixnum(tnbytes,1)," ",buildtime(avgelap),(uint64_t)avgelap);
 #endif
 
-       fclose(fp_top1);
+       if (fclose(fp_top1)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),top1,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
        if (!KeepTempLog && unlink(top1)) {
                debuga(_("Cannot delete \"%s\": %s\n"),top1,strerror(errno));
                exit(EXIT_FAILURE);
@@ -273,7 +279,7 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
                while(fgets(warea,sizeof(warea),fp_top3)!=NULL)
                        fputs(warea,stdout);
                if (fclose(fp_top3)==EOF) {
-                       debuga(_("Read error in temporary mail file %s: %s\n"),top3,strerror(errno));
+                       debuga(_("Read error in \"%s\": %s\n"),top3,strerror(errno));
                        exit(EXIT_FAILURE);
                }
        } else {
index cebe1911499dce5b2fb31ff0f2c1e51a1ab06b9c..edb2aa22d134331e8b447818f5d9a1592cde48e0 100644 (file)
--- a/exclude.c
+++ b/exclude.c
@@ -224,7 +224,10 @@ void gethexclude(const char *hexfile, int debug)
                }
        }
 
-       fclose(fp_ex);
+       if (fclose(fp_ex)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),hexfile,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
        return;
 }
 
@@ -350,7 +353,10 @@ void getuexclude(const char *uexfile, int debug)
 
        strcat(excludeuser,"*END* ");
 
-       fclose(fp_ex);
+       if (fclose(fp_ex)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),uexfile,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
 
        return;
 }
index 74bdeee4c36fab6a63f592c6468b2b9c9b10fb93..67fdf389f16647463b01ecf831ea4b1875084ff6 100644 (file)
--- a/getconf.c
+++ b/getconf.c
@@ -980,6 +980,9 @@ void getconf(void)
 
        }
 
-       fclose(fp_in);
+       if (fclose(fp_in)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),ConfigFile,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
        return;
 }
index 4d1321e5631606a7b0dafb64de174aa4eef61b7b..5ae9acc8672afcb463652cc517710b7fc94fbce2 100644 (file)
--- a/grepday.c
+++ b/grepday.c
@@ -720,7 +720,10 @@ void greport_day(const struct userinfostruct *uinfo)
                        elappoints[day-1]+=elap;
                }
        }
-       fclose(fp_in);
+       if (fclose(fp_in)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),wdirname,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
 
        if (snprintf(wdirname,sizeof(wdirname),"%s/%s/graph.html",outdirname,uinfo->filename)>=sizeof(wdirname)) {
                debuga(_("User name too long to manufacture file name "));
@@ -763,8 +766,10 @@ void greport_day(const struct userinfostruct *uinfo)
        fputs("</table>\n",fp_ou);
 
        write_html_trailer(fp_ou);
-       if (fclose(fp_ou)==EOF)
+       if (fclose(fp_ou)==EOF) {
                debuga(_("Write error in \"%s\": %s\n"),wdirname,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
 #endif //HAVE_GD
 
        return;
diff --git a/html.c b/html.c
index 9f2371d3ce54202d740fba3efa2aebb29b493f1f..360c2a820ff9c60f531795cba868883ef228a3f8 100644 (file)
--- a/html.c
+++ b/html.c
@@ -98,7 +98,10 @@ void htmlrel(void)
                                                   strerror(errno));
                                        exit(EXIT_FAILURE);
                                }
-                               fclose(fp_usr);
+                               if (fclose(fp_usr)==EOF) {
+                                       debuga(_("Write error in \"%s\": %s\n"),PerUserLimits[i].File,strerror(errno));
+                                       exit(EXIT_FAILURE);
+                               }
                        }
                        break;
 
@@ -423,11 +426,14 @@ void htmlrel(void)
                                }
                                longline_destroy(&line1);
 
-                               fclose(fp_ip);
                                if (fclose(fp_ip2)==EOF) {
                                        debuga(_("Write error in \"%s\": %s\n"),tmp2,strerror(errno));
                                        exit(EXIT_FAILURE);
                                }
+                               if (fclose(fp_ip)==EOF) {
+                                       debuga(_("Read error in \"%s\": %s\n"),arqip,strerror(errno));
+                                       exit(EXIT_FAILURE);
+                               }
 
                                if (snprintf(csort,sizeof(csort),"sort -n -t \"\t\" -T \"%s\" -k 1,1 -k 2,2 -o \"%s\" \"%s\"",tmp,tmp3,tmp2)>=sizeof(csort)) {
                                        debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),tmp2,tmp3);
@@ -497,7 +503,10 @@ void htmlrel(void)
                                        unelap+=userelap;
                                }
 
-                               fclose(fp_ip);
+                               if (fclose(fp_ip)==EOF) {
+                                       debuga(_("Read error in \"%s\": %s\n"),tmp3,strerror(errno));
+                                       exit(EXIT_FAILURE);
+                               }
                                longline_destroy(&line1);
 
                                if (unlink(tmp3)) {
@@ -527,7 +536,10 @@ void htmlrel(void)
                        unelap=0;
                }
 
-               fclose(fp_in);
+               if (fclose(fp_in)==EOF) {
+                       debuga(_("Read error in \"%s\": %s\n"),arqin,strerror(errno));
+                       exit(EXIT_FAILURE);
+               }
                longline_destroy(&line);
 
                if (iprel && arqip[0]) {
@@ -594,7 +606,7 @@ void htmlrel(void)
                                                        break;
                                        }
                                        if (fclose(fp_usr)==EOF) {
-                                               debuga(_("Write error in per user limit file %s: %s\n"),PerUserLimits[i].File,strerror(errno));
+                                               debuga(_("Write error in \"%s\": %s\n"),PerUserLimits[i].File,strerror(errno));
                                                exit(EXIT_FAILURE);
                                        }
                                        user_limit[maskid]|=mask;
diff --git a/index.c b/index.c
index 0e176ca3b85f56a8fe4b494814e1ff2c36fac393..feb44db5c91844470a4c8fa7965c8d47a5a78876 100644 (file)
--- a/index.c
+++ b/index.c
@@ -344,7 +344,8 @@ static long long int make_date_index_day(char *monthdir,int monthdir_size,int or
        monthdir[monthdir_len-1]='\0';
        write_html_trailer(fp_ou);
        if (fclose(fp_ou)==EOF) {
-               debuga(_("Write error in %s/%s: %s\n"),monthdir,INDEX_HTML_FILE,strerror(errno));
+               strcpy(monthdir+monthdir_len,INDEX_HTML_FILE);
+               debuga(_("Write error in \"%s\": %s\n"),monthdir,strerror(errno));
                exit(EXIT_FAILURE);
        }
        return(total_size);
@@ -513,7 +514,8 @@ static long long int make_date_index_month(char *yeardir,int yeardir_size,int or
        yeardir[yeardir_len-1]='\0';
        write_html_trailer(fp_ou);
        if (fclose(fp_ou)==EOF) {
-               debuga(_("Write error in %s/%s: %s\n"),yeardir,INDEX_HTML_FILE,strerror(errno));
+               strcpy(yeardir+yeardir_len,INDEX_HTML_FILE);
+               debuga(_("Write error in \"%s\": %s\n"),yeardir,strerror(errno));
                exit(EXIT_FAILURE);
        }
        return(total_size);
diff --git a/log.c b/log.c
index a7a98bf3fbd71f32fdd57011ff7bcdfd29a07989..dc14bef3c2a6663717ed3fd4869fde7b5bc5cdbe 100644 (file)
--- a/log.c
+++ b/log.c
@@ -797,7 +797,10 @@ static void getusers(const char *pwdfile, int debug)
                strcat(userfile,buf);
        }
 
-       fclose(fp_usr);
+       if (fclose(fp_usr)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),pwdfile,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
 
        return;
 }
index 6bf1a0f49d505bbc3f71f688529eeeb45457014c..cc7a8281288ea4fba3f4c6612a061ca2a80a266e 100644 (file)
--- a/readlog.c
+++ b/readlog.c
@@ -664,7 +664,7 @@ static void ReadOneLogFile(struct ReadLogDataStruct *Filter,const char *arq)
                                        if (ufile1->file!=NULL) {
                                                if (x>=maxopenfiles) {
                                                        if (fclose(ufile1->file)==EOF) {
-                                                               debuga(_("Write error in the log file of user %s: %s\n"),ufile1->user->id,strerror(errno));
+                                                               debuga(_("Write error in log file of user %s: %s\n"),ufile1->user->id,strerror(errno));
                                                                exit(EXIT_FAILURE);
                                                        }
                                                        ufile1->file=NULL;
@@ -839,7 +839,7 @@ int ReadLogFile(struct ReadLogDataStruct *Filter)
        for (ufile=first_user_file ; ufile ; ufile=ufile1) {
                ufile1=ufile->next;
                if (ufile->file!=NULL && fclose(ufile->file)==EOF) {
-                       debuga(_("Write error in the log file of user %s: %s\n"),ufile->user->id,strerror(errno));
+                       debuga(_("Write error in log file of user %s: %s\n"),ufile->user->id,strerror(errno));
                        exit(EXIT_FAILURE);
                }
                free(ufile);
index 37e0dd2139c8084dd2d644f31937cdc1e1048c4a..0f15d55d4332f5f13fba8ff2679012e86847fca2 100644 (file)
@@ -242,7 +242,10 @@ void realtime(void)
                if (NextIndex>StoreSize) StoreSize=NextIndex;
                if (NextIndex>realtime_access_log_lines) NextIndex=0;
        }
-       fclose(fp);
+       if (fclose(fp)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),file_name,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
        longline_destroy(&line);
 
        datashow(StoredLogEntries,StoreIndex,StoreSize);
index f6379d19896fc3000986e32a50c69518f3e8d71d..c9b8464ac434eac91f6d90400e6c5c4d2ab2bcd6 100644 (file)
@@ -277,7 +277,10 @@ static void read_log(const char *wentp, FILE *fp_ou,int dfrom,int duntil)
        while ((buf=longline_read(fp_in,line)) != NULL) {
                parse_log(fp_ou,buf);
        }
-       fclose(fp_in);
+       if (fclose(fp_in)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),wentp,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
        longline_destroy(&line);
        return;
 }
@@ -373,9 +376,12 @@ void redirector_log(void)
                                read_log(wentp,fp_ou,dfrom,duntil);
                        }
                }
+               if (fclose(fp_guard)==EOF) {
+                       debuga(_("Read error in \"%s\": %s\n"),SquidGuardConf,strerror(errno));
+                       exit(EXIT_FAILURE);
+               }
        }
 
-       if (fp_guard) fclose(fp_guard);
        if (fp_ou && fclose(fp_ou)==EOF) {
                debuga(_("Write error in \"%s\": %s\n"),guard_in,strerror(errno));
                exit(EXIT_FAILURE);
@@ -561,7 +567,10 @@ void redirector_report(void)
                output_html_link(fp_ou,url,100);
                fprintf(fp_ou,"</td><td class=\"data2\">%s</td></tr>\n",rule);
        }
-       fclose(fp_in);
+       if (fclose(fp_in)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),redirector_sorted,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
        longline_destroy(&line);
 
        if(count>SquidGuardReportLimit && SquidGuardReportLimit>0)
index cb8088028ee4df9425a89fcce38431d17fc413f4..20a4d6ff112e12aa277317cd5f2059fa4d1a3c2e 100644 (file)
--- a/repday.c
+++ b/repday.c
@@ -118,7 +118,10 @@ void report_day(const struct userinfostruct *uinfo)
                        telap[i]+=elap;
                }
        }
-       fclose(fp_in);
+       if (fclose(fp_in)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),wdirname,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
 
        if((fp_ou=fopen(arqout,"w"))==NULL) {
                debuga(_("Cannot open file \"%s\": %s\n"),arqout,strerror(errno));
index 666432f4d4ed2b3303b2ed35825b7f13998bc025..c64c37d4ff06d276b354759bce3adfdb378e4919 100644 (file)
--- a/report.c
+++ b/report.c
@@ -330,7 +330,10 @@ void gerarel(void)
                        strcpy(oldaccdia,accdia);
                        strcpy(oldacchora,acchora);
                }
-               fclose(fp_in);
+               if (fclose(fp_in)==EOF) {
+                       debuga(_("Read error in \"%s\": %s\n"),tmp3,strerror(errno));
+                       exit(EXIT_FAILURE);
+               }
                longline_destroy(&line);
                if (oldurltt) free(oldurltt);
                if (oldurl) {
@@ -349,7 +352,7 @@ void gerarel(void)
                }
                if (fp_tmp) {
                        if (fclose(fp_tmp)==EOF) {
-                               debuga(_("Failed to close temporary file for user %s: %s\n"),uinfo->filename,strerror(errno));
+                               debuga(_("Write error in \"%s\": %s\n"),uinfo->filename,strerror(errno));
                                exit(EXIT_FAILURE);
                        }
                        fp_tmp=NULL;
index 5b0e681cc51382cdb712414cddb4901291289d88..410c6dffd197ee1bb64463d64c4f0e66ccd05fd2 100644 (file)
@@ -175,7 +175,10 @@ void siteuser(void)
                }
 
        }
-       fclose(fp_in);
+       if (fclose(fp_in)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),general2,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
        longline_destroy(&line);
 
        if(regs>0) {
index d6593b2d74c59b42d6393e46b071e31ca074ffd4..36bf6609dfb8b3ded4f13a7a69654f965dc62749 100644 (file)
@@ -141,7 +141,8 @@ void splitlog(const char *arq, char df, int dfrom, int duntil, int convert, cons
 
        longline_destroy(&line);
        if (fclose(fp_in)==EOF) {
-               debuga(_("Failed to close file \"%s\": %s\n"),arq,strerror(errno));
+               debuga(_("Read error in \"%s\": %s\n"),arq,strerror(errno));
+               exit(EXIT_FAILURE);
        }
        if (autosplit && fp_ou) {
                if (fclose(fp_ou)==EOF) {
index 664e25daeeefaff6a5b8090f955d1e521a6b9a7d..a41558f823c19f01836742488272a016219167dc 100644 (file)
@@ -162,7 +162,10 @@ void topsites(void)
                ttntime+=item.nelap;
 #endif
        }
-       fclose(fp_in);
+       if (fclose(fp_in)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),general2,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
        longline_destroy(&line);
 
        if (ourl) {
@@ -316,7 +319,10 @@ void topsites(void)
                if (SortTableJs[0]) fprintf(fp_ou," sorttable_customkey=\"%d\"",nusers);
                fprintf(fp_ou,">%s</td></tr>\n",fixnum(nusers,1));
        }
-       fclose(fp_in);
+       if (fclose(fp_in)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),sites,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
        longline_destroy(&line);
 
        fputs("</table></div>\n",fp_ou);
index 59fb9a84d50127d9f7c01be2aa9834b9b179c981..3441c3894b525bb134adf6df65381bf15201d0ec 100644 (file)
--- a/topuser.c
+++ b/topuser.c
@@ -140,7 +140,10 @@ void topuser(void)
                tnincache+=item.incache;
                tnoucache+=item.oucache;
        }
-       fclose(fp_in);
+       if (fclose(fp_in)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),wger,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
        longline_destroy(&line);
 
        if (olduser[0] != '\0') {
@@ -423,7 +426,10 @@ void topuser(void)
 
                topcount++;
        }
-       fclose(fp_top1);
+       if (fclose(fp_top1)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),top1,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
        if (!KeepTempLog && unlink(top1)) {
                debuga(_("Cannot delete \"%s\": %s\n"),top1,strerror(errno));
                exit(EXIT_FAILURE);
diff --git a/url.c b/url.c
index ca2318cafeb6c14423fe3a0370296a420b8899f7..f24ce71d01c94c8fcd954b612347f418ee0d0f45 100644 (file)
--- a/url.c
+++ b/url.c
@@ -598,7 +598,10 @@ void read_hostalias(const char *Filename)
        }
 
        longline_destroy(&line);
-       fclose(fi);
+       if (fclose(fi)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),Filename,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
 
        if (debug) {
                struct hostalias_name *alias1;
index ea9cf2af025f39c2b0721734e8a6341376c9b979..8ea1140b3e555192ac73b9dd5ec4b44d4532dc9d 100644 (file)
@@ -122,11 +122,14 @@ void useragent(void)
                debuga(_("   Records read: %ld\n"),totregsl);
        }
 
-       fclose(fp_in);
        if (fclose(fp_ou)==EOF) {
                debuga(_("Write error in \"%s\": %s\n"),tmp3,strerror(errno));
                exit(EXIT_FAILURE);
        }
+       if (fclose(fp_in)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),UserAgentLog,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
 
        if(debug) {
                debuga(_("Sorting file: %s\n"),tmp2);
@@ -213,7 +216,10 @@ void useragent(void)
        }
 
        fputs("</table>\n",fp_ht);
-       fclose(fp_in);
+       if (fclose(fp_in)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),tmp2,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
 
        if (snprintf(csort,sizeof(csort),"sort -t \"\t\" -k 2,2 -o \"%s\" \"%s\"",tmp3,tmp2)>=sizeof(csort)) {
                debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),tmp2,tmp3);
@@ -273,11 +279,14 @@ void useragent(void)
        fprintf(fp_ou,"%06d %s\n",agentot,agent);
        agentot2+=agentot;
 
-       fclose(fp_in);
        if (fclose(fp_ou)==EOF) {
                debuga(_("Write error in \"%s\": %s\n"),tmp3,strerror(errno));
                exit(EXIT_FAILURE);
        }
+       if (fclose(fp_in)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),tmp3,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
 
        if (!KeepTempLog && unlink(tmp3)) {
                debuga(_("Cannot delete \"%s\": %s\n"),tmp3,strerror(errno));
@@ -325,7 +334,10 @@ void useragent(void)
                output_html_string(fp_ht,gwarea.current,250);
                fprintf(fp_ht,"</td><td class=\"data\">%d</td><td class=\"data\">%3.2lf</td></tr>\n",nagent,perc);
        }
-       fclose(fp_in);
+       if (fclose(fp_in)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),tmp3,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
 
        fputs("</table></div>\n",fp_ht);
        write_html_trailer(fp_ht);
index e87db5ed913c07360e6a8f8fce8840944a933832..6f9ac916bd8d8fadf75bf523645000b46c44a726 100644 (file)
@@ -342,7 +342,10 @@ void read_useralias(const char *Filename)
        }
 
        longline_destroy(&line);
-       fclose(fi);
+       if (fclose(fi)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),Filename,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
 
        if (debug) {
                debuga(_("List of user names to alias:\n"));
index 5e6aa82f5e4b8c53208221f00fedc4ebde2b9cc1..40c08ec5c7a425b86577ea1f63d83423dce40e8f 100644 (file)
--- a/usertab.c
+++ b/usertab.c
@@ -123,7 +123,10 @@ static void init_file_usertab(const char *UserTabFile)
                userfile[z2++]='\t';
        }
        userfile[z2]='\0';
-       fclose(fp_usr);
+       if (fclose(fp_usr)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),UserTabFile,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
 }
 
 static void get_usertab_name(const char *user,char *name,int namelen)
diff --git a/util.c b/util.c
index 957b464b6a3b71b2ea13d6eb8a09d4b5571ded06..12b14ffe67676f8bf00c62abbda10ed8a73bb5e4 100644 (file)
--- a/util.c
+++ b/util.c
@@ -793,7 +793,10 @@ int obtdate(const char *dirname, const char *name, char *data)
                debuga(_("Failed to read the date in %s\n"),wdir);
                exit(EXIT_FAILURE);
        }
-       fclose(fp_in);
+       if (fclose(fp_in)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),wdir,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
        fixendofline(data);
 
        return(0);
@@ -857,7 +860,10 @@ int obtuser(const char *dirname, const char *name)
                debuga(_("Failed to read the number of users in %s\n"),wdir);
                exit(EXIT_FAILURE);
        }
-       fclose(fp_in);
+       if (fclose(fp_in)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),wdir,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
        nuser=atoi(tuser);
 
        return(nuser);
@@ -922,7 +928,10 @@ void obttotal(const char *dirname, const char *name, int nuser, long long int *t
                }
                break;
        }
-       fclose(fp_in);
+       if (fclose(fp_in)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),wdir,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
        longline_destroy(&line);
 
        if (nuser <= 0)
@@ -1132,12 +1141,15 @@ static void copy_images(void)
                                                }
                                        }
                                        if (fclose(img_ou)==EOF) {
-                                               debuga(_("Error while copying image %s: %s\n"),dstfile,strerror(errno));
+                                               debuga(_("Write error in \"%s\": %s\n"),dstfile,strerror(errno));
                                                exit(EXIT_FAILURE);
                                        }
                                } else
                                        debuga(_("Cannot open file \"%s\": %s\n"), dstfile, strerror(errno));
-                               fclose(img_in);
+                               if (fclose(img_in)==EOF) {
+                                       debuga(_("Read error in \"%s\": %s\n"),srcfile,strerror(errno));
+                                       exit(EXIT_FAILURE);
+                               }
                        } else
                                debuga(_("Cannot open file \"%s\": %s\n"), srcfile, strerror(errno));
                }
@@ -1447,7 +1459,7 @@ int vrfydir(const struct periodstruct *per1, const char *addr, const char *site,
                exit(EXIT_FAILURE);
        }
        if (fclose(fp_ou)==EOF) {
-               debuga(_("Failed to write the date in %s: %s\n"),wdir,strerror(errno));
+               debuga(_("Write error in \"%s\": %s\n"),wdir,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -1725,7 +1737,7 @@ void removetmp(const char *outdir)
        }
        totalger(fp_gen,filename);
        if (fclose(fp_gen)==EOF) {
-               debuga(_("Failed to close %s after writing the total line: %s\n"),filename,strerror(errno));
+               debuga(_("Write error in \"%s\": %s\n"),filename,strerror(errno));
                exit(EXIT_FAILURE);
        }
 }
@@ -1781,7 +1793,10 @@ void load_excludecodes(const char *ExcludeCodes)
                Stored+=i+1;
        }
 
-       fclose(fp_in);
+       if (fclose(fp_in)==EOF) {
+               debuga(_("Read error in \"%s\": %s\n"),ExcludeCodes,strerror(errno));
+               exit(EXIT_FAILURE);
+       }
        return;
 }