]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Keep temporary files in place for inspection
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Sun, 15 Jul 2012 12:34:52 +0000 (14:34 +0200)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Sun, 15 Jul 2012 12:34:52 +0000 (14:34 +0200)
Add a command line option and a configuration tag to leave the temporary
files in place when sarg terminates.

The feature is for debugging purpose. It cannot be used for production.

21 files changed:
authfail.c
dansguardian_log.c
dansguardian_report.c
denied.c
download.c
email.c
getconf.c
grepday.c
html.c
include/conf.h
log.c
realtime.c
redirector.c
report.c
sarg.conf
siteuser.c
smartfilter.c
sort.c
topsites.c
topuser.c
useragent.c

index b390202af565304764937e367754982b3bfa6eea..8e3b9585686935f42aa78b1ae0c4d7f028ebae40 100644 (file)
@@ -71,7 +71,9 @@ void authfail_report(void)
        snprintf(tmp4,sizeof(tmp4),"%s/authfail.int_unsort",tmp);
 
        if(authfail_count == 0) {
-               unlink(tmp4);
+               if (!KeepTempLog && unlink(tmp4)) {
+                       debuga(_("Cannot delete \"%s\": %s\n"),tmp4,strerror(errno));
+               }
                if (debugz) debugaz(_("Authentication failures report not produced because it is empty\n"));
                return;
        }
@@ -91,8 +93,8 @@ void authfail_report(void)
                debuga(_("sort command: %s\n"),csort);
                exit(EXIT_FAILURE);
        }
-       if (unlink(tmp4)) {
-               debuga(_("Cannot delete %s - %s\n"),tmp4,strerror(errno));
+       if (!KeepTempLog && unlink(tmp4)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),tmp4,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -204,8 +206,8 @@ void authfail_report(void)
        if (fclose(fp_ou)==EOF)
                debuga(_("Failed to close file %s - %s\n"),report,strerror(errno));
 
-       if (unlink(authfail_in)) {
-               debuga(_("Cannot delete %s - %s\n"),authfail_in,strerror(errno));
+       if (!KeepTempLog && unlink(authfail_in)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),authfail_in,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
index be13b867effa49af52732b3d893cf7e31cf3c14e..69e37b651895ee01b3a8ccc15fdc06c6fa471dff 100644 (file)
@@ -154,8 +154,8 @@ void dansguardian_log(void)
                debuga(_("sort command: %s\n"),tmp6);
                exit(EXIT_FAILURE);
        }
-       if (unlink(guard_in)) {
-               debuga(_("Cannot delete %s - %s\n"),guard_in,strerror(errno));
+       if (!KeepTempLog && unlink(guard_in)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),guard_in,strerror(errno));
                exit(EXIT_FAILURE);
        }
 }
index f326226d2f79430dc8bf618b3c88cb2b1d1684c6..4405a8145eb4e7066b76594e338959562d05cd34 100644 (file)
@@ -60,7 +60,8 @@ void dansguardian_report(void)
 
        snprintf(dansguardian_in,sizeof(dansguardian_in),"%s/dansguardian.int_log",tmp);
        if(!dansguardian_count) {
-               unlink(dansguardian_in);
+               if (!KeepTempLog && unlink(dansguardian_in))
+                       debuga(_("Cannot delete \"%s\": %s\n"),dansguardian_in,strerror(errno));
                if (debugz) debugaz(_("Dansguardian report not generated because it is empty\n"));
                return;
        }
@@ -169,8 +170,8 @@ void dansguardian_report(void)
        if (fclose(fp_ou)==EOF)
                debuga(_("Failed to close file %s - %s\n"),report,strerror(errno));
 
