]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
tree-wide: Include <libaudit.h> via libaudit-util.h
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 21 May 2025 10:22:40 +0000 (12:22 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 21 May 2025 12:05:56 +0000 (14:05 +0200)
Let's keep the ifdeffery for the include in one place.

src/core/audit-fd.c
src/core/manager.c
src/core/selinux-access.c
src/shared/libaudit-util.c
src/shared/libaudit-util.h
src/sysusers/sysusers.c
src/update-utmp/update-utmp.c

index b09f3ac49a5f21c81fbf45010d47b396f25950df..6150e7e43e563ae14da7dcf9f7e2bc3e6ecefc2c 100644 (file)
@@ -3,19 +3,13 @@
 #include <errno.h>
 
 #include "audit-fd.h"
-
-#if HAVE_AUDIT
-#  include <stdbool.h>
-
-#  include "libaudit-util.h"
-#  include "capability-util.h"
+#include "capability-util.h"
+#include "libaudit-util.h"
 
 static bool initialized = false;
 static int audit_fd = -EBADF;
-#endif
 
 int get_core_audit_fd(void) {
-#if HAVE_AUDIT
         if (!initialized) {
                 if (have_effective_cap(CAP_AUDIT_WRITE) <= 0)
                         audit_fd = -EPERM;
@@ -26,15 +20,10 @@ int get_core_audit_fd(void) {
         }
 
         return audit_fd;
-#else
-        return -EAFNOSUPPORT;
-#endif
 }
 
 void close_core_audit_fd(void) {
-#if HAVE_AUDIT
         close_audit_fd(audit_fd);
         initialized = true;
         audit_fd = -ECONNRESET;
-#endif
 }
index 1e264a361d70ddb853e04ddfc3ff1927a6ba4d3c..5b3d41596bbbc94cd77776937c0b628d7e710d71 100644 (file)
 #include <sys/wait.h>
 #include <unistd.h>
 
-#if HAVE_AUDIT
-#include <libaudit.h>
-#endif
-
 #include "sd-daemon.h"
 #include "sd-messages.h"
 #include "sd-path.h"
@@ -58,6 +54,7 @@
 #include "io-util.h"
 #include "iovec-util.h"
 #include "label-util.h"
+#include "libaudit-util.h"
 #include "load-fragment.h"
 #include "locale-setup.h"
 #include "log.h"
index 8ab488390cbd54e1577594c28eba8976ee9b39a0..189bded2800296d3c109bee967baa1d6579686f2 100644 (file)
@@ -7,9 +7,6 @@
 #include <errno.h>
 #include <selinux/avc.h>
 #include <selinux/selinux.h>
-#if HAVE_AUDIT
-#include <libaudit.h>
-#endif
 
 #include "sd-bus.h"
 
@@ -18,6 +15,7 @@
 #include "bus-util.h"
 #include "errno-util.h"
 #include "format-util.h"
+#include "libaudit-util.h"
 #include "log.h"
 #include "path-util.h"
 #include "selinux-util.h"
index e84684e581e9a50278d12a1732167a47f0fc8e44..da85c84d203a617783f93a14ebfca72039016c7e 100644 (file)
@@ -6,10 +6,6 @@
 #include <stdio.h>
 #include <sys/socket.h>
 
-#if HAVE_AUDIT
-#  include <libaudit.h>
-#endif
-
 #include "fd-util.h"
 #include "iovec-util.h"
 #include "libaudit-util.h"
@@ -100,14 +96,15 @@ int close_audit_fd(int fd) {
 }
 
 int open_audit_fd_or_warn(void) {
-        int fd = -EBADF;
-
 #if HAVE_AUDIT
         /* If the kernel lacks netlink or audit support, don't worry about it. */
-        fd = audit_open();
+        int fd = audit_open();
         if (fd < 0)
                 return log_full_errno(ERRNO_IS_NOT_SUPPORTED(errno) ? LOG_DEBUG : LOG_WARNING,
                                       errno, "Failed to connect to audit log, ignoring: %m");
-#endif
+
         return fd;
+#else
+        return log_debug_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), "libaudit support not compiled in");
+#endif
 }
index f00d816f78e6930cac29a6f71ded9811d89c78d7..1887e180c227da9b4c0d991c6a7d084938ebd6a6 100644 (file)
@@ -1,6 +1,10 @@
 /* SPDX-License-Identifier: LGPL-2.1-or-later */
 #pragma once
 
+#if HAVE_AUDIT
+#  include <libaudit.h>
+#endif
+
 #include <stdbool.h>
 
 bool use_audit(void);
index c9d3870111ea364993eb870d96a2bb3871f1279d..658bc72d85a4b2bc879a5695a524aef729cc188b 100644 (file)
@@ -4,10 +4,6 @@
 #include <stdlib.h>
 #include <sys/stat.h>
 
-#if HAVE_AUDIT
-#  include <libaudit.h>
-#endif
-
 #include "alloc-util.h"
 #include "build.h"
 #include "chase.h"
index 8c7a83ccb62449daa46282e8ee73f5144789b244..914c5ea3223d9294feba1f3e33274f4587f39a9c 100644 (file)
@@ -2,10 +2,6 @@
 
 #include <sys/stat.h>
 
-#if HAVE_AUDIT
-#  include <libaudit.h>
-#endif
-
 #include "sd-bus.h"
 
 #include "alloc-util.h"