]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Don't abort if "onload" or "script" is found in the user agent string.
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Wed, 14 Jul 2010 05:48:00 +0000 (05:48 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Wed, 14 Jul 2010 05:48:00 +0000 (05:48 +0000)
CMakeLists.txt
ChangeLog
configure.in
email.c
include/info.h
useragent.c

index de5081ff6bdd503fc4038d02da4c7f1da748e3bb..dc7cbe2b56da52b3c24f6ae750138d668b6d01c9 100755 (executable)
@@ -1,9 +1,9 @@
 CMAKE_MINIMUM_REQUIRED (VERSION 2.6)
 PROJECT(sarg C)
 SET(sarg_VERSION 2)
-SET(sarg_REVISION "3")
+SET(sarg_REVISION "3.1-pre1")
 SET(sarg_BUILD "")
-SET(sarg_BUILDDATE "Jun-21-2010")
+SET(sarg_BUILDDATE "Jul-14-2010")
 
 INCLUDE(AddFileDependencies)
 INCLUDE(CheckIncludeFile)
index 99ac52198bbecab687ddd82ac503a2c916c78188..f1c281b57a2b4c4f2243397e1ec9d9bd3239134a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,10 @@
 SARG ChangeLog
 
-Jun-21-2009 Version 2.3
+Jul-14-2010 Version 2.3.1
+               - Remove the distinct printf for the alpha architecture as it doesn't work anymore and is not necessary anyway.
+               - Don't abort if "onload" or "script" is found in the user agent string.
+
+Jun-21-2010 Version 2.3
                - LDAP usertab added. 
                  Now you can have your users in a LDAP Server.
                  Use these tags in sarg.conf: LDAPHost, LDAPPort, LDAPBindDN, LDAPBindPW,
index 11b919c3b26eddb738bd37556bf56554e614c333..b858008a6e17192d5460d273bca551bf1e976815 100644 (file)
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT([sarg],[2.3])
+AC_INIT([sarg],[2.3.1-pre1])
 AC_CONFIG_SRCDIR([log.c])
 AC_CONFIG_AUX_DIR(cfgaux)
 
diff --git a/email.c b/email.c
index 6e54850d8afc7e5343ed741eb1c2f59b4565af27..63a77f3b5ea520a4aa85cdb194c43127550d7c21 100644 (file)
--- a/email.c
+++ b/email.c
@@ -80,8 +80,6 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
          if (olduser[0] != '\0') {
 #if defined(__FreeBSD__)
             fprintf(fp_top2,"%s\t%qu\t%qu\t%qu\n",olduser,tnbytes,tnacc,tnelap);
-#elif defined(__alpha) || __ALPHA
-            fprintf(fp_top2,"%s\t%ld\t%ld\t%ld\n",olduser,tnbytes,tnacc,tnelap);
 #else
             fprintf(fp_top2,"%s\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\n",olduser,(uint64_t)tnbytes,(uint64_t)tnacc,(uint64_t)tnelap);
 #endif
@@ -103,8 +101,6 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
    if (olduser[0] != '\0') {
 #if defined(__FreeBSD__)
       fprintf(fp_top2,"%s\t%qu\t%qu\t%qu\n",olduser,tnbytes,tnacc,tnelap);
-#elif defined(__alpha) || __ALPHA
-      fprintf(fp_top2,"%s\t%ld\t%ld\t%ld\n",olduser,tnbytes,tnacc,tnelap);
 #else
       fprintf(fp_top2,"%s\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\n",olduser,(uint64_t)tnbytes,(uint64_t)tnacc,(uint64_t)tnelap);
 #endif
@@ -132,8 +128,6 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
    }
 #if defined(__FreeBSD__)
    fprintf(fp_top1,"TOTAL\t%qu\t%qu\t%qu\n",ttnbytes,ttnacc,ttnelap);
-#elif defined(__alpha) || __ALPHA
-   fprintf(fp_top1,"TOTAL\t%ld\t%ld\t%ld\n",ttnbytes,ttnacc,ttnelap);
 #else
    fprintf(fp_top1,"TOTAL\t%"PRIu64"\t%"PRIu64"\t%"PRIu64"\n",(uint64_t)ttnbytes,(uint64_t)ttnacc,(uint64_t)ttnelap);
 #endif
@@ -208,16 +202,12 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
          fputs("------- -------------------- -------- --------------- ------- ---------- ---------- -------\n",fp_top3);
 #if defined(__FreeBSD__)
          fprintf(fp_top3,"%-7s %20s %8qu %15s %8s %9s %10qu\n",_("TOTAL")," ",ttnacc,fixnum(ttnbytes,1)," ",buildtime(ttnelap),ttnelap);
-#elif defined(__alpha) || __ALPHA
-         fprintf(fp_top3,"%-7s %20s %8ld %15s %8s %9s %10ld\n",_("TOTAL")," ",ttnacc,fixnum(ttnbytes,1)," ",buildtime(ttnelap),ttnelap);
 #else
          fprintf(fp_top3,"%-7s %20s %8"PRIu64" %15s %8s %9s %10"PRIu64"\n",_("TOTAL")," ",(uint64_t)ttnacc,fixnum(ttnbytes,1)," ",buildtime(ttnelap),(uint64_t)ttnelap);
 #endif
       } else {
 #if defined(__FreeBSD__)
          fprintf(fp_top3,"%7d %20s %8lld %15s %3.2lf%% %10s %10qu %3.2lf%%\n",posicao,user,nacc,fixnum(nbytes,1),perc,buildtime(elap),elap,perc2);
-#elif defined(__alpha) || __ALPHA
-         fprintf(fp_top3,"%7d %20s %8lld %15s %3.2lf%% %10s %10ld %3.2lf%%\n",posicao,user,nacc,fixnum(nbytes,1),perc,buildtime(elap),elap,perc2);
 #else
          fprintf(fp_top3,"%7d %20s %8"PRIu64" %15s %3.2lf%% %10s %10"PRIu64" %3.2lf%%\n",posicao,user,(uint64_t)nacc,fixnum(nbytes,1),perc,buildtime(elap),(uint64_t)elap,perc2);
 #endif
@@ -238,8 +228,6 @@ int geramail(const char *dirname, int debug, const char *outdir, const char *ema
    strip_latin(strip1);
 #if defined(__FreeBSD__)
    fprintf(fp_top3,"%-7s %20s %8qu %15s %8s %9s %10qu\n",strip1," ",avgacc,fixnum(tnbytes,1)," ",buildtime(avgelap),avgelap);
-#elif defined(__alpha) || __ALPHA
-   fprintf(fp_top3,"%-7s %20s %8ld %15s %8s %9s %10ld\n",strip1," ",avgacc,fixnum(tnbytes,1)," ",buildtime(avgelap),avgelap);
 #else
    fprintf(fp_top3,"%-7s %20s %8"PRIu64" %15s %8s %9s %10"PRIu64"\n",strip1," ",(uint64_t)avgacc,fixnum(tnbytes,1)," ",buildtime(avgelap),(uint64_t)avgelap);
 #endif
index 6bd4ba78304ffd861a8e7c920f2e67c18fa07d32..c4021c4f99dee2eae9c20f8f98649768aa4a674d 100755 (executable)
@@ -1,3 +1,3 @@
-#define VERSION PACKAGE_VERSION" Jun-21-2010"
+#define VERSION PACKAGE_VERSION" Jul-14-2010"
 #define PGM PACKAGE_NAME
 #define URL "http://sarg.sourceforge.net"
index b47bfced4973bb79718839403f720e9738f1a789..492fa8af5c3c74d500f6df959bceb528ef7cc1e6 100644 (file)
@@ -59,8 +59,8 @@ void useragent(void)
    ipbefore[0]='\0';
    namebefore[0]='\0';
 
-   sprintf(tmp3,"%s/squagent.unsort",TempDir);
-   sprintf(tmp2,"%s/squagent.log",TempDir);
+   sprintf(tmp3,"%s/sarg/squagent.unsort",TempDir);
+   sprintf(tmp2,"%s/sarg/squagent.log",TempDir);
 
    if((fp_in=fopen(UserAgentLog,"r"))==NULL) {
       debuga(_("(useragent) Cannot open file %s\n"),UserAgentLog);
@@ -101,25 +101,21 @@ void useragent(void)
          debuga(_("Maybe you have a broken useragent entry in your %s file\n"),UserAgentLog);
          exit(EXIT_FAILURE);
       }
-      strcpy(warea,agent);
-      strup(warea);
-      if(strstr(warea,"SCRIPT") != 0 || strstr(warea,"ONLOAD") != 0)
-         baddata();
 
       if(gwarea.current[0]!='\0') {
          if (getword_skip(MAXLEN,&gwarea,' ')<0 || getword(user,sizeof(user),&gwarea,'\n')<0) {
             debuga(_("Maybe you have a broken record or garbage in your %s file\n"),UserAgentLog);
             exit(EXIT_FAILURE);
          }
-      }
-
-      if(user[0] == '-')
-         strcpy(user,ip);
-      if(user[0] == '\0')
+         if(user[0] == '-')
+            strcpy(user,ip);
+         if(user[0] == '\0')
+            strcpy(user,ip);
+      } else {
          strcpy(user,ip);
+      }
 
       fprintf(fp_ou,"%s\t%s\t%s\n",ip,agent,user);
-      user[0]='\0';
       useragent_count++;
    }
 
@@ -128,7 +124,10 @@ void useragent(void)
    }
 
    fclose(fp_in);
