From 9a2efbd0097385fabde7e30990b6455ff3d737e3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20Marchal?= Date: Wed, 30 Sep 2009 14:41:05 +0000 Subject: [PATCH] Adjustments to run sarg on windows outside of msys. --- CMakeLists.txt | 12 +++--- README_cmake | 104 +++++++++++++++++++++++++++++++++++++++++++++ authfail.c | 2 +- dansguardian_log.c | 2 +- email.c | 4 +- grepday.c | 4 +- html.c | 2 +- include/info.h | 2 +- index.c | 18 ++++---- lastlog.c | 4 +- log.c | 8 ++-- realtime.c | 2 +- siteuser.c | 2 +- smartfilter.c | 2 +- sort.c | 6 +-- squidguard_log.c | 2 +- topsites.c | 4 +- topuser.c | 2 +- totday.c | 2 +- useragent.c | 6 +-- util.c | 10 ++--- 21 files changed, 152 insertions(+), 48 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 84e4980..46e40b8 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/README_cmake b/README_cmake index 1096597..be78a18 100644 --- a/README_cmake +++ b/README_cmake @@ -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. diff --git a/authfail.c b/authfail.c index 5a00a08..c7fe5b0 100644 --- a/authfail.c +++ b/authfail.c @@ -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)); diff --git a/dansguardian_log.c b/dansguardian_log.c index bd913f3..1b6cbce 100644 --- a/dansguardian_log.c +++ b/dansguardian_log.c @@ -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 848d40b..c8d03f1 100644 --- 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); diff --git a/grepday.c b/grepday.c index 95075d3..543c6bf 100644 --- 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 0177d1f..8376391 100644 --- 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)); diff --git a/include/info.h b/include/info.h index a6ec0a4..2ae2dd8 100755 --- a/include/info.h +++ b/include/info.h @@ -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 d855262..e7d5eba 100644 --- 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)); diff --git a/lastlog.c b/lastlog.c index c509301..a7522b8 100644 --- 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 d21adcb..f88f5aa 100644 --- 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); } diff --git a/realtime.c b/realtime.c index 047b5d2..077dc7c 100755 --- a/realtime.c +++ b/realtime.c @@ -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)); diff --git a/siteuser.c b/siteuser.c index 79a229a..3cdbe66 100644 --- a/siteuser.c +++ b/siteuser.c @@ -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)); diff --git a/smartfilter.c b/smartfilter.c index a7a91ec..5ed753a 100644 --- a/smartfilter.c +++ b/smartfilter.c @@ -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 774b52a..fc0caef 100644 --- 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)) { diff --git a/squidguard_log.c b/squidguard_log.c index 38153b4..3409d13 100644 --- a/squidguard_log.c +++ b/squidguard_log.c @@ -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)); diff --git a/topsites.c b/topsites.c index d7cd5a5..5494b2b 100644 --- a/topsites.c +++ b/topsites.c @@ -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)); diff --git a/topuser.c b/topuser.c index 6654287..f6fe5e8 100644 --- 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)); diff --git a/totday.c b/totday.c index 15de6b0..d2ff1b5 100644 --- 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)); diff --git a/useragent.c b/useragent.c index 537b9f1..dc5cc02 100644 --- a/useragent.c +++ b/useragent.c @@ -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 6f7cdfd..7e76820 100644 --- 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); } -- 2.47.2