---
 src/affile.c |   33 ++++++++++++++++++++++++++++++---
 1 file changed, 30 insertions(+), 3 deletions(-)

Index: syslog-ng-2.0.7/src/affile.c
===================================================================
--- syslog-ng-2.0.7.orig/src/affile.c	2009-03-27 13:13:30.000000000 +0100
+++ syslog-ng-2.0.7/src/affile.c	2009-03-27 13:45:00.000000000 +0100
@@ -40,10 +40,36 @@
 #endif
 
 static gboolean
+affile_create_fifo(gchar *name, int mode)
+{
+  if (mode == -1)
+    return 0;
+  if (mkfifo(name, mode) == 0)
+    {
+      msg_verbose("Destination is a fifo and did not "
+	          "exist -> created it.",
+	          evt_tag_str("filename", name),
+	          NULL);
+    }
+  else
+    {
+      if (errno != EEXIST)
+        {
+          msg_error("Error creating fifo.",
+	  	    evt_tag_str("filename", name),
+		    evt_tag_int("mode", mode),
+		    evt_tag_errno(EVT_TAG_OSERROR, errno),
+		    NULL);
+	  return 0;
+        }
+    }
+}
+
+static gboolean
 affile_open_file(gchar *name, int flags,
 	     int uid, int gid, int mode,
 	     int dir_uid, int dir_gid, int dir_mode,
-	     int create_dirs, int *fd)
+	     int create_dirs, int pipe, int *fd)
 {
   if (strstr(name, "../") || strstr(name, "/..")) 
     {
@@ -53,6 +74,8 @@
       return FALSE;
     }
 
+  if (pipe)
+    affile_create_fifo(name, mode);
   *fd = open(name, flags, mode);
   if (create_dirs && *fd == -1 && errno == ENOENT) 
     {
@@ -81,6 +104,8 @@
 	  *p = '/';
 	  p = strchr(p + 1, '/');
 	}
+      if (pipe)
+        affile_create_fifo(name, mode);
       *fd = open(name, flags, mode);
     }
   if (*fd != -1)
@@ -106,7 +131,8 @@
   else
     flags = O_RDONLY | O_NOCTTY | O_NONBLOCK | O_LARGEFILE;
 
-  if (affile_open_file(self->filename->str, flags, -1, -1, -1, 0, 0, 0, 0, fd))
+  if (affile_open_file(self->filename->str, flags, -1, -1, -1, 0, 0, 0, 0,
+		       (self->flags & AFFILE_PIPE), fd))
     return TRUE;
     
   return FALSE;
@@ -340,7 +366,8 @@
   if (affile_open_file(self->filename->str, flags, 
                        self->owner->file_uid, self->owner->file_gid, self->owner->file_perm, 
                        self->owner->dir_uid, self->owner->dir_gid, self->owner->dir_perm, 
-                       !!(self->owner->flags & AFFILE_CREATE_DIRS), &fd))
+                       !!(self->owner->flags & AFFILE_CREATE_DIRS),
+		       (self->owner->flags & AFFILE_PIPE), &fd))
     {
       FDWrite *fdw;
       
