]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Adjustments to run sarg on windows outside of msys.
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Wed, 30 Sep 2009 14:41:05 +0000 (14:41 +0000)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Wed, 30 Sep 2009 14:41:05 +0000 (14:41 +0000)
21 files changed:
CMakeLists.txt
README_cmake
authfail.c
dansguardian_log.c
email.c
grepday.c
html.c
include/info.h
index.c
lastlog.c
log.c
realtime.c
siteuser.c
smartfilter.c
sort.c
squidguard_log.c
topsites.c
topuser.c
totday.c
useragent.c
util.c

index 84e4980db84c0c1935f48923d055cba7a26151e8..46e40b80219267bf8a93120022447309624b69ba 100755 (executable)
@@ -3,7 +3,7 @@ PROJECT(sarg C)
 SET(sarg_VERSION 2)
 SET(sarg_REVISION 2)
 SET(sarg_BUILD "6rc1")
-SET(sarg_BUILDDATE "Sep-24-2009")
+SET(sarg_BUILDDATE "Sep-30-2009")
 
 INCLUDE(AddFileDependencies)
 INCLUDE(CheckIncludeFile)
@@ -95,7 +95,7 @@ IF(HAVE_GD_H)
    CHECK_INCLUDE_FILE(gdfonts.h HAVE_GDFONTS_H)
    CHECK_INCLUDE_FILE(gdfontmb.h HAVE_GDFONTMB_H)
    CHECK_INCLUDE_FILE(gdfontg.h HAVE_GDFONTG_H)
-   FIND_LIBRARY(GD_LIBRARY NAMES gd PATHS /usr/lib /usr/local/lib DOC "The GD library")
+   FIND_LIBRARY(GD_LIBRARY NAMES gd DOC "The GD library")
    IF(GD_LIBRARY)
       #CHECK_LIBRARY_EXISTS(gd gdImagePng "." HAVE_GD)
       TARGET_LINK_LIBRARIES(sarg gd)
@@ -111,8 +111,8 @@ IF(ENABLE_ICONV)
    IF(HAVE_ICONV_H)
       CHECK_FUNCTION_EXISTS(iconv_open HAVE_ICONV)
       IF(!HAVE_ICONV)
-         FIND_PATH(ICONV_INCLUDE_PATH NAMES iconv.h PATHS /usr/include /usr/local/include)
-         FIND_LIBRARY(ICONV_LIBRARY NAMES iconv PATHS /lib /usr/lib /usr/local/lib DOC "The ICONV library")
+         FIND_PATH(ICONV_INCLUDE_PATH NAMES iconv.h)
+         FIND_LIBRARY(ICONV_LIBRARY NAMES iconv DOC "The ICONV library")
       ENDIF(!HAVE_ICONV)
 
       SET(ICONV_CONST_FILE ${CMAKE_BINARY_DIR}/consticonv.c)
@@ -220,7 +220,7 @@ ENDIF(HAVE_RLIM_T)
 IF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
    CHECK_INCLUDE_FILE(windows.h HAVE_WINDOWS_H)
    CHECK_INCLUDE_FILE(winsock.h HAVE_WINSOCK_H)
-   FIND_LIBRARY(WSOCK_LIB NAMES wsock32 PATHS /usr/lib /usr/local/lib DOC "The winsock library")
+   FIND_LIBRARY(WSOCK_LIB NAMES wsock32 DOC "The winsock library")
    #check_library_exists(wsock32 "." HAVE_WSOCK)
    IF(WSOCK_LIB)
       #set_target_properties(sarg PROPERTIES LINK_FLAGS "${LINK_FLAGS} -lwsock32")
@@ -232,7 +232,7 @@ ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
 CHECK_FUNCTION_EXISTS(mkstemp HAVE_MKSTEMP)
 IF(NOT HAVE_MKSTEMP)
    # MingW provide mkstemps in libiberty but doesn't declare it in any header file
-   FIND_LIBRARY(IBERTY_LIB NAMES iberty PATHS /mingw/lib DOC "The library of mingw containing mkstemps")
+   FIND_LIBRARY(IBERTY_LIB NAMES iberty DOC "The library of mingw containing mkstemps")
    IF(IBERTY_LIB)
       TARGET_LINK_LIBRARIES(sarg iberty)
    ENDIF(IBERTY_LIB)
