From: Frédéric Marchal Date: Thu, 2 Sep 2010 07:14:14 +0000 (+0000) Subject: Report an error if the tail command cannot read the last lines of the log file when... X-Git-Tag: v2.3.1~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=89dbb8e8ad5e33560638eb3c10e1215ff6654688;p=thirdparty%2Fsarg.git Report an error if the tail command cannot read the last lines of the log file when creating a realtime report. Surrond the log file name with quotes in the command that read the trailing lines of the log file when creating a realtime report. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 14c2970..9b6d7de 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,7 @@ PROJECT(sarg C) SET(sarg_VERSION 2) SET(sarg_REVISION "3.1-pre1") SET(sarg_BUILD "") -SET(sarg_BUILDDATE "Aug-27-2010") +SET(sarg_BUILDDATE "Sep-02-2010") INCLUDE(AddFileDependencies) INCLUDE(CheckIncludeFile) diff --git a/ChangeLog b/ChangeLog index a41db39..c0a39d3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,6 @@ SARG ChangeLog -Aug-27-2010 Version 2.3.1 +Sep-02-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. - Take the configured locale path into account when installing sarg. @@ -13,6 +13,7 @@ Aug-27-2010 Version 2.3.1 - Report an error if the output directory is a subdirectory of the temporary directory. - Use a more robust protection against an attack using javascript in the useragent string. - Prevent a segfault if the parameter passed to command line option -d is invalid (thanks to ItalianPenguin). + - Check for the return code of the tail command to generate the realtime report. Jun-21-2010 Version 2.3 - LDAP usertab added. diff --git a/include/info.h b/include/info.h index 70dfd87..6549948 100755 --- a/include/info.h +++ b/include/info.h @@ -1,3 +1,3 @@ -#define VERSION PACKAGE_VERSION" Aug-27-2010" +#define VERSION PACKAGE_VERSION" Sep-02-2010" #define PGM PACKAGE_NAME #define URL "http://sarg.sourceforge.net" diff --git a/realtime.c b/realtime.c index 4f6f456..9d47fdd 100755 --- a/realtime.c +++ b/realtime.c @@ -65,8 +65,13 @@ static void getlog(void) exit(EXIT_FAILURE); } - sprintf(cmd,"tail -%d %s",realtime_access_log_lines,AccessLog[0]); + sprintf(cmd,"tail -%d \"%s\"",realtime_access_log_lines,AccessLog[0]); fp = popen(cmd, "r"); + if (!fp) { + debuga(_("Failed to get the %d trailing lines of %s: %s\n"),realtime_access_log_lines,AccessLog[0],strerror(errno)); + debuga(_("tail command: %s\n"),cmd); + exit(EXIT_FAILURE); + } while((buf=longline_read(fp,line)) != NULL ) if (getdata(buf,tmp)<0) { debuga(_("Maybe a broken record or garbage was returned by %s\n"),cmd);