char guard_ou[MAXLEN];
char loglocation[MAXLEN] = "/var/log/dansguardian/access.log";
int year, mon, day;
- char hour[15];
+ int hour;
+ char minsec[15];
char user[MAXLEN], code1[255], code2[255];
char ip[45];
char *url;
continue;
getword_start(&gwarea,buf);
if (getword_atoi(&year,&gwarea,'.')<0 || getword_atoi(&mon,&gwarea,'.')<0 ||
- getword_atoi(&day,&gwarea,' ')<0 || getword(hour,sizeof(hour),&gwarea,' ')<0 ||
- getword(user,sizeof(user),&gwarea,' ')<0 || getword(ip,sizeof(ip),&gwarea,' ')<0 ||
- getword_skip(MAXLEN,&gwarea,'/')<0 || getword_skip(MAXLEN,&gwarea,'/')<0) {
+ getword_atoi(&day,&gwarea,' ')<0) {
+ debuga(_("Invalid date found in your dansguardian log file %s\n"),loglocation);
+ exit(EXIT_FAILURE);
+ }
+ if (getword_atoi(&hour,&gwarea,':')<0 || getword(minsec,sizeof(minsec),&gwarea,' ')<0) {
+ debuga(_("Invalid time found in your dansguardian log file %s\n"),loglocation);
+ exit(EXIT_FAILURE);
+ }
+ if (getword(user,sizeof(user),&gwarea,' ')<0) {
+ debuga(_("Invalid user found in your dansguardian log file %s\n"),loglocation);
+ exit(EXIT_FAILURE);
+ }
+ if (getword(ip,sizeof(ip),&gwarea,' ')<0) {
+ debuga(_("Invalid IP address found in your dansguardian log file %s\n"),loglocation);
+ exit(EXIT_FAILURE);
+ }
+ if (getword_skip(MAXLEN,&gwarea,'/')<0 || getword_skip(MAXLEN,&gwarea,'/')<0) {
debuga(_("Maybe you have a broken record or garbage in your %s file\n"),loglocation);
exit(EXIT_FAILURE);
}
strcpy(user,ip);
ip[0]='\0';
}
- fprintf(fp_ou,"%s\t%d\t%s\t%s\t%s\t%s\t%s\n",user,idata,hour,ip,url,code1,code2);
+ fprintf(fp_ou,"%s\t%d\t%02d:%s\t%s\t%s\t%s\t%s\n",user,idata,hour,minsec,ip,url,code1,code2);
dansguardian_count++;
}