index 1096597a1266b735f4b0ef956a619cfaeee31ad2..be78a18687ed0781d9faaf4c1d55da4295dcf9e4 100644 (file)
@@ -13,6 +13,8 @@ with cmake and I'm sure it is done in an definitely autotoolistic way.
 Any comment about the usage of cmake is welcome.
 
 
+
+
 CONFIGURING SARG
 
 It is recommended to build sarg out of the source directory. It makes it easier
@@ -54,6 +56,8 @@ Install with
  make install
 
 
+
+
 CONFIGURATION VARIABLES
 
 These configuration variables are available on the first configuration run.
@@ -99,3 +103,103 @@ available on the second run.
 They are other configuration variables whose documentation is visible during the
 configuration with ccmake.
 
+
+
+
+COMPILATION WITH MSYS+MINGW
+
+The autotools don't compile sarg with msys. You have to use cmake in an msys
+terminal.
+
+If cmake is not already installed on your system, download and uncompress the
+cmake sources in your home directory then run the following commands in an msys
+terminal:
+
+ configure
+ make
+ make install
+
+Permanently add the path to cmake.exe by appending this line at the end of your
+profile file (c:/msys/1.0/etc/profile):
+
+ export PATH="$PATH:/c/Program files/CMake/bin"
+
+Reopen the msys terminal or run the above command in the same terminal to
+register the new path.
+
+Get the sources of sarg and uncompress them in your home directory. Let's assume
+they are in a directory named "sarg".
+
+Create a separate directory at the same level as the sources of sarg and change
+to that directory. For instance, assuming your prompt is in the sarg directory,
+run the following commands:
+
+ mkdir ../bin
+ cd ../bin
+
+Configure, compile and install sarg:
+
+ cmake ../sarg -G "MSYS Makefiles"
+ make
+ make install
+
+This will compile sarg outside of the sources and install it in c:\Program
+Files\sarg.
+
+If the compilation fails because mkstemp cannot be found, ensure that the LIB
+and INCLUDE environment variables are set properly to the lib and include
+directories of mingw. For instance, type the following two commands and run make
+again:
+
+ export LIB=c:/mingw/lib
+ export INCLUDE=c:/mingw/include
+
+You can make them permanent by appending those two commands at the end of the
+profile file in c:/msys/1.0/etc/profile.
+
+
+
+
+CONFIGURING SARG TO RUN ON WINDOWS
+
+Cmake install a sample configuration file in c:/Program
+Files/sarg/etc/sarg/sarg.conf.exemple. Rename it as sarg.conf and edit it.
+
+You must change the following options:
+
+ access_log c:/Program Files/sarg/log/access.log
+ temporary_dir c:/Program Files/sarg/tmp
+ output_dir c:/Program Files/sarg/www/squid-reports
+
+Adjust and create the directories according to your configuration.
+
+You may have to adjust other options to suit your needs.
+
+If sarg complains about a missing rm or sort command, then you have to install
+the unxtools or run sarg from msys.
+
+If you want to run sarg from a regular dos prompt, download UnxUtils.zip from
+http://unxutils.sourceforge.net/ and uncompress it somewhere. Change the system
+path to include the usr\local\wbin directory before the Windows system
+directory.
+
+You must be sure that the unxutils are found before the windows native commands.
+To check this, open a dos prompt and type
+
+ls
+
+If it list the content of the directory, then the unxutils are found. Then type
+
+sort --help
+
+It should display the help of the sort command if the unxutils command is found
+first. If the windows command is found first, it will complain that the --help
+file cannot be found.
+
+Finally, if sort complains that it cannot write in the /tmp directory, either
+create that directory or set TMPDIR like this:
+
+ set TMPDIR=c:/Program Files/sarg/tmp
+
+It may be set to your TMP or TEMP directory or the temporary directory you named
+in your sarg.conf file.
index 5a00a08601fae0f8cfe9ea4561de0838f9f6558d..c7fe5b031d3401ce4f7437acd43f8c033a8b8fc7 100644 (file)
@@ -70,7 +70,7 @@ void authfail_report(void)
    fgets(period,sizeof(period),fp_in);
    fclose(fp_in);
 
