summaryrefslogtreecommitdiffstats
path: root/tools/omfile.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2009-01-27 16:58:30 +0100
committerRainer Gerhards <rgerhards@adiscon.com>2009-01-27 16:58:30 +0100
commit4c7ab3bcc6db2aaddd0515944f282e3dd6ab056a (patch)
tree2b60a6d27a7bae4125876bb3782194c45830c27d /tools/omfile.c
parentd5360aa57436bb931c513677bc2cbdb1733a4c6b (diff)
parentce11f7bdb8db977a8b00b28d9b84d1b1c924f3c3 (diff)
downloadrsyslog-4c7ab3bcc6db2aaddd0515944f282e3dd6ab056a.tar.gz
rsyslog-4c7ab3bcc6db2aaddd0515944f282e3dd6ab056a.tar.xz
rsyslog-4c7ab3bcc6db2aaddd0515944f282e3dd6ab056a.zip
Merge branch 'beta'
Conflicts: tools/omfile.c
Diffstat (limited to 'tools/omfile.c')
-rw-r--r--tools/omfile.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/tools/omfile.c b/tools/omfile.c
index 00a82933..1539ae19 100644
--- a/tools/omfile.c
+++ b/tools/omfile.c
@@ -405,25 +405,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.
+ */
}
}
}