]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Deal with url without scheme or path in a squidGuard log
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Sat, 10 Mar 2012 14:37:11 +0000 (15:37 +0100)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Sat, 10 Mar 2012 14:37:11 +0000 (15:37 +0100)
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
sarg.conf

index 81a0de758e568d90b166f1e1e950bf1b4d345093..1fd63393534abbeba3e47326a548165a578f8ac9 100644 (file)
@@ -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));
                                }
                        }
                }
index 30a0e457d7a13c89a42c214e237b6682ea39aef1..a405476bbdcf896a5bc2613c3641efefda162d4a 100644 (file)
--- a/sarg.conf
+++ b/sarg.conf
 #      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