]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Ported r150 from branches/v2_2_6_1 (useragent report statistics)
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Thu, 10 Dec 2009 12:29:17 +0000 (12:29 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Thu, 10 Dec 2009 12:29:17 +0000 (12:29 +0000)
ChangeLog
configure
configure.in
useragent.c

index e3417d637528cd9a2a127bafbaa228a1cbb75eb9..b3e02fadd97cf136d20c8ada4d69f5f262fca4f2 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -9,8 +9,10 @@ Dec-03-2009 Version 2.2.7
 Dec-09-2009 Version 2.2.6.1
                - Remove unecessary dependency on off_t.
                - Configuration doesn't fail if rlim_t is not available.
-               - Test for the availability of -Werror=xxx flags in gcc.
+               - Test for the availability of -Werror=implicit-function-declaration and -Werror=format flags in gcc (thanks to Murilo Moreira de Oliveira and pjetko).
                - Fix sort delimiter when reading useragent log (thanks to Maxim Britov).
+               - Fix user agent report font size and statistics on user agent.
+               - Test for the availability of -Werror=format-security in gcc (thanks to Maxim Britov).
 
 Oct-14-2009 Version 2.2.6
                - Protection against buffer overflows in getword and friends and report the origin of the error instead of always blaming access.log.
index a24ce981ebe2b8ae2d715c98cdf208819141498f..8659a5dfe3be3621ead88f5d69f13867ac3c826e 100755 (executable)
--- a/configure
+++ b/configure
@@ -6126,7 +6126,51 @@ echo "using $IMAGEDIR as the directory of the images"
 if test "${enable_extraprotection+set}" = set; then
   enableval=$enable_extraprotection;
     if test "$enableval"; then
-       CFLAGS="${CFLAGS} -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=2 -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter"
+       CFLAGS="${CFLAGS} -fstack-protector -D_FORTIFY_SOURCE=2 -Werror"
+
+       { echo "$as_me:$LINENO: checking for format security flag in gcc" >&5
+echo $ECHO_N "checking for format security flag in gcc... $ECHO_C" >&6; }
+       saved_CFLAGS="${CFLAGS}"
+       CFLAGS="${CFLAGS}  -Werror=format-security"
+       cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  have_format_security="yes"
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       have_format_security="no"
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       { echo "$as_me:$LINENO: result: have_format_security" >&5
+echo "${ECHO_T}have_format_security" >&6; }
+       if test "$have_format_security" == "no" ; then
+          CFLAGS="${saved_CFLAGS}"
+       fi
     fi
 
 fi
index c779b315c236f3d00dff60831b2a9ea6a1dc8c9a..06f2ac8b123a746c0007afe1b75f56f5844c6700 100644 (file)
@@ -163,7 +163,16 @@ AC_ARG_ENABLE(extraprotection,
                         Enable compile and runtime extra protections ],
 [
     if test "$enableval"; then
-       CFLAGS="${CFLAGS} -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=2 -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter"
+       CFLAGS="${CFLAGS} -fstack-protector -D_FORTIFY_SOURCE=2 -Werror"
+
+       AC_MSG_CHECKING([for format security flag in gcc])
+       saved_CFLAGS="${CFLAGS}"
+       CFLAGS="${CFLAGS}  -Werror=format-security"
+       AC_COMPILE_IFELSE([AC_LANG_SOURCE([])],[have_format_security="yes"],[have_format_security="no"])
+       AC_MSG_RESULT(have_format_security)
+       if test "$have_format_security" == "no" ; then
+          CFLAGS="${saved_CFLAGS}"
+       fi
     fi
 ])
 
index 4bb6456145393df19124630bbcc6516f72d816c8..c4d1ef8447d2ef209376b17a72ca053283ea0c6a 100644 (file)
@@ -37,7 +37,7 @@ void useragent(void)
    char agent_old[MAXLEN]="$#%0a3bc6";
    char hfile[MAXLEN];
    char idate[MAXLEN], fdate[MAXLEN];
-   int  agentot=0, agentot2=0, agentdif=0, cont=0;
+   int  agentot=0, agentot2=0, agentdif=0, cont=0, nagent;
    unsigned long totregsl=0;
    int cstatus;
    char ftime[128];
@@ -98,7 +98,7 @@ void useragent(void)
       if(strlen(user) == 0)
          strcpy(user,ip);
 
-      fprintf(fp_ou,"%s\t%s\t%s\t%s\n",ip,data,agent,user);
+      fprintf(fp_ou,"%s\t%s\t%s\n",ip,agent,user);
       user[0]='\0';
    }
 
