summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2011-06-15 12:20:12 +0200
committerRainer Gerhards <rgerhards@adiscon.com>2011-06-15 12:20:12 +0200
commit41d8672524b93aaf7b7835336ac9b92428b90fed (patch)
treee24d93da0c0b3d61490ddede5fdba7fb2e31f29b
parent28af40670e9dc1a85a24dfcbb093ddc1171e151f (diff)
downloadrsyslog-41d8672524b93aaf7b7835336ac9b92428b90fed.tar.gz
rsyslog-41d8672524b93aaf7b7835336ac9b92428b90fed.tar.xz
rsyslog-41d8672524b93aaf7b7835336ac9b92428b90fed.zip
bugfix/improvement:$WorkDirectory now gracefully handles trailing slashes
-rw-r--r--ChangeLog1
-rw-r--r--runtime/glbl.c23
-rw-r--r--runtime/rsyslog.h1
3 files changed, 24 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 8867e04e..042aeae3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@ Version 5.8.2 [V5-stable] (rgerhards), 2011-06-??
- bugfix: memory leak in imtcp & subsystems under some circumstances
This leak is tied to error conditions which lead to incorrect cleanup
of some data structures. [backport from v6]
+- bugfix/improvement:$WorkDirectory now gracefully handles trailing slashes
---------------------------------------------------------------------------
Version 5.8.1 [V5-stable] (rgerhards), 2011-05-19
- bugfix: invalid processing in QUEUE_FULL condition
diff --git a/runtime/glbl.c b/runtime/glbl.c
index ec4992cf..dea5a17b 100644
--- a/runtime/glbl.c
+++ b/runtime/glbl.c
@@ -159,8 +159,29 @@ static void SetGlobalInputTermination(void)
*/
static rsRetVal setWorkDir(void __attribute__((unused)) *pVal, uchar *pNewVal)
{
- DEFiRet;
+ size_t lenDir;
+ int i;
struct stat sb;
+ DEFiRet;
+
+ /* remove trailing slashes */
+ lenDir = ustrlen(pNewVal);
+ i = lenDir - 1;
+ while(i > 0 && pNewVal[i] == '/') {
+ --i;
+ }
+
+ if(i < 0) {
+ errmsg.LogError(0, RS_RET_ERR_WRKDIR, "$WorkDirectory: empty value "
+ "- directive ignored");
+ ABORT_FINALIZE(RS_RET_ERR_WRKDIR);
+ }
+
+ if(i != (int) lenDir - 1) {
+ pNewVal[i+1] = '\0';
+ errmsg.LogError(0, RS_RET_WRN_WRKDIR, "$WorkDirectory: trailing slashes "
+ "removed, new value is '%s'", pNewVal);
+ }
if(stat((char*) pNewVal, &sb) != 0) {
errmsg.LogError(0, RS_RET_ERR_WRKDIR, "$WorkDirectory: %s can not be "
diff --git a/runtime/rsyslog.h b/runtime/rsyslog.h
index d63dbe4f..52b29ac4 100644
--- a/runtime/rsyslog.h
+++ b/runtime/rsyslog.h
@@ -342,6 +342,7 @@ enum rsRetVal_ /** return value. All methods return this if not specified oth
RS_RET_ERR_HDFS_OPEN = -2179, /**< error during hdfsOpen (e.g. file does not exist) */
RS_RET_FILE_NOT_SPECIFIED = -2180, /**< file name not configured where this was required */
RS_RET_ERR_WRKDIR = -2181, /**< problems with the rsyslog working directory */
+ RS_RET_WRN_WRKDIR = -2182, /**< correctable problems with the rsyslog working directory */
/* RainerScript error messages (range 1000.. 1999) */
RS_RET_SYSVAR_NOT_FOUND = 1001, /**< system variable could not be found (maybe misspelled) */