[syslog-ng] [PATCH (3.5)] system-source: Make /proc/kmsg optional

Gergely Nagy algernon at balabit.hu
Thu May 16 14:35:43 CEST 2013


In certain environments (vserver and OpenVZ come to mind), /proc/kmsg is
not readable, not even for root. On these systems, emit a warning, and
skip it, instead of aborting the startup.

Reported-by: Tamas Pal <folti at balabit.hu>
Signed-off-by: Gergely Nagy <algernon at balabit.hu>
---
 modules/system-source/system-source.c |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/modules/system-source/system-source.c b/modules/system-source/system-source.c
index 3c72859..955ade7 100644
--- a/modules/system-source/system-source.c
+++ b/modules/system-source/system-source.c
@@ -167,8 +167,17 @@ system_sysblock_add_linux_kmsg(GString *sysblock)
       close (fd);
     }
 
-  system_sysblock_add_file(sysblock, kmsg, -1,
-                           "kernel", "kernel", format);
+  if (access(kmsg, R_OK) == -1)
+    {
+      msg_warning("system(): The kernel message buffer is not readable, "
+                  "please check permissions if this is unintentional.",
+                  evt_tag_str("device", kmsg),
+                  evt_tag_errno("error", errno),
+                  NULL);
+    }
+  else
+    system_sysblock_add_file(sysblock, kmsg, -1,
+                             "kernel", "kernel", format);
 }
 
 gboolean
-- 
1.7.10.4




More information about the syslog-ng mailing list