@@ -111,15 +111,11 @@ void useragent(void)
    fclose(fp_in);
    fclose(fp_ou);
 
-   if (fp_ht) {
-      fclose(fp_ht);
-   }
-
    if(debug) {
       debuga("%s: %s",text[54],tmp2);
    }
 
-   sprintf(csort,"sort -n -t \"\t\" -k 4,4 -k 3,3 -k 2,2 -k 1,1 -o \"%s\" \"%s\"",tmp2,tmp3);
+   sprintf(csort,"sort -n -t \"\t\" -k 3,3 -k 2,2 -k 1,1 -o \"%s\" \"%s\"",tmp2,tmp3);
    cstatus=system(csort);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
@@ -184,7 +180,7 @@ void useragent(void)
          } else strcpy(ip,namebefore);
       }
 
-      if (getword(data,sizeof(data),buf,'\t')<0 || getword(agent,sizeof(agent),buf,'\t')<0 ||
+      if (getword(agent,sizeof(agent),buf,'\t')<0 ||
           getword(user,sizeof(user),buf,'\t')<0) {
          printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",tmp2);
          exit(1);
@@ -206,7 +202,7 @@ void useragent(void)
    fclose(fp_in);
    fclose(fp_ou);
 
-   sprintf(csort,"sort -n -t \"\t\" -k 3,3 -o \"%s\" \"%s\"",tmp3,tmp2);
+   sprintf(csort,"sort -t \"\t\" -k 2,2 -o \"%s\" \"%s\"",tmp3,tmp2);
    cstatus=system(csort);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
@@ -227,9 +223,10 @@ void useragent(void)
    }
 
    agent_old[0]='\0';
+   cont=0;
 
    while(fgets(buf,sizeof(buf),fp_in)!=NULL) {
-      if (getword(ip,sizeof(ip),buf,'\t')<0 || getword(data,sizeof(data),buf,'\t')<0 ||
+      if (getword(ip,sizeof(ip),buf,'\t')<0 ||
           getword(agent,sizeof(agent),buf,'\t')<0) {
          printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",tmp);
          exit(1);
@@ -240,15 +237,14 @@ void useragent(void)
          strcpy(agent_old,agent);
       }
 
-      agentot++;
-
       if(strcmp(agent,agent_old) != 0) {
          agentdif++;
          fprintf(fp_ou,"%06d %s\n",agentot,agent_old);
          strcpy(agent_old,agent);
          agentot2+=agentot;
-         agentot=1;
+         agentot=0;
       }
+      agentot++;
    }
    agentdif++;
    fprintf(fp_ou,"%06d %s\n",agentot,agent);
@@ -284,16 +280,20 @@ void useragent(void)
    fputs("<div align=\"center\"><table cellpadding=\"0\" cellspacing=\"0\">\n",fp_ht);
    fprintf(fp_ht,"<tr><th align=\"left\" bgcolor=\"%s\"><font color=\"%s\">%s</font></th><th bgcolor=\"%s\" align=\"left\"><font color=\"%s\">%s</font></th><th align=\"center\" bgcolor=\"%s\"><font color=\"%s\">%%</font></th></tr>\n",HeaderBgColor,HeaderColor,text[106],HeaderBgColor,HeaderColor,text[107],HeaderBgColor,HeaderColor);
 
+   perc=0.;
    while(fgets(buf,sizeof(buf),fp_in)!=NULL) {
       fixendofline(buf);
       if (getword(tagent,sizeof(tagent),buf,' ')<0) {
          printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",tmp);
          exit(1);
       }
-      perc=atoi(tagent) * 100;
-      perc=perc / agentot2;
+      nagent=atoi(tagent);
+      if(agentot2>0) {
+         perc=nagent * 100;
+         perc=perc / agentot2;
+      }
 
-      fprintf(fp_ht,"<tr><td align=\"left\" bgcolor=\"%s\">%s</td><td align=\"right\" bgcolor=\"%s\">%d</td><td align=\"right\" bgcolor=\"%s\">%3.2f</td></tr>\n",TxBgColor,buf,TxBgColor,atoi(tagent),TxBgColor,perc);
+      fprintf(fp_ht,"<tr><td align=\"left\" bgcolor=\"%s\">%s</td><td align=\"right\" bgcolor=\"%s\">%d</td><td align=\"right\" bgcolor=\"%s\">%3.2f</td></tr>\n",TxBgColor,buf,TxBgColor,nagent,TxBgColor,perc);
    }
 
    fputs("</table></html>\n",fp_ht);