]> git.ipfire.org Git - thirdparty/sarg.git/blobdiff - authfail.c
Store the period internaly and get rid of the sarg-period file.
[thirdparty/sarg.git] / authfail.c
index 693444fcedaf73881bc4a04b7f44745ea7386fe7..ce4b0eed7ce37c00e67dbca8647f8b5af6d6bdfa 100644 (file)
@@ -35,9 +35,7 @@ void authfail_report(void)
    char *buf;
    char *url;
    char authfail_in[MAXLEN];
-   char per[MAXLEN];
    char report[MAXLEN];
-   char period[100];
    char ip[MAXLEN];
    char oip[MAXLEN];
    char user[MAXLEN];
@@ -69,19 +67,8 @@ void authfail_report(void)
    }
 
    snprintf(authfail_in,sizeof(authfail_in),"%s/authfail.log",TempDir);
-   snprintf(per,sizeof(per),"%s/sarg-period",outdirname);
    snprintf(report,sizeof(report),"%s/authfail.html",outdirname);
 
-   if ((fp_in = fopen(per, "r")) == NULL) {
-      debuga(_("(authfail) Cannot open file %s\n"),per);
-      exit(EXIT_FAILURE);
-   }
-   if (!fgets(period,sizeof(period),fp_in)) {
-      debuga(_("(authfail) read error in %s\n"),per);
-      exit(EXIT_FAILURE);
-   }
-   fclose(fp_in);
-
    snprintf(csort,sizeof(csort),"sort -b -T \"%s\" -k 3,3 -k 5,5 -o \"%s\" \"%s\"", TempDir, authfail_in, tmp4);
    cstatus=system(csort);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
@@ -102,7 +89,9 @@ void authfail_report(void)
    }
 
    write_html_header(fp_ou,(IndexTree == INDEX_TREE_DATE) ? 3 : 1,_("Authentication Failures"));
-   fprintf(fp_ou,"<tr><td class=\"header_l\">%s: %s</td></tr>\n",_("Period"),period);
+   fputs("<tr><td class=\"header_l\">",fp_ou);
+   fprintf(fp_ou,_("Period: %s"),period.text);
+   fputs("</td></tr>\n",fp_ou);
    fprintf(fp_ou,"<tr><th class=\"header_c\">%s</th></tr>\n",_("Authentication Failures"));
    close_html_header(fp_ou);
 
@@ -195,8 +184,10 @@ void authfail_report(void)
    longline_destroy(&line);
 
    fputs("</table></div>\n",fp_ou);
-   write_html_trailer(fp_ou);
-   fclose(fp_ou);
+   if (write_html_trailer(fp_ou)<0)
+      debuga(_("Write error in file %s\n"),report);
+   if (fclose(fp_ou)==EOF)
+      debuga(_("Failed to close file %s - %s\n"),report,strerror(errno));
 
    unlink(authfail_in);