Merge pull request #1397 from rgerhards/errmsg-on-dir-own-chg-err

Errmsg on dir own chg err
This commit is contained in:
Rainer Gerhards 2017-02-10 13:14:29 +01:00 committed by GitHub
commit 0afeffef33
4 changed files with 14 additions and 3 deletions

View File

@ -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;

View File

@ -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 */

View File

@ -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) */

View File

@ -44,6 +44,7 @@
#include <inttypes.h>
#include "srUtils.h"
#include "obj.h"
#include "errmsg.h"
#if _POSIX_TIMERS <= 0
#include <sys/time.h>
@ -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) {