From d19124ace7ef034648b5e5d231082c2c014c7d30 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Marchal?= Date: Sat, 10 Mar 2012 15:37:11 +0100 Subject: [PATCH] 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. --- redirector.c | 11 +++++------ sarg.conf | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) 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 -- 2.47.2