[syslog-ng] Writing to a named Pipe

Balazs Scheidler bazsi at balabit.hu
Thu Jan 22 19:39:48 CET 2009


On Thu, 2009-01-22 at 15:26 +0000, Pedro Rafael Alves Simoes wrote:
> Hello,
> 
> In my syslog-ng configuration I'm writing messages to named pipes
> which name is given dynamically by the $PRI macro:
> 
> destination d_test {
>   pipe("/tmp/$PRI.log");
> };
> 
> All the possible PRI.log pipes were created previously with mkfifo.
> 
> With this configuration the messages aren't being written to the
> pipes. It simply does nothing. Doing a strace on the syslog-ng
> process, it shows an error :
> 
> open("/tmp/$PRI.log", O_RDWR|O_NONBLOCK|O_NOCTTY|O_LARGEFILE) = -1
> ENOENT (No such file or directory)
> 
> It seems that the PRI macro isn't being interpolated in the string.

well, the pipe() driver does not support macros, thus it uses the string
literally. More exactly the pipe driver explicitly disallows that. Since
I don't remember exactly why I did this, here's a patch that removes the
restriction.

Please let me know how it works out for you, if it seems to work, I'm
also willing to integrate it. Patch is against OSE 3.0, but is trivial
to backport to 2.1

diff --git a/src/cfg-grammar.y b/src/cfg-grammar.y
index 761bb56..fdfa18f 100644
--- a/src/cfg-grammar.y
+++ b/src/cfg-grammar.y
@@ -801,7 +801,7 @@ dest_afpipe
 dest_afpipe_params
        : string 
          { 
-           last_driver = affile_dd_new($1, AFFILE_NO_EXPAND | AFFILE_PIPE);
+           last_driver = affile_dd_new($1, AFFILE_PIPE);
            free($1); 
            last_writer_options = &((AFFileDestDriver *) last_driver)->writer_options;
            last_writer_options->flush_lines = 0;


-- 
Bazsi




More information about the syslog-ng mailing list