diff options
author | Rainer Gerhards <rgerhards@adiscon.com> | 2007-07-17 10:09:19 +0000 |
---|---|---|
committer | Rainer Gerhards <rgerhards@adiscon.com> | 2007-07-17 10:09:19 +0000 |
commit | 6ce20a8c79fc3d3e7ed06b93f03308d78d7dbb4e (patch) | |
tree | 580548bddfed38a12897161ff30545ddf10ae44d /syslogd.c | |
parent | 31e188f8e7db7c057f1edd29c72703a3ff00ef0b (diff) | |
download | rsyslog-6ce20a8c79fc3d3e7ed06b93f03308d78d7dbb4e.tar.gz rsyslog-6ce20a8c79fc3d3e7ed06b93f03308d78d7dbb4e.tar.bz2 rsyslog-6ce20a8c79fc3d3e7ed06b93f03308d78d7dbb4e.zip |
basic support for creating directories with dynaFiles added
Diffstat (limited to 'syslogd.c')
-rw-r--r-- | syslogd.c | 15 |
1 files changed, 14 insertions, 1 deletions
@@ -6229,10 +6229,23 @@ static int prepareDynFile(selector_t *f) /* Ok, we finally can open the file */ f->f_file = open((char*) newFileName, O_WRONLY|O_APPEND|O_CREAT|O_NOCTTY, f->f_un.f_file.fCreateMode); + + if(f->f_file == -1) { + /* on first failure, we try to create parent directories and then + * retry the open. Only if that fails, we give up. We do not report + * any errors here ourselfs but let the code fall through to error + * handler below. + */ + if(makeFileParentDirs(newFileName, strlen(newFileName), + f->f_un.f_file.fCreateMode) == 0) { + f->f_file = open((char*) newFileName, O_WRONLY|O_APPEND|O_CREAT|O_NOCTTY, + f->f_un.f_file.fCreateMode); + } + } if(f->f_file == -1) { /* do not report anything if the message is an internally-generated * message. Otherwise, we could run into a never-ending loop. The bad - * news is that we also loose errors on startup messages, but so it is. + * news is that we also lose errors on startup messages, but so it is. */ if(f->f_pMsg->msgFlags & INTERNAL_MSG) dprintf("Could not open dynaFile, discarding message\n"); |