summaryrefslogtreecommitdiffstats
path: root/syslogd.c
diff options
context:
space:
mode:
authorRainer Gerhards <rgerhards@adiscon.com>2007-07-17 10:09:19 +0000
committerRainer Gerhards <rgerhards@adiscon.com>2007-07-17 10:09:19 +0000
commit6ce20a8c79fc3d3e7ed06b93f03308d78d7dbb4e (patch)
tree580548bddfed38a12897161ff30545ddf10ae44d /syslogd.c
parent31e188f8e7db7c057f1edd29c72703a3ff00ef0b (diff)
downloadrsyslog-6ce20a8c79fc3d3e7ed06b93f03308d78d7dbb4e.tar.gz
rsyslog-6ce20a8c79fc3d3e7ed06b93f03308d78d7dbb4e.tar.xz
rsyslog-6ce20a8c79fc3d3e7ed06b93f03308d78d7dbb4e.zip
basic support for creating directories with dynaFiles added
Diffstat (limited to 'syslogd.c')
-rw-r--r--syslogd.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/syslogd.c b/syslogd.c
index d29221fa..70785e8c 100644
--- a/syslogd.c
+++ b/syslogd.c
@@ -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");