[syslog-ng] [PATCH (3.4)] afsocket: Use the "dgram" proto for dgram sockets

Gergely Nagy algernon at balabit.hu
Thu Oct 11 12:34:34 CEST 2012

When applying a transport to a socket, don't just set the transport,
but also set logproto_name properly: "dgram" for SOCK_DGRAM sockets,
"text" for everything else.

If this is not done, and our socket is SOCK_DGRAM, we'd use the text
proto, which after the refactoring, would look for a terminating new
line, instead of datagram boundary - and it wouldn't find it, which
will result in partial messages accumulating in a buffer, to
eventually be sent out as garbage.

This patch simply makes it so that SOCK_DGRAM will use the "dgram"
logproto, which does the right thing, and knows about datagram

Reported-by: Peter Czanik <czanik at balabit.hu>
Signed-off-by: Gergely Nagy <algernon at balabit.hu>
 modules/afsocket/afunix.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/modules/afsocket/afunix.c b/modules/afsocket/afunix.c
index 1a1465f..8849927 100644
--- a/modules/afsocket/afunix.c
+++ b/modules/afsocket/afunix.c
@@ -172,12 +172,16 @@ afunix_sd_apply_transport(AFSocketSourceDriver *s)
   if (!self->super.bind_addr)
     self->super.bind_addr = g_sockaddr_unix_new(self->filename);
+  self->super.logproto_name = "text";
   if (self->super.sock_type == SOCK_DGRAM)
-    afsocket_sd_set_transport(&self->super.super.super, "unix-dgram");
+    {
+      afsocket_sd_set_transport(&self->super.super.super, "unix-dgram");
+      self->super.logproto_name = "dgram";
+    }
     afsocket_sd_set_transport(&self->super.super.super, "unix-stream");
-  self->super.logproto_name = "text";
   return TRUE;

More information about the syslog-ng mailing list