diff --git a/runtime/errmsg.c b/runtime/errmsg.c index 866397abb..b961fe390 100644 --- a/runtime/errmsg.c +++ b/runtime/errmsg.c @@ -115,7 +115,7 @@ doLogMsg(const int iErrno, const int iErrCode, const int severity, const char * * maps to a specific error event). * rgerhards, 2008-06-27 */ -static void __attribute__((format(printf, 3, 4))) +void __attribute__((format(printf, 3, 4))) LogError(const int iErrno, const int iErrCode, const char *fmt, ... ) { va_list ap; @@ -144,7 +144,7 @@ LogError(const int iErrno, const int iErrCode, const char *fmt, ... ) * maps to a specific error event). * rgerhards, 2008-06-27 */ -static void __attribute__((format(printf, 4, 5))) +void __attribute__((format(printf, 4, 5))) LogMsg(const int iErrno, const int iErrCode, const int severity, const char *fmt, ... ) { va_list ap; diff --git a/runtime/errmsg.h b/runtime/errmsg.h index 4379f0391..5f8adaac9 100644 --- a/runtime/errmsg.h +++ b/runtime/errmsg.h @@ -46,5 +46,8 @@ ENDinterface(errmsg) PROTOTYPEObj(errmsg); void resetErrMsgsFlag(void); int hadErrMsgs(void); +void __attribute__((format(printf, 3, 4))) LogError(const int iErrno, const int iErrCode, const char *fmt, ... ); +void __attribute__((format(printf, 4, 5))) + LogMsg(const int iErrno, const int iErrCode, const int severity, const char *fmt, ... ); #endif /* #ifndef INCLUDED_ERRMSG_H */ diff --git a/runtime/rsyslog.h b/runtime/rsyslog.h index e1ef547f9..ba3a81f0c 100644 --- a/runtime/rsyslog.h +++ b/runtime/rsyslog.h @@ -483,6 +483,7 @@ operation not carried out */ RS_RET_FILE_CHOWN_ERROR = -2434, /**< error during chown() */ RS_RET_RENAME_TMP_QI_ERROR = -2435, /**< renaming temporary .qi file failed */ RS_RET_ERR_SETENV = -2436, /**< error setting an environment variable */ + RS_RET_DIR_CHOWN_ERROR = -2437, /**< error during chown() */ /* RainerScript error messages (range 1000.. 1999) */ RS_RET_SYSVAR_NOT_FOUND = 1001, /**< system variable could not be found (maybe misspelled) */ diff --git a/runtime/srutils.c b/runtime/srutils.c index 761ef0142..01f4ce377 100644 --- a/runtime/srutils.c +++ b/runtime/srutils.c @@ -44,6 +44,7 @@ #include #include "srUtils.h" #include "obj.h" +#include "errmsg.h" #if _POSIX_TIMERS <= 0 #include @@ -220,12 +221,18 @@ again: if(mkdir((char*)pszWork, mode) == 0) { if(uid != (uid_t) -1 || gid != (gid_t) -1) { /* we need to set owner/group */ - if(chown((char*)pszWork, uid, gid) != 0) + if(chown((char*)pszWork, uid, gid) != 0) { + char errStr[1024]; /* buffer for strerr() */ + rs_strerror_r(errno, errStr, sizeof(errStr)); + LogError(0, RS_RET_DIR_CHOWN_ERROR, + "chown for directory '%s' failed: %s", + pszWork, errStr); if(bFailOnChownFail) bErr = 1; /* silently ignore if configured * to do so. */ + } } } else { if(errno == EEXIST && iTry == 0) {