-   sprintf(csort,"sort -b -T '%s' -k 3,3 -k 5,5 -o '%s' '%s'", TempDir, authfail_in, tmp4);
+   sprintf(csort,"sort -b -T \"%s\" -k 3,3 -k 5,5 -o \"%s\" \"%s\"", TempDir, authfail_in, tmp4);
    cstatus=system(csort);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
index bd913f3e9c9229eb5b48fd2bb0dbf55dc96ae737..1b6cbce229296f243dc7660c8a1b3ca4d0dc699e 100644 (file)
@@ -154,7 +154,7 @@ void dansguardian_log(void)
    if(debug)
       debuga("%s: %s",text[54],guard_ou);
 
-   sprintf(tmp6,"sort -k 1,1 -k 2,2 -k 4,4 '%s' -o '%s'",guard_in, guard_ou);
+   sprintf(tmp6,"sort -k 1,1 -k 2,2 -k 4,4 \"%s\" -o \"%s\"",guard_in, guard_ou);
    cstatus=system(tmp6);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
diff --git a/email.c b/email.c
index 848d40b32b076f66688fadb653bf87880413dc24..c8d03f1e5dc2b9ac49b6fc95b809cb562792d762 100644 (file)
--- a/email.c
+++ b/email.c
@@ -164,7 +164,7 @@ int geramail(const char *dirname, int debug, const char *outdir, int userip, con
    fclose(fp_in);
    fclose(fp_top2);
 
-   sprintf(csort,"sort -n -T '%s' -r -k 2,2 -o '%s' '%s'", TempDir, top1, top2);
+   sprintf(csort,"sort -n -T \"%s\" -r -k 2,2 -o \"%s\" \"%s\"", TempDir, top1, top2);
    cstatus=system(csort);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
@@ -344,7 +344,7 @@ int geramail(const char *dirname, int debug, const char *outdir, int userip, con
       }
     }
 
-   sprintf(csort,"rm -rf '%s/sarg'",TempDir);
+   sprintf(csort,"rm -rf \"%s/sarg\"",TempDir);
    system(csort);
 
    return (0);
index 95075d32ee82965850f29ae417ac282286d723fd..543c6bf2461733eb8e2eb3709e0b38f885ba46d3 100644 (file)
--- a/grepday.c
+++ b/grepday.c
@@ -391,9 +391,9 @@ void greport_day(const char *user)
    if(access(wdirname, R_OK) != 0)
       return;
 
-   sprintf(csort,"sort -t'/' -k 2,2 -o '%s' '%s'",tmp5,wdirname);
+   sprintf(csort,"sort -t\"/\" -k 2,2 -o \"%s\" \"%s\"",tmp5,wdirname);
    if(strcmp(DateFormat,"e") == 0)
-      sprintf(csort,"sort -t'/' -k 1,1 -o '%s' '%s'",tmp5,wdirname);
+      sprintf(csort,"sort -t\"/\" -k 1,1 -o \"%s\" \"%s\"",tmp5,wdirname);
 
    cstatus=system(csort);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
diff --git a/html.c b/html.c
index 0177d1f8b3fc7be3bd3d4ff8cea68a063790ca10..8376391e49d079e82e268b25d372a2c9dbe9087e 100644 (file)
--- a/html.c
+++ b/html.c
@@ -462,7 +462,7 @@ void htmlrel(void)
             fclose(fp_ip);
             fclose(fp_ip2);
 
-            sprintf(csort,"sort -n -T '%s' -k 1,1 -k 5,5 -o '%s' '%s'",TempDir,tmp3,tmp2);
+            sprintf(csort,"sort -n -T \"%s\" -k 1,1 -k 5,5 -o \"%s\" \"%s\"",TempDir,tmp3,tmp2);
             cstatus=system(csort);
             if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
                fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
index a6ec0a4124cec5b3a1807519768b3783ffe400c4..2ae2dd8502ef4ca0b0008f80d2a7704bfb3acf11 100755 (executable)
@@ -1,3 +1,3 @@
-#define VERSION PACKAGE_VERSION" Sep-24-2009"
+#define VERSION PACKAGE_VERSION" Sep-30-2009"
 #define PGM PACKAGE_NAME
 #define URL "http://sarg.sourceforge.net"
