]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/core/audit-fd.c
1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
12 #include "capability-util.h"
16 static bool initialized
= false;
19 int get_audit_fd(void) {
22 if (have_effective_cap(CAP_AUDIT_WRITE
) <= 0) {
29 audit_fd
= audit_open();
32 if (!IN_SET(errno
, EAFNOSUPPORT
, EPROTONOSUPPORT
))
33 log_error_errno(errno
, "Failed to connect to audit log: %m");
35 audit_fd
= errno
? -errno
: -EINVAL
;
44 void close_audit_fd(void) {
46 if (initialized
&& audit_fd
>= 0)
50 audit_fd
= -ECONNRESET
;
55 int get_audit_fd(void) {
59 void close_audit_fd(void) {