-   fclose(fp_ou);
+   if (fclose(fp_ou)==EOF) {
+      debuga(_("Failed to close file %s - %s\n"),tmp3,strerror(errno));
+      exit(EXIT_FAILURE);
+   }
 
    if(debug) {
       debuga(_("Sorting file: %s\n"),tmp2);
@@ -195,14 +194,16 @@ void useragent(void)
       }
 
       if(strcmp(user,user_old) != 0) {
-         fprintf(fp_ht,"<tr><td class=\"data2\">%s</td><td class=\"data2\">%s</td></tr>\n",user,agent);
+         fprintf(fp_ht,"<tr><td class=\"data2\">%s</td><td class=\"data2\">",user);
+         output_html_string(fp_ht,agent,250);
+         fputs("</td></tr>\n",fp_ht);
          strcpy(user_old,user);
          strcpy(agent_old,agent);
-      } else {
-         if(strcmp(agent,agent_old) != 0) {
-            fprintf(fp_ht,"<tr><td></td><td class=\"data2\">%s</td></tr>\n",agent);
-            strcpy(agent_old,agent);
-         }
+      } else if(strcmp(agent,agent_old) != 0) {
+         fputs("<tr><td></td><td class=\"data2\">",fp_ht);
+         output_html_string(fp_ht,agent,250);
+         fputs("</td></tr>\n",fp_ht);
+         strcpy(agent_old,agent);
       }
    }
 