diff --git a/index.c b/index.c
index d855262b87108ec2b5926736ce93b49a54536b71..e7d5eba731f2c448eb3bbf2d6a96af9421d63473 100644 (file)
--- a/index.c
+++ b/index.c
@@ -109,7 +109,7 @@ void make_index(void)
          rename(val4,val3);
          sprintf(val5,"%s/images",val2);
          if(access(val5, R_OK) != 0) {
-            sprintf(val5,"ln -s '%simages' '%s/images'",outdir,val2);
+            sprintf(val5,"ln -s \"%simages\" \"%s/images\"",outdir,val2);
             cstatus=system(val5);
             if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
                fprintf(stderr, "SARG: command return status %d\n",WEXITSTATUS(cstatus));
@@ -252,8 +252,8 @@ void make_index(void)
    }
 
    if(strcmp(IndexTree,"date") == 0) {
-      if(strcmp(IndexSortOrder,"A") == 0) sprintf(warea,"sort -k 1,1 '%s' -o '%s'", wdir_tmp, wdir_tmp2);
-      else sprintf(warea,"sort -r -k 1,1 '%s' -o '%s'", wdir_tmp, wdir_tmp2);
+      if(strcmp(IndexSortOrder,"A") == 0) sprintf(warea,"sort -k 1,1 \"%s\" -o \"%s\"", wdir_tmp, wdir_tmp2);
+      else sprintf(warea,"sort -r -k 1,1 \"%s\" -o \"%s\"", wdir_tmp, wdir_tmp2);
       cstatus=system(warea);
       if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
          fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
@@ -294,8 +294,8 @@ void make_index(void)
          (void)rewinddir(dirp2);
          (void)closedir(dirp2);
          sprintf(wdir_tmp3,"%s%s/index.sort",outdir,tmp4);
-         if(strcmp(IndexSortOrder,"A") == 0) sprintf(csort,"sort -n '%s' -o '%s'", tmp3, wdir_tmp3);
-         else sprintf(csort,"sort -n -r '%s' -o '%s'", tmp3, wdir_tmp3);
+         if(strcmp(IndexSortOrder,"A") == 0) sprintf(csort,"sort -n \"%s\" -o \"%s\"", tmp3, wdir_tmp3);
+         else sprintf(csort,"sort -n -r \"%s\" -o \"%s\"", tmp3, wdir_tmp3);
          cstatus=system(csort);
          if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
             fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
@@ -349,8 +349,8 @@ void make_index(void)
             (void)closedir(dirp3);
             unlink(wdir_tmp3);
             sprintf(tmp6,"%s%s/%s/index.sort",outdir,tmp4,wwork1);
-            if(strcmp(IndexSortOrder,"A") == 0) sprintf(csort,"sort -n '%s' -o '%s'", tmp5, tmp6);
-            else sprintf(csort,"sort -n -r '%s' -o '%s'", tmp5, tmp6);
+            if(strcmp(IndexSortOrder,"A") == 0) sprintf(csort,"sort -n \"%s\" -o \"%s\"", tmp5, tmp6);
+            else sprintf(csort,"sort -n -r \"%s\" -o \"%s\"", tmp5, tmp6);
             cstatus=system(csort);
             if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
                fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
@@ -389,8 +389,8 @@ void make_index(void)
       unlink(tmp6);
       unlink(wdir_tmp2);
    } else {
-      if(strcmp(IndexSortOrder,"A") == 0) sprintf(warea,"sort -t';' -k 7,7 -k 1,1 '%s' -o '%s'", wdir_tmp, wdir_tmp2);
-      else sprintf(warea,"sort -r -t';' -k 7,7 -k 1,1 '%s' -o '%s'", wdir_tmp, wdir_tmp2);
+      if(strcmp(IndexSortOrder,"A") == 0) sprintf(warea,"sort -t\";\" -k 7,7 -k 1,1 \"%s\" -o \"%s\"", wdir_tmp, wdir_tmp2);
+      else sprintf(warea,"sort -r -t\";\" -k 7,7 -k 1,1 \"%s\" -o \"%s\"", wdir_tmp, wdir_tmp2);
       cstatus=system(warea);
       if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
          fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
index c509301258750cfa735f6215c65973f622e01283..a7522b8ab0d2a6f58ba354aac83d626d81fd049b 100644 (file)
--- a/lastlog.c
+++ b/lastlog.c
@@ -68,7 +68,7 @@ void mklastlog(const char *outdir)
    (void)closedir( dirp );
    fclose(fp_ou);
    
-   sprintf(buf,"sort -n -k 1,1 -o '%slastlog' '%s'",outdir,temp);
+   sprintf(buf,"sort -n -k 1,1 -o \"%slastlog\" \"%s\"",outdir,temp);
    cstatus=system(buf);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
@@ -104,7 +104,7 @@ void mklastlog(const char *outdir)
          if(debug)
             debuga("%s: %s",text[81],buf);
 //         sprintf(temp,"%s%s",outdir,buf);
-         sprintf(temp,"rm -r '%s%s'",outdir,buf);
+         sprintf(temp,"rm -r \"%s%s\"",outdir,buf);
          system(temp);
          unlink(temp);
          ftot--;
diff --git a/log.c b/log.c
index d21adcb1f9aea80f4c688669dac126297e8c6860..f88f5aa9d2df68ec5e80799eeaeda04e3db35643 100644 (file)
--- a/log.c
+++ b/log.c
@@ -537,7 +537,7 @@ int main(int argc,char *argv[])
 
    sprintf(warea,"%s/sarg",tmp);
    if(access(warea, R_OK) == 0) {
-      sprintf(tmp3,"rm -rf '%s'",warea);
+      sprintf(tmp3,"rm -rf \"%s\"",warea);
       system(tmp3);
    }
 
@@ -1494,7 +1494,7 @@ int main(int argc,char *argv[])
       strcpy(arq_log,val4);
 
       if(strcmp(ParsedOutputLogCompress,"nocompress") != 0) {
-         sprintf(val1,"'%s' '%s'",ParsedOutputLogCompress,arq_log);
+         sprintf(val1,"\"%s\" \"%s\"",ParsedOutputLogCompress,arq_log);
          cstatus=system(val1);
          if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
             fprintf(stderr, "SARG: command return status %d\n",WEXITSTATUS(cstatus));
@@ -1508,7 +1508,7 @@ int main(int argc,char *argv[])
    }
 
    if(strstr(ReportType,"denied") != 0) {
-      sprintf(csort,"sort -T '%s' -k 3,3 -k 5,5 -o '%s' '%s'",tmp,tmp5,tmp4);
+      sprintf(csort,"sort -T \"%s\" -k 3,3 -k 5,5 -o \"%s\" \"%s\"",tmp,tmp5,tmp4);
       cstatus=system(csort);
       if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
          fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
@@ -1535,7 +1535,7 @@ int main(int argc,char *argv[])
 //   else  unlink(arq);
 
    if(strcmp(tmp,"/tmp") != 0) {
-      sprintf(tmp4,"rm -rf '%s'",tmp);
+      sprintf(tmp4,"rm -rf \"%s\"",tmp);
       system(tmp4);
    }
 
index 047b5d2686dd461f14da5d53d5258f912b2e402e..077dc7c87e4183507d14d22740541acc582f9ffd 100755 (executable)
@@ -74,7 +74,7 @@ static void getlog(void)
    pclose(fp);
    fclose(tmp);
 
-   sprintf(cmd,"sort -r -k 1,1 -k 2,2 -o '%s' '%s'",template2,template1);
+   sprintf(cmd,"sort -r -k 1,1 -k 2,2 -o \"%s\" \"%s\"",template2,template1);
    cstatus=system(cmd);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
index 79a229aa46174b82d2392dc971e69e89928ce358..3cdbe66fb6c3170555b655dbab50a29ae2c92f2e 100644 (file)
@@ -69,7 +69,7 @@ void siteuser(void)
    fgets(period,sizeof(period),fp_in);
    fclose(fp_in);
 
-   sprintf(csort,"sort -k 4,4 -k 1,1 -o '%s' '%s'",general2,general);
+   sprintf(csort,"sort -k 4,4 -k 1,1 -o \"%s\" \"%s\"",general2,general);
    cstatus=system(csort);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
index a7a91ec31d7bd6fb6136869f925b6c460b6d1f63..5ed753add4f4bb527f0e33f66e2ac667416a9b7f 100644 (file)
@@ -71,7 +71,7 @@ void smartfilter_report(void)
    fgets(period,sizeof(period),fp_in);
    fclose(fp_in);
 
-   sprintf(csort,"sort -n -k 1,1 -k 2,2 -k 3,3 -o '%s' '%s'",smart_ou,smart_in);
+   sprintf(csort,"sort -n -k 1,1 -k 2,2 -k 3,3 -o \"%s\" \"%s\"",smart_ou,smart_in);
    cstatus=system(csort);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
diff --git a/sort.c b/sort.c
index 774b52a894d922d3015a2d0790b1420fa74b83bd..fc0caef21af2f7ccd765ed604fdcafe0ff2a9ff0 100644 (file)
--- a/sort.c
+++ b/sort.c
@@ -90,7 +90,7 @@ void tmpsort(void)
       }
 
       strcat(arqou,".txt");
-      sprintf(csort,"sort -n -T '%s' %s -k %s -k %s -k %s -o '%s' '%s'",TempDir,order,field1,field2,field3,arqou,arqin);
+      sprintf(csort,"sort -n -T \"%s\" %s -k %s -k %s -k %s -o \"%s\" \"%s\"",TempDir,order,field1,field2,field3,arqou,arqin);
       cstatus=system(csort);
       if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
          fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
@@ -141,10 +141,10 @@ void sort_users_log(const char *tmp, int debug)
       }
 
       if(strcmp(direntp->d_name,"download.unsort") == 0)