-       if (unlink(dansguardian_in)) {
-               debuga(_("Cannot delete %s - %s\n"),dansguardian_in,strerror(errno));
+       if (!KeepTempLog && unlink(dansguardian_in)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),dansguardian_in,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
index 8b76517918cd87c1d623ae50b593cc16548ccdb8..76b71af67c2cb68192f89926722f0ba0b67589e7 100644 (file)
--- a/denied.c
+++ b/denied.c
@@ -64,7 +64,8 @@ void gen_denied_report(void)
 
        sprintf(denied_in,"%s/denied.int_log",tmp);
        if (!denied_count) {
-               unlink(denied_in);
+               if (!KeepTempLog && unlink(denied_in))
+                       debuga(_("Cannot delete \"%s\": %s\n"),denied_in,strerror(errno));
                if (debugz) debugaz(_("Denied report not produced because it is empty\n"));
                return;
        }
@@ -176,8 +177,8 @@ void gen_denied_report(void)
        if (fclose(fp_ou)<0)
                debuga(_("Failed to close file %s - %s\n"),report,strerror(errno));
 
-       if (unlink(denied_in)==-1)
-               debuga(_("Failed to delete the file \"%s\" after processing it - %s\n"),denied_in,strerror(errno));
+       if (!KeepTempLog && unlink(denied_in)==-1)
+               debuga(_("Cannot delete \"%s\": %s\n"),denied_in,strerror(errno));
 
        return;
 }
index 83b4191088c20f0fb469e40ca041b59e6ad7a404..d914782de8fa4f82346e2a30eca14b1223ba01a0 100644 (file)
@@ -75,8 +75,8 @@ static void download_sort(const char *report_in)
                debuga(_("Path too long for %s/download.int_unsort\n"),tmp);
                exit(EXIT_FAILURE);
        }
-       if (unlink(csort)) {
-               debuga(_("Cannot delete %s - %s\n"),csort,strerror(errno));
+       if (!KeepTempLog && unlink(csort)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),csort,strerror(errno));
                exit(EXIT_FAILURE);
        }
 }
@@ -230,8 +230,8 @@ void download_report(void)
        if (fclose(fp_ou)==EOF)
                debuga(_("Failed to close file %s - %s\n"),report,strerror(errno));
 
-       if (unlink(report_in)) {
-               debuga(_("Cannot delete %s - %s\n"),report_in,strerror(errno));
+       if (!KeepTempLog && unlink(report_in)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),report_in,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
diff --git a/email.c b/email.c
index df4f9314594cbda5329aa70f2c4226c4eb0222aa..e8b02866ff9db40d4738b99e66af539b3bbf2cc7 100644 (file)
--- a/email.c
+++ b/email.c
@@ -142,8 +142,8 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
                exit(EXIT_FAILURE);
        }
 
-       if (unlink(top2)) {
-               debuga(_("Cannot delete %s - %s\n"),top2,strerror(errno));
+       if (!KeepTempLog && unlink(top2)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),top2,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -253,8 +253,8 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
 #endif
 
        fclose(fp_top1);
-       if (unlink(top1)) {
-               debuga(_("Cannot delete %s - %s\n"),top1,strerror(errno));
+       if (!KeepTempLog && unlink(top1)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),top1,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
index efa1fe679ca6e111e7ba121dd4ee2e9eaac6bfea..e338310323e31dd5ef8db61fb64f76154be2ce49 100644 (file)
--- a/getconf.c
+++ b/getconf.c
@@ -748,6 +748,8 @@ static void parmtest(char *buf)
        if (getparam_string("sorttable",buf,SortTableJs,sizeof(SortTableJs))>0) return;
 
        if (getparam_string("hostalias",buf,HostAliasFile,sizeof(HostAliasFile))>0) return;
+
+       if (getparam_bool("keep_temp_log",buf,&KeepTempLog)>0) return;
        
        if(strstr(buf,"squid24") != 0) {
                squid24=true;
index 42935f113db8a2c68e14cd5e2afa42f5790df36e..84ad3115dc0e9a328e3e45aa594c9707e0bf541e 100644 (file)
--- a/grepday.c
+++ b/grepday.c
@@ -683,7 +683,8 @@ void greport_day(const struct userinfostruct *uinfo)
                return;
        }
        if(!Graphs || GraphFont[0]=='\0') {
-               unlink(wdirname);
+               if (!KeepTempLog && unlink(wdirname))
+                       debuga(_("Cannot delete \"%s\": %s\n"),wdirname,strerror(errno));
                return;
        }
 
@@ -724,8 +725,8 @@ void greport_day(const struct userinfostruct *uinfo)
                }
        }
        fclose(fp_in);
