summaryrefslogtreecommitdiffstats
path: root/tools/omfile.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2008-12-18 13:55:24 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2008-12-18 13:55:24 +0100
commit98624f1bc46b8fd259bc1096022df5fc642e90bf (patch)
tree29468fa8e8a9bdddbbaae188494e24bf6972ef62 /tools/omfile.c
parent6b1a023f256030d19e12bbaeaeb236e4d664d90a (diff)
parent197d980f5b1fabef40d908f2aaf51c5be184c0e2 (diff)
downloadrsyslog-98624f1bc46b8fd259bc1096022df5fc642e90bf.tar.gz
rsyslog-98624f1bc46b8fd259bc1096022df5fc642e90bf.tar.xz
rsyslog-98624f1bc46b8fd259bc1096022df5fc642e90bf.zip
Merge branch 'debian_lenny' into v3-stable
Diffstat (limited to 'tools/omfile.c')
-rw-r--r--tools/omfile.c42
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.
+ */
}
}
}