]>
git.ipfire.org Git - thirdparty/systemd.git/blob - src/core/audit-fd.c
1 /* SPDX-License-Identifier: LGPL-2.1+ */
3 This file is part of systemd.
5 Copyright 2012 Lennart Poettering
17 #include "capability-util.h"
22 static bool initialized
= false;
25 int get_audit_fd(void) {
28 if (have_effective_cap(CAP_AUDIT_WRITE
) == 0) {
35 audit_fd
= audit_open();
38 if (!IN_SET(errno
, EAFNOSUPPORT
, EPROTONOSUPPORT
))
39 log_error_errno(errno
, "Failed to connect to audit log: %m");
41 audit_fd
= errno
? -errno
: -EINVAL
;
50 void close_audit_fd(void) {
52 if (initialized
&& audit_fd
>= 0)
56 audit_fd
= -ECONNRESET
;
61 int get_audit_fd(void) {
65 void close_audit_fd(void) {