diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2009-01-27 14:42:23 +0100 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2009-01-27 14:42:23 +0100 |
commit | ce11f7bdb8db977a8b00b28d9b84d1b1c924f3c3 (patch) | |
tree | 0ded85bdb06e524e48ff9bad6292d792d14c467d /tools/omfile.c | |
parent | e2ffeb19f9c2962fd711e28d50ce0d51ae3bbc45 (diff) | |
parent | 40514075c692195290306cd3928b5ce78f2aa38c (diff) | |
download | rsyslog-ce11f7bdb8db977a8b00b28d9b84d1b1c924f3c3.tar.gz rsyslog-ce11f7bdb8db977a8b00b28d9b84d1b1c924f3c3.tar.bz2 rsyslog-ce11f7bdb8db977a8b00b28d9b84d1b1c924f3c3.zip |
Merge branch 'v3-stable' into beta
Conflicts:
ChangeLog
configure.ac
doc/manual.html
Diffstat (limited to 'tools/omfile.c')
-rw-r--r-- | tools/omfile.c | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/tools/omfile.c b/tools/omfile.c index 8144386f..d76e24ae 100644 --- a/tools/omfile.c +++ b/tools/omfile.c @@ -385,26 +385,30 @@ static void prepareFile(instanceData *pData, uchar *newFileName) */ if(makeFileParentDirs(newFileName, strlen((char*)newFileName), pData->fDirCreateMode, pData->dirUID, - pData->dirGID, pData->bFailOnChown) == 0) { - pData->fd = open((char*) newFileName, O_WRONLY|O_APPEND|O_CREAT|O_NOCTTY, - pData->fCreateMode); - if(pData->fd != -1) { - /* check and set uid/gid */ - if(pData->fileUID != (uid_t)-1 || pData->fileGID != (gid_t) -1) { - /* we need to set owner/group */ - if(fchown(pData->fd, pData->fileUID, - pData->fileGID) != 0) { - if(pData->bFailOnChown) { - int eSave = errno; - close(pData->fd); - pData->fd = -1; - errno = eSave; - } - /* we will silently ignore the chown() failure - * if configured to do so. - */ - } + pData->dirGID, pData->bFailOnChown) != 0) { + return; /* we give up */ + } + } + /* no matter if we needed to create directories or not, we now try to create + * the file. -- rgerhards, 2008-12-18 (based on patch from William Tisater) + */ + pData->fd = open((char*) newFileName, O_WRONLY|O_APPEND|O_CREAT|O_NOCTTY, + pData->fCreateMode); + if(pData->fd != -1) { + /* check and set uid/gid */ + if(pData->fileUID != (uid_t)-1 || pData->fileGID != (gid_t) -1) { + /* we need to set owner/group */ + if(fchown(pData->fd, pData->fileUID, + pData->fileGID) != 0) { + if(pData->bFailOnChown) { + int eSave = errno; + close(pData->fd); + pData->fd = -1; + errno = eSave; } + /* we will silently ignore the chown() failure + * if configured to do so. + */ } } } |