-         sprintf(csort,"sort -T '%s' -k 3,3 -k 1,1 -k 2,2 -k 5,5 -o '%s/%s.log' '%s/%s.unsort'",
+         sprintf(csort,"sort -T \"%s\" -k 3,3 -k 1,1 -k 2,2 -k 5,5 -o \"%s/%s.log\" \"%s/%s.unsort\"",
               tmp, wtmp, user, wtmp, user);
       else
-         sprintf(csort,"sort -T '%s' -k 5,5 -k 1,1 -k 2,2 -o '%s/%s.log' '%s/%s.unsort'",
+         sprintf(csort,"sort -T \"%s\" -k 5,5 -k 1,1 -k 2,2 -o \"%s/%s.log\" \"%s/%s.unsort\"",
               tmp, wtmp, user, wtmp, user);
       cstatus=system(csort);
       if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
index 38153b44dde269aed98330900998e62444368e5f..3409d137460c722dbbce46b0b2cffd6c9175c8e9 100644 (file)
@@ -286,7 +286,7 @@ void squidguard_log(void)
       debuga("%s: %s",text[54],guard_ou);
    }
 
-   sprintf(tmp6,"sort -k 1,1 -k 2,2 -k 4,4 '%s' -o '%s'",guard_in, guard_ou);
+   sprintf(tmp6,"sort -k 1,1 -k 2,2 -k 4,4 \"%s\" -o \"%s\"",guard_in, guard_ou);
    cstatus=system(tmp6);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
index d7cd5a593fa4f07a1263e712e569b7529bfd6da0..5494b2bd2041ad53227ffd8e11ace3d6540f96ba 100644 (file)
@@ -79,7 +79,7 @@ void topsites(void)
    fgets(period,sizeof(period),fp_in);
    fclose(fp_in);
 
-   sprintf(csort,"sort -k 4,4 -o '%s' '%s'",general2,general);
+   sprintf(csort,"sort -k 4,4 -o \"%s\" \"%s\"",general2,general);
    cstatus=system(csort);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
@@ -189,7 +189,7 @@ void topsites(void)
    if(strcmp(TopsitesSortType,"d") == 0)
       strcpy(sortt,"-r");
 
-   sprintf(csort,"sort %s -k %s -o '%s' '%s'",sortt,sortf,sites,general3);
+   sprintf(csort,"sort %s -k %s -o \"%s\" \"%s\"",sortt,sortf,sites,general3);
    cstatus=system(csort);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
index 6654287cf6d2aecb1b3b5cf7504f7f01172bab47..f6fe5e8756708662aa2fde054a48ad8b09e8aa14 100644 (file)
--- a/topuser.c
+++ b/topuser.c
@@ -204,7 +204,7 @@ void topuser(void)
    if(strcmp(TopuserSortOrder,"normal") == 0)
       order[0]='\0';
 
-   sprintf(csort,"sort -n -T '%s' %s -k %s -o '%s' '%s'", TempDir, order, sfield, top1, top2);
+   sprintf(csort,"sort -n -T \"%s\" %s -k %s -o \"%s\" \"%s\"", TempDir, order, sfield, top1, top2);
    cstatus=system(csort);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
index 15de6b0d70036f5bd252841d32537bda21191f3b..d2ff1b5ad417e5e2e883b8c31f38518daef4e28d 100644 (file)
--- a/totday.c
+++ b/totday.c
@@ -56,7 +56,7 @@ void day_totalize(const char *tmp, const char *user, int indexonly)
    sprintf(arqout,"%s/%s.day",tmp,user);
    sprintf(sortout,"%s/%s.sort",tmp,user);
 
-   sprintf(csort,"sort -k 1,1 -k 2,2 -o '%s' '%s'",sortout,wdirname);
+   sprintf(csort,"sort -k 1,1 -k 2,2 -o \"%s\" \"%s\"",sortout,wdirname);
    cstatus=system(csort);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
index 537b9f165918a5543da88d8521b8dd1d7cdca3d4..dc5cc025e4a9f12c113f0e7b8d25a437ff015fa0 100644 (file)
@@ -120,7 +120,7 @@ void useragent(void)
       debuga("%s: %s",text[54],tmp2);
    }
 
