chiark / gitweb /
audit: do not complain if kernel lacks audit
authorJonathan Nieder <jrnieder@gmail.com>
Mon, 17 Oct 2011 19:01:40 +0000 (21:01 +0200)
committerTollef Fog Heen <tfheen@err.no>
Mon, 17 Oct 2011 19:04:59 +0000 (21:04 +0200)
When running on a kernel without audit support, systemd currently
writes a mysterious-sounding error to its log:

systemd[1]: Failed to connect to audit log: Protocol not supported

Better to suppress the audit_open() failure message when (and only
when) it is due to running on a kernel without audit support, since in
this case the admin probably does not mind systemd not writing to the
audit log.  This way, more serious errors like ENOMEM and EACCES will
stand out more.

src/manager.c
src/update-utmp.c

index 6d202588939a3485bcb37b8c4b862a95c4346123..111167a8c2a19147af66dfec669a72de2b2f444a 100644 (file)
@@ -286,7 +286,10 @@ int manager_new(ManagerRunningAs running_as, Manager **_m) {
                 goto fail;
 
 #ifdef HAVE_AUDIT
-        if ((m->audit_fd = audit_open()) < 0)
+        if ((m->audit_fd = audit_open()) < 0 &&
+            /* If the kernel lacks netlink or audit support,
+             * don't worry about it. */
+            errno != EAFNOSUPPORT && errno != EPROTONOSUPPORT)
                 log_error("Failed to connect to audit log: %m");
 #endif
 
index f81e7f495f864c25949c2bafdbec0878b32ae34d..12e4d110425c2050f09edb7e14a5a581b7ee2ec7 100644 (file)
@@ -376,7 +376,10 @@ int main(int argc, char *argv[]) {
         umask(0022);
 
 #ifdef HAVE_AUDIT
-        if ((c.audit_fd = audit_open()) < 0)
+        if ((c.audit_fd = audit_open()) < 0 &&
+            /* If the kernel lacks netlink or audit support,
+             * don't worry about it. */
+            errno != EAFNOSUPPORT && errno != EPROTONOSUPPORT)
                 log_error("Failed to connect to audit log: %m");
 #endif