]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Make it possible to delete an old temporary directory
authorFrederic Marchal <fmarchal@users.sourceforge.net>
Sun, 12 Jul 2015 19:13:43 +0000 (21:13 +0200)
committerFrederic Marchal <fmarchal@users.sourceforge.net>
Sun, 12 Jul 2015 19:13:43 +0000 (21:13 +0200)
Sarg prepares the report in a the temporary directory. The directory must
be empty before starting the report generation. Deleting an old stray
temporary directory must be made with care to make sure we don't delete
a wrong directory.

The old temporary directory check would not take the email report generated
files into account.

email.c
report.c
util.c

diff --git a/email.c b/email.c
index 293601a5e02fcf2a36ded1a4602a5a41198fd1d8..6e4680731439a719af05073b597605c6822a1154 100644 (file)
--- a/email.c
+++ b/email.c
@@ -63,7 +63,7 @@ int geramail(const char *dirname, int debug, const char *email, const char *Temp
                exit(EXIT_FAILURE);
        }
 
-       snprintf(top2,sizeof(top2),"%s/top.tmp",dirname);
+       snprintf(top2,sizeof(top2),"%s/email.int_unsort",dirname);
        if((fp_top2=fopen(top2,"w"))==NULL) {
                debuga(__FILE__,__LINE__,_("Cannot open file \"%s\": %s\n"),top2,strerror(errno));
                exit(EXIT_FAILURE);
index e1df5ba1e8b6630d2eef553255f144fbbc138e9d..acf37feeb6bf1113cf9dcc6da96dc6912821bb43 100644 (file)
--- a/report.c
+++ b/report.c
@@ -94,9 +94,18 @@ void gerarel(void)
        smartfilter=false;
        memset(&globstat,0,sizeof(globstat));
 
-       if (vrfydir(&period, addr, site, us)<0) {
-               debuga(__FILE__,__LINE__,_("Cannot create the output directory name containing the period as part of the name\n"));
-               exit(EXIT_FAILURE);
+       if (email[0]=='\0') {
+               if (vrfydir(&period, addr, site, us)<0) {
+                       debuga(__FILE__,__LINE__,_("Cannot create the output directory name containing the period as part of the name\n"));
+                       exit(EXIT_FAILURE);
+               }
+       } else {
+               if (snprintf(outdirname,sizeof(outdirname),"%semailrep",outdir)>=sizeof(outdirname)) {
+                       debuga(__FILE__,__LINE__,_("Path too long: "));
+                       debuga_more("%semailrep\n",outdir);
+                       exit(EXIT_FAILURE);
+               }
+               my_mkdir(outdirname);
        }
 
        if(debugz>=LogLevel_Process){
diff --git a/util.c b/util.c
index c49824e2971edb87d735080a341b1173218fa752..dc75be0ffb9aabccfc6d6be81aaf7c2dd40ef4cc 100644 (file)
--- a/util.c
+++ b/util.c
@@ -2266,7 +2266,8 @@ void emptytmpdir(const char *dir)
                ".utmp",
                ".ip",
                "lastlog1",
-               "lastlog"
+               "lastlog",
+               "emailrep"
        };
 
        dirp=opendir(dir);