-   sprintf(csort,"sort -n -t '\\' -k 4,4 -k 3,3 -k 2,2 -k 1,1 -o '%s' '%s'",tmp2,tmp3);
+   sprintf(csort,"sort -n -t '\\' -k 4,4 -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));
@@ -205,7 +205,7 @@ void useragent(void)
    fclose(fp_in);
    fclose(fp_ou);
 
-   sprintf(csort,"sort -n -t '\\' -k 3,3 -o '%s' '%s'",tmp3,tmp2);
+   sprintf(csort,"sort -n -t \"\\\" -k 3,3 -o \"%s\" \"%s\"",tmp3,tmp2);
    cstatus=system(csort);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
@@ -258,7 +258,7 @@ void useragent(void)
 
    unlink(tmp3);
 
-   sprintf(csort,"sort -n -r -k 1,1 -o '%s' '%s'",tmp3,tmp2);
+   sprintf(csort,"sort -n -r -k 1,1 -o \"%s\" \"%s\"",tmp3,tmp2);
    cstatus=system(csort);
    if (!WIFEXITED(cstatus) || WEXITSTATUS(cstatus)) {
       fprintf(stderr, "SARG: sort command return status %d\n",WEXITSTATUS(cstatus));
diff --git a/util.c b/util.c
index 6f7cdfd260778a3cc7b83a6246f9231a96ae9498..7e768205b88265e2bbdac55101c6a26fdd1fc82c 100644 (file)
--- a/util.c
+++ b/util.c
@@ -841,7 +841,7 @@ void vrfydir(const char *dir, const char *per1, const char *addr, const char *si
          }
       } else {
          if(access(dir,R_OK) == 0) {
-            sprintf(csort,"rm -r '%s'",dir);
+            sprintf(csort,"rm -r \"%s\"",dir);
             system(csort);
          }
       }
@@ -867,7 +867,7 @@ void vrfydir(const char *dir, const char *per1, const char *addr, const char *si
          }
       } else {
          if(access(wdir,R_OK) == 0) {
-            sprintf(csort,"rm -r '%s'",wdir);
+            sprintf(csort,"rm -r \"%s\"",wdir);
             system(csort);
          }
       }
@@ -1388,10 +1388,10 @@ void baddata(void)
    printf("SARG: process stoped. No actions taken.\n");
    printf("SARG: ------------------------------------------------------------------------------\n");
 
-   system("rm -rf '/tmp/sarg'");
-   sprintf(tmp4,"rm -rf '%s'",dirname);
+   system("rm -rf \"/tmp/sarg\"");
+   sprintf(tmp4,"rm -rf \"%s\"",dirname);
    system(tmp4);
-   system("rm -rf '/tmp/sarg'");
+   system("rm -rf \"/tmp/sarg\"");
 
    exit(1);
 }