From: Frédéric Marchal Date: Sat, 10 Mar 2012 14:37:11 +0000 (+0100) Subject: Deal with url without scheme or path in a squidGuard log X-Git-Tag: v2.3.3-pre1~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d19124ace7ef034648b5e5d231082c2c014c7d30;p=thirdparty%2Fsarg.git Deal with url without scheme or path in a squidGuard log Some url in a squidGuard log don't start with a scheme:// and may not even contain a path. Those bare minimum url are not parsed correctly by the redirector_log_format suggested in sarg.conf. To parse those log entries correctly, we grab the whole url in the buffer and strip it down to keep the host name. --- diff --git a/redirector.c b/redirector.c index 81a0de7..1fd6339 100644 --- a/redirector.c +++ b/redirector.c @@ -124,12 +124,11 @@ static void parse_log(FILE *fp_ou,char *buf) } strcpy(user,res); } else if(strcmp(leks,"url") == 0) { - if (strlen(res)>=sizeof(full_url)) { - debuga(_("URL too long in redirector log file %s\n"),wentp); - RedirectorErrors++; - return; - } - strcpy(full_url,res); + /* + * Don't worry about the url being truncated as we only keep the host name + * any way... + */ + safe_strcpy(full_url,res,sizeof(full_url)); } } } diff --git a/sarg.conf b/sarg.conf index 30a0e45..a405476 100644 --- a/sarg.conf +++ b/sarg.conf @@ -549,8 +549,8 @@ # Format string for web proxy redirector logs. # This option was named squidguard_log_format before sarg 2.3. # REJIK #year#-#mon#-#day# #hour# #list#:#tmp# #ip# #user# #tmp#/#tmp#/#url#/#end# -# SQUIDGUARD #year#-#mon#-#day# #hour# #tmp#/#list#/#tmp#/#tmp#/#url#/#tmp# #ip#/#tmp# #user# #end# -#redirector_log_format #year#-#mon#-#day# #hour# #tmp#/#list#/#tmp#/#tmp#/#url#/#tmp# #ip#/#tmp# #user# #end# +# SQUIDGUARD #year#-#mon#-#day# #hour# #tmp#/#list#/#tmp# #url# #ip#/#tmp# #user# #end# +#redirector_log_format #year#-#mon#-#day# #hour# #tmp#/#list#/#tmp# #url# #ip#/#tmp# #user# #end# # TAG: show_sarg_info yes|no # shows sarg information and site path on each report bottom