mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
tree-wide: Include <libaudit.h> via libaudit-util.h
Let's keep the ifdeffery for the include in one place.
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -12,10 +12,6 @@
|
||||
#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"
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if HAVE_AUDIT
|
||||
# include <libaudit.h>
|
||||
#endif
|
||||
|
||||
#include "sd-bus.h"
|
||||
|
||||
#include "alloc-util.h"
|
||||
|
||||
Reference in New Issue
Block a user