-       if (unlink(wdirname)) {
-               debuga(_("Cannot delete %s - %s\n"),wdirname,strerror(errno));
+       if (!KeepTempLog && unlink(wdirname)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),wdirname,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
diff --git a/html.c b/html.c
index 08ab1f678ea4bbd88ea4f56a5b0ef7655d01d99b..4ca7bca10a7d2a3ba07b2c0d18dcf07a6df0b71c 100644 (file)
--- a/html.c
+++ b/html.c
@@ -487,13 +487,13 @@ void htmlrel(void)
                longline_destroy(&line);
 
                if (iprel && arqip[0]) {
-                       if (unlink(arqip)) {
-                               debuga(_("Cannot delete %s - %s\n"),arqip,strerror(errno));
+                       if (!KeepTempLog && unlink(arqip)) {
+                               debuga(_("Cannot delete \"%s\": %s\n"),arqip,strerror(errno));
                                exit(EXIT_FAILURE);
                        }
                }
-               if (unlink(arqin)) {
-                       debuga(_("Cannot delete %s - %s\n"),arqin,strerror(errno));
+               if (!KeepTempLog && unlink(arqin)) {
+                       debuga(_("Cannot delete \"%s\": %s\n"),arqin,strerror(errno));
                        exit(EXIT_FAILURE);
                }
 
index b87558db746c26ca0ba8389c59b556421755f63e..70cb4a2fc67903fd376fe52b3a7b703d6e193ee4 100755 (executable)
@@ -475,6 +475,8 @@ int  nrepday;
 int  ndownload;
 int  ntopuser;
 bool  squid24;
+//! \c True to keep the temporary files for inspection.
+bool KeepTempLog;
 
 long long int nocost;
 float cost;
diff --git a/log.c b/log.c
index 6bc1b68e356af0b48b60142e9908cdf99a03a9f0..923a797654bcfc9817e7fd57a7b85701666e47a6 100644 (file)
--- a/log.c
+++ b/log.c
@@ -348,6 +348,7 @@ int main(int argc,char *argv[])
        squid24=false;
        dfrom=0;
        duntil=0;
+       KeepTempLog=false;
 
        bzero(IncludeUsers, sizeof(IncludeUsers));
        bzero(ExcludeString, sizeof(ExcludeString));
@@ -362,7 +363,7 @@ int main(int argc,char *argv[])
 
        strcpy(Title,_("Squid User Access Report"));
 
-       while((ch = getopt_long_only(argc, argv, "a:b:c:d:e:f:g:u:l:L:o:s:t:w:P:hijmnprvxyz",long_options,&option_index)) != -1){
+       while((ch = getopt_long_only(argc, argv, "a:b:c:d:e:f:g:hikl:L:mno:P:prs:t:u:vw:xyz",long_options,&option_index)) != -1){
                switch(ch)
                {
                        case 0:
@@ -401,6 +402,9 @@ int main(int argc,char *argv[])
                        case 'i':
                                iprel=true;
                                break;
+                       case 'k':
+                               KeepTempLog=true;
+                               break;
                        case 'l':
                                if (NAccessLog>=MAXLOGS) {
                                        debuga(_("Too many log files passed on command line with option -l.\n"));
@@ -669,6 +673,7 @@ int main(int argc,char *argv[])
                if(strcmp(df,"w") == 0)
                        debuga(_("                     Date format (-g) = Sites & Users (yyyy/ww)\n"));
                debuga(_("                       IP report (-i) = %s\n"),(iprel) ? _("Yes") : _("No"));
+               debuga(_("            Keep temporary files (-k) = %s\n"),(KeepTempLog) ? _("Yes") : _("No"));
                for (iarq=0 ; iarq<NAccessLog ; iarq++)
                        debuga(_("                       Input log (-l) = %s\n"),AccessLog[iarq]);
                for (iarq=0 ; iarq<NRedirectorLogs ; iarq++)
@@ -701,6 +706,7 @@ int main(int argc,char *argv[])
                if(strcmp(df,"w") == 0)
                        printf(_("                     Date format (-g) = Sites & Users (yyyy/ww)\n"));
                printf(_("                       IP report (-i) = %s\n"),(iprel) ? _("Yes") : _("No"));
+               printf(_("            Keep temporary files (-k) = %s\n"),(KeepTempLog) ? _("Yes") : _("No"));
                for (iarq=0 ; iarq<NAccessLog ; iarq++)
                        printf(_("                       Input log (-l) = %s\n"),AccessLog[iarq]);
                for (iarq=0 ; iarq<NRedirectorLogs ; iarq++)
@@ -1686,8 +1692,8 @@ int main(int argc,char *argv[])
                        debuga(_("sort command: %s\n"),csort);
                        exit(EXIT_FAILURE);
                }
-               if (unlink(denied_unsort)) {
-                       debuga(_("Cannot delete %s - %s\n"),denied_unsort,strerror(errno));
+               if (!KeepTempLog && unlink(denied_unsort)) {
+                       debuga(_("Cannot delete \"%s\": %s\n"),denied_unsort,strerror(errno));
                        exit(EXIT_FAILURE);
                }
        }
@@ -1698,10 +1704,11 @@ int main(int argc,char *argv[])
                gerarel();
 
        if((ReportType & REPORT_TYPE_DENIED) != 0) {
-               unlink(denied_sort);
+               if (!KeepTempLog && unlink(denied_sort))
+                       debuga(_("Cannot delete \"%s\": %s\n"),denied_sort,strerror(errno));
        }
 
-       if(strcmp(tmp,"/tmp") != 0) {
+       if(!KeepTempLog && strcmp(tmp,"/tmp") != 0) {
                unlinkdir(tmp,0);
        }
 
index a2d7c7f2eb8d914783614583dc54de4e331a54ce..746286b9eded9b11b6d18dd3c86b52a5f16ec63b 100755 (executable)
@@ -104,8 +104,8 @@ static void getlog(void)
                debuga(_("sort command: %s\n"),cmd);
                exit(EXIT_FAILURE);
        }
-       if (unlink(template1)) {
-               debuga(_("Cannot delete %s - %s\n"),template1,strerror(errno));
+       if (!KeepTempLog && unlink(template1)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),template1,strerror(errno));
                exit(EXIT_FAILURE);
        }
        datashow(template2);
@@ -288,8 +288,8 @@ static void datashow(const char *tmp)
 
        puts("</table>\n</div>\n</body>\n</html>\n");
        fclose(fin);
-       if (unlink(tmp)) {
-               debuga(_("Cannot delete %s - %s\n"),tmp,strerror(errno));
+       if (!KeepTempLog && unlink(tmp)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),tmp,strerror(errno));
                exit(EXIT_FAILURE);
        }
        fflush(NULL);
index 1fd63393534abbeba3e47326a548165a578f8ac9..87051a6cf9af49ba928333b115ba317420ef5dee 100644 (file)
@@ -398,8 +398,8 @@ void redirector_log(void)
                exit(EXIT_FAILURE);
        }
 
-       if (unlink(guard_in)) {
-               debuga(_("Cannot delete %s - %s\n"),guard_in,strerror(errno));
+       if (!KeepTempLog && unlink(guard_in)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),guard_in,strerror(errno));
                exit(EXIT_FAILURE);
        }
        return;
@@ -444,7 +444,8 @@ void redirector_report(void)
 
        snprintf(squidguard_in,sizeof(squidguard_in),"%s/redirector.int_log",tmp);
        if(!redirector_count) {
-               unlink(squidguard_in);
+               if (!KeepTempLog && unlink(squidguard_in))
+                       debuga(_("Cannot delete \"%s\": %s\n"),squidguard_in,strerror(errno));
                if (debugz) debugaz(_("Redirector report not generated because it is empty\n"));
                return;
        }
@@ -575,8 +576,8 @@ void redirector_report(void)
        if (fclose(fp_ou)==EOF)
                debuga(_("Failed to close file %s - %s\n"),report,strerror(errno));
 
-       if (unlink(squidguard_in)) {
-               debuga(_("Cannot delete %s - %s\n"),squidguard_in,strerror(errno));
+       if (!KeepTempLog && unlink(squidguard_in)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),squidguard_in,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
index 4ede8abc6b4182033f199b6564a5c165d822995d..39a9d00b63bddb3312e12c231416533c18b5d76f 100644 (file)
--- a/report.c
+++ b/report.c
@@ -331,8 +331,8 @@ void gerarel(void)
                                debuga(_("Failed to close temporary file for user %s - %s\n"),uinfo->filename,strerror(errno));
                        fp_tmp=NULL;
                }
-               if (unlink(tmp3)) {
-                       debuga(_("Cannot delete %s - %s\n"),tmp3,strerror(errno));
+               if (!KeepTempLog && unlink(tmp3)) {
+                       debuga(_("Cannot delete \"%s\": %s\n"),tmp3,strerror(errno));
                        exit(EXIT_FAILURE);
                }
        }
index 3e786c9f4257fa6fa527e106bb76b8f63221ddee..52c83f349c91e53adf66afd6b570b30d5c8b3735 100644 (file)
--- a/sarg.conf
+++ b/sarg.conf
 #      re:/\.dropbox\.com(:443)?/ dropbox
 #      re:/([\w-]+)\.(\w*[a-zA-Z]\w*)(?::\d+)?$/\1.\2
 #hostalias /usr/local/sarg/hostalias
+
+# TAG: keep_temp_log yes|no
+#      Keep temporary files created by sarg to produce its reports. The normal
+#      operation mode is to delete those files when they are not necessary any more.
+#
+#      Never leave that option to "yes" for normal operation as temporary files
+#      left over by previous run can be included in subsequent reports.
+#
+#      Use this option only to diagnose a problem with your reports. A better
+#      alternative is to run sarg from the command line with optino -k.
+#keep_temp_log no
index 84410b43333306811113de90c1920c75df041650..1904afe192cf7718119f00cce2c038dab1e58456 100644 (file)
@@ -180,8 +180,8 @@ void siteuser(void)
        }
        if (ourl) free(ourl);
 
-       if (unlink(general2)) {
-               debuga(_("Cannot delete %s - %s\n"),general2,strerror(errno));
+       if (!KeepTempLog && unlink(general2)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),general2,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
index ad73eb548cef8470dfeb4a800cd0570d196058ef..d461f702b43b93a13e6d48e5b3184b2897545c7a 100644 (file)
@@ -85,8 +85,8 @@ void smartfilter_report(void)
                debuga(_("sort command: %s\n"),csort);
                exit(EXIT_FAILURE);
        }
-       if (unlink(smart_in)) {
-               debuga(_("Cannot delete %s - %s\n"),smart_in,strerror(errno));
+       if (!KeepTempLog && unlink(smart_in)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),smart_in,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
diff --git a/sort.c b/sort.c
index e660fda1b418e1b5007171fe69c1664eb6fca1ef..b35d7a228f245399273abd42ddde37cefcec8ceb 100644 (file)
--- a/sort.c
+++ b/sort.c
@@ -85,8 +85,8 @@ void tmpsort(const struct userinfostruct *uinfo)
                debuga(_("sort command: %s\n"),csort);
                exit(EXIT_FAILURE);
        }
-       if (unlink(arqin)) {
-               debuga(_("Cannot delete %s - %s\n"),arqin,strerror(errno));
+       if (!KeepTempLog && unlink(arqin)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),arqin,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -135,8 +135,8 @@ void sort_users_log(const char *tmp, int debug,struct userinfostruct *uinfo)
                debuga(_("user name too long for %s/%s.unsort\n"),tmp,user);
                exit(EXIT_FAILURE);
        }
-       if (unlink(csort)) {
-               debuga(_("Cannot delete %s - %s\n"),csort,strerror(errno));
+       if (!KeepTempLog && unlink(csort)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),csort,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
index 59067636220fec6616c47523c6e2f16e6eb3ae24..6b0949b364e56f09346241feddfa149070f20bbb 100644 (file)
@@ -174,8 +174,8 @@ void topsites(void)
        }
 #endif
 
-       if (unlink(general2)) {
-               debuga(_("Cannot delete %s - %s\n"),general2,strerror(errno));
+       if (!KeepTempLog && unlink(general2)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),general2,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -210,8 +210,8 @@ void topsites(void)
                exit(EXIT_FAILURE);
        }
 
-       if (unlink(general3)) {
-               debuga(_("Cannot delete %s - %s\n"),general3,strerror(errno));
+       if (!KeepTempLog && unlink(general3)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),general3,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
index eb7c5bd412df47240a6acad3dd222a0c9f83c0e5..efeb607e150f54db7fa6c9e7ac1a4b783fc28242 100644 (file)
--- a/topuser.c
+++ b/topuser.c
@@ -201,8 +201,8 @@ void topuser(void)
                exit(EXIT_FAILURE);
        }
 
-       if (unlink(top2)) {
-               debuga(_("Cannot delete %s - %s\n"),top2,strerror(errno));
+       if (!KeepTempLog && unlink(top2)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),top2,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -356,7 +356,7 @@ void topuser(void)
                        } else {
                                sprintf(val1,"%s/d%s.html",outdirname,uinfo->filename);
                                if (unlink(val1)) {
-                                       debuga(_("Cannot delete %s - %s\n"),val1,strerror(errno));
+                                       debuga(_("Cannot delete \"%s\": %s\n"),val1,strerror(errno));
                                        exit(EXIT_FAILURE);
                                }
                        }
@@ -411,8 +411,8 @@ void topuser(void)
                topcount++;
        }
        fclose(fp_top1);
