//! Name of the file containing the unsorted denied entries.
static char denied_unsort[MAXLEN]="";
-//! Name of the file containing the sorted denied entries.
-static char denied_sort[MAXLEN]="";
//! The file handle to write the entries.
static FILE *fp_denied=NULL;
//! \c True if at least one denied entry exists.
debuga(_("Write error in %s: %s\n"),denied_unsort,strerror(errno));
exit(EXIT_FAILURE);
}
+ fp_denied=NULL;
}
}
char *buf;
char *url;
+ char denied_sort[MAXLEN];
char report[MAXLEN];
char ip[MAXLEN];
char oip[MAXLEN];
char user[MAXLEN];
- char ouser[MAXLEN];
- char ouser2[MAXLEN];
+ char ouser[MAXLEN]="";
+ char ouser2[MAXLEN]="";
char data[15];
char hora[15];
char csort[4098];
- bool z=false;
+ bool z=false;
int count=0;
int day,month,year;
int cstatus;
struct userinfostruct *uinfo;
struct tm t;
- ouser[0]='\0';
- ouser2[0]='\0';
-
- sprintf(denied_sort,"%s/denied.int_log",tmp);
if (!denied_exists) {
if (unlink(denied_sort)==-1)
{
return;
}
+ if (snprintf(denied_sort,sizeof(denied_sort),"%s/denied.int_log",tmp)>=sizeof(denied_sort)) {
+ debuga(_("Temporary directory path too long to sort the denied accesses\n"));
+ exit(EXIT_FAILURE);
+ }
if (snprintf(csort,sizeof(csort),"sort -T \"%s\" -t \"\t\" -k 3,3 -k 5,5 -o \"%s\" \"%s\"",tmp,denied_sort,denied_unsort)>=sizeof(csort)) {
debuga(_("Sort command too long when sorting file \"%s\" to \"%s\"\n"),denied_unsort,denied_sort);
exit(EXIT_FAILURE);
if (unlink(denied_sort)==-1)
debuga(_("Failed to delete the file \"%s\" after processing it - %s\n"),denied_sort,strerror(errno));
- denied_sort[0]='\0';
return;
}
*/
void denied_cleanup(void)
{
- if(denied_sort[0]) {
- if (unlink(denied_sort)==-1)
- debuga(_("Failed to delete %s: %s\n"),denied_sort,strerror(errno));
+ if (fp_denied)
+ {
+ fclose(fp_denied);
+ fp_denied=NULL;
}
if(denied_unsort[0]) {
if (unlink(denied_unsort)==-1)