chiark / gitweb /
tree-wide: allow state to be passed through to parse_proc_cmdline_item
[elogind.git] / src / basic / audit-util.c
index 4612297334156aa325b62894603120c30e45be50..2b557839446d87d49704b9db5aa4085748dd061a 100644 (file)
@@ -1,5 +1,3 @@
-/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
-
 /***
   This file is part of systemd.
 
@@ -20,7 +18,9 @@
 ***/
 
 #include <errno.h>
+#include <linux/netlink.h>
 #include <stdio.h>
+#include <sys/socket.h>
 
 #include "alloc-util.h"
 #include "audit-util.h"
@@ -30,7 +30,6 @@
 #include "parse-util.h"
 #include "process-util.h"
 #include "user-util.h"
-#include "util.h"
 
 int audit_session_from_pid(pid_t pid, uint32_t *id) {
         _cleanup_free_ char *s = NULL;
@@ -86,6 +85,7 @@ int audit_loginuid_from_pid(pid_t pid, uid_t *uid) {
         return 0;
 }
 
+#if 0 /// UNNEEDED by elogind
 bool use_audit(void) {
         static int cached_use = -1;
 
@@ -93,8 +93,11 @@ bool use_audit(void) {
                 int fd;
 
                 fd = socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC|SOCK_NONBLOCK, NETLINK_AUDIT);
-                if (fd < 0)
-                        cached_use = errno != EAFNOSUPPORT && errno != EPROTONOSUPPORT;
+                if (fd < 0) {
+                        cached_use = !IN_SET(errno, EAFNOSUPPORT, EPROTONOSUPPORT, EPERM);
+                        if (errno == EPERM)
+                                log_debug_errno(errno, "Audit access prohibited, won't talk to audit");
+                }
                 else {
                         cached_use = true;
                         safe_close(fd);
@@ -103,3 +106,4 @@ bool use_audit(void) {
 
         return cached_use;
 }
+#endif // 0