-       if (unlink(top1)) {
-               debuga(_("Cannot delete %s - %s\n"),top1,strerror(errno));
+       if (!KeepTempLog && unlink(top1)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),top1,strerror(errno));
                exit(EXIT_FAILURE);
        }
        longline_destroy(&line);
index fa000b5ffaaa28690600d3bc9b5c55670e7e96f7..4770d5ca2d99eb37f742e8c6b5712b655457e8b8 100644 (file)
@@ -148,8 +148,8 @@ void useragent(void)
                exit(EXIT_FAILURE);
        }
 
-       if (unlink(tmp3)) {
-               debuga(_("Cannot delete %s - %s\n"),tmp3,strerror(errno));
+       if (!KeepTempLog && unlink(tmp3)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),tmp3,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -231,8 +231,8 @@ void useragent(void)
                exit(EXIT_FAILURE);
        }
 
-       if (unlink(tmp2)) {
-               debuga(_("Cannot delete %s - %s\n"),tmp2,strerror(errno));
+       if (!KeepTempLog && unlink(tmp2)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),tmp2,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -279,8 +279,8 @@ void useragent(void)
                exit(EXIT_FAILURE);
        }
 
-       if (unlink(tmp3)) {
-               debuga(_("Cannot delete %s - %s\n"),tmp3,strerror(errno));
+       if (!KeepTempLog && unlink(tmp3)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),tmp3,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -300,8 +300,8 @@ void useragent(void)
                exit(EXIT_FAILURE);
        }
 
-       if (unlink(tmp2)) {
-               debuga(_("Cannot delete %s - %s\n"),tmp2,strerror(errno));
+       if (!KeepTempLog && unlink(tmp2)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),tmp2,strerror(errno));
                exit(EXIT_FAILURE);
        }
 
@@ -333,8 +333,8 @@ void useragent(void)
        if (fclose(fp_ht)==EOF)
                debuga(_("Failed to close file %s - %s\n"),hfile,strerror(errno));
 
-       if (unlink(tmp3)) {
-               debuga(_("Cannot delete %s - %s\n"),tmp3,strerror(errno));
+       if (!KeepTempLog && unlink(tmp3)) {
+               debuga(_("Cannot delete \"%s\": %s\n"),tmp3,strerror(errno));
                exit(EXIT_FAILURE);
        }