]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/core/audit-fd.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
12 #include "capability-util.h"
17 static bool initialized
= false;
20 int get_audit_fd(void) {
23 if (have_effective_cap(CAP_AUDIT_WRITE
) == 0) {
30 audit_fd
= audit_open();
33 if (!IN_SET(errno
, EAFNOSUPPORT
, EPROTONOSUPPORT
))
34 log_error_errno(errno
, "Failed to connect to audit log: %m");
36 audit_fd
= errno
? -errno
: -EINVAL
;
45 void close_audit_fd(void) {
47 if (initialized
&& audit_fd
>= 0)
51 audit_fd
= -ECONNRESET
;
56 int get_audit_fd(void) {
60 void close_audit_fd(void) {