@@ -235,11 +236,11 @@ void useragent(void)
    while(fgets(buf,sizeof(buf),fp_in)!=NULL) {
       getword_start(&gwarea,buf);
       if (getword(ip,sizeof(ip),&gwarea,'\t')<0) {
-         debuga(_("There is an invalid IP address in file %s\n"),tmp);
+         debuga(_("There is an invalid IP address in file %s\n"),tmp3);
          exit(EXIT_FAILURE);
       }
       if (getword(agent,sizeof(agent),&gwarea,'\t')<0) {
-         debuga(_("There is an invalid useragent in file %s\n"),tmp);
+         debuga(_("There is an invalid useragent in file %s\n"),tmp3);
          exit(EXIT_FAILURE);
       }
 
@@ -262,7 +263,10 @@ void useragent(void)
    agentot2+=agentot;
 
    fclose(fp_in);
-   fclose(fp_ou);
+   if (fclose(fp_ou)==EOF) {
+      debuga(_("Failed to close file %s - %s\n"),tmp3,strerror(errno));
+      exit(EXIT_FAILURE);
+   }
 
    unlink(tmp3);
 
@@ -291,13 +295,15 @@ void useragent(void)
       fixendofline(buf);
       getword_start(&gwarea,buf);
       if (getword(tagent,sizeof(tagent),&gwarea,' ')<0) {
-         debuga(_("There is an invalid useragent in file %s\n"),tmp);
+         debuga(_("There is an invalid useragent in file %s\n"),tmp3);
          exit(EXIT_FAILURE);
       }
       nagent=atoi(tagent);
       perc=(agentot2>0) ? nagent * 100. / agentot2 : 0.;
 
-      fprintf(fp_ht,"<tr><td class=\"data2\">%s</td><td class=\"data\">%d</td><td class=\"data\">%3.2lf</td></tr>\n",gwarea.current,nagent,perc);
+      fputs("<tr><td class=\"data2\">",fp_ht);
+      output_html_string(fp_ht,gwarea.current,250);
+      fprintf(fp_ht,"</td><td class=\"data\">%d</td><td class=\"data\">%3.2lf</td></tr>\n",nagent,perc);
    }
    fclose(fp_in);