From 7d18d348da26fdbb392c76b0f5edb7f06282afbb Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sun, 2 Aug 2015 13:55:57 -0400 Subject: [PATCH] journald: make audit socket optional If we were given some sockets through socket activation, and audit socket is not among them, do not try to open it. This way, if the socket unit is disabled, we will not receive audit events. https://bugzilla.redhat.com/show_bug.cgi?id=1227379 --- src/journal/journald-server.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/journal/journald-server.c b/src/journal/journald-server.c index bff4e6f..ae325c4 100644 --- a/src/journal/journald-server.c +++ b/src/journal/journald-server.c @@ -1453,6 +1453,7 @@ static int server_open_hostname(Server *s) { int server_init(Server *s) { _cleanup_fdset_free_ FDSet *fds = NULL; int n, r, fd; + bool no_sockets; assert(s); @@ -1569,6 +1570,9 @@ int server_init(Server *s) { fds = fdset_free(fds); } + no_sockets = s->native_fd < 0 && s->stdout_fd < 0 && s->syslog_fd < 0 && s->audit_fd < 0; + + /* always open stdout, syslog, native, and kmsg sockets */ r = server_open_stdout_socket(s); if (r < 0) return r; @@ -1585,9 +1589,12 @@ int server_init(Server *s) { if (r < 0) return r; - r = server_open_audit(s); - if (r < 0) - return r; + /* Unless we got *some* sockets and not audit, open audit socket */ + if (s->audit_fd >= 0 || no_sockets) { + r = server_open_audit(s); + if (r < 0) + return r; + } r = server_open_kernel_seqnum(s); if (r < 0) -- 2.7.4