journald-server.c revision ea69bd41c5923f4f278a09bb7d8cb1abcfa122e1
/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
/***
This file is part of systemd.
Copyright 2011 Lennart Poettering
under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
systemd is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with systemd; If not, see <http://www.gnu.org/licenses/>.
***/
#include <sys/signalfd.h>
#include <libudev.h>
#include "sd-journal.h"
#include "sd-messages.h"
#include "sd-daemon.h"
#include "fileio.h"
#include "mkdir.h"
#include "hashmap.h"
#include "journal-file.h"
#include "socket-util.h"
#include "cgroup-util.h"
#include "list.h"
#include "missing.h"
#include "conf-parser.h"
#include "selinux-util.h"
#include "journal-internal.h"
#include "journal-vacuum.h"
#include "journal-authenticate.h"
#include "journald-rate-limit.h"
#include "journald-kmsg.h"
#include "journald-syslog.h"
#include "journald-stream.h"
#include "journald-console.h"
#include "journald-native.h"
#include "journald-audit.h"
#include "journald-server.h"
#ifdef HAVE_ACL
#include "acl-util.h"
#endif
#ifdef HAVE_SELINUX
#endif
#define USER_JOURNALS_MAX 1024
#define DEFAULT_RATE_LIMIT_BURST 1000
#define DEFAULT_MAX_FILE_USEC USEC_PER_MONTH
static const char* const storage_table[_STORAGE_MAX] = {
[STORAGE_AUTO] = "auto",
[STORAGE_VOLATILE] = "volatile",
[STORAGE_PERSISTENT] = "persistent",
[STORAGE_NONE] = "none"
};
DEFINE_CONFIG_PARSE_ENUM(config_parse_storage, storage, Storage, "Failed to parse storage setting");
static const char* const split_mode_table[_SPLIT_MAX] = {
[SPLIT_LOGIN] = "login",
[SPLIT_UID] = "uid",
[SPLIT_NONE] = "none",
};
DEFINE_CONFIG_PARSE_ENUM(config_parse_split_mode, split_mode, SplitMode, "Failed to parse split mode setting");
char ids[33];
_cleanup_free_ char *p = NULL;
int r;
const char *f;
JournalMetrics *m;
&& !verbose)
return s->cached_available_space;
r = sd_id128_get_machine(&machine);
if (r < 0)
return 0;
if (s->system_journal) {
m = &s->system_metrics;
} else {
m = &s->runtime_metrics;
}
assert(m);
if (!p)
return 0;
d = opendir(p);
if (!d)
return 0;
return 0;
for (;;) {
errno = 0;
return 0;
if (!de)
break;
continue;
continue;
continue;
}
/* If we reached a high mark, we will always allow this much
* again, unless usage goes above max_use. This watermark
* value is cached so that we don't give up space on pressure,
* but hover below the maximum usage. */
if (verbose) {
"%s journal is using %s (max allowed %s, "
"trying to leave %s free of %s available → current limit %s).",
}
return s->cached_available_space;
}
int r;
#ifdef HAVE_ACL
#endif
assert(f);
if (r < 0)
#ifdef HAVE_ACL
if (uid <= SYSTEM_UID_MAX)
return;
if (!acl) {
return;
}
if (r <= 0) {
goto finish;
}
}
/* We do not recalculate the mask unconditionally here,
* so that the fchmod() mask above stays intact. */
calc_acl_mask_if_needed(&acl) < 0) {
goto finish;
}
#endif
}
_cleanup_free_ char *p = NULL;
int r;
JournalFile *f;
assert(s);
/* We split up user logs only on /var, not on /run. If the
* runtime file is open, we write to it exclusively, in order
* to guarantee proper order as soon as we flush /run to
* /var and close the runtime file. */
if (s->runtime_journal)
return s->runtime_journal;
if (uid <= SYSTEM_UID_MAX)
return s->system_journal;
r = sd_id128_get_machine(&machine);
if (r < 0)
return s->system_journal;
if (f)
return f;
return s->system_journal;
/* Too many open? Then let's close one */
f = ordered_hashmap_steal_first(s->user_journals);
assert(f);
}
r = journal_file_open_reliably(p, O_RDWR|O_CREAT, 0640, s->compress, s->seal, &s->system_metrics, s->mmap, NULL, &f);
if (r < 0)
return s->system_journal;
server_fix_perms(s, f, uid);
if (r < 0) {
return s->system_journal;
}
return f;
}
static int do_rotate(
Server *s,
JournalFile **f,
const char* name,
bool seal,
int r;
assert(s);
if (!*f)
return -EINVAL;
if (r < 0)
if (*f)
else
else
server_fix_perms(s, *f, uid);
return r;
}
void server_rotate(Server *s) {
JournalFile *f;
void *k;
Iterator i;
int r;
log_debug("Rotating...");
ORDERED_HASHMAP_FOREACH_KEY(f, k, s->user_journals, i) {
if (r >= 0)
ordered_hashmap_replace(s->user_journals, k, f);
else if (!f)
/* Old file has been closed and deallocated */
ordered_hashmap_remove(s->user_journals, k);
}
}
void server_sync(Server *s) {
JournalFile *f;
void *k;
Iterator i;
int r;
if (s->system_journal) {
r = journal_file_set_offline(s->system_journal);
if (r < 0)
log_error_errno(r, "Failed to sync system journal: %m");
}
ORDERED_HASHMAP_FOREACH_KEY(f, k, s->user_journals, i) {
r = journal_file_set_offline(f);
if (r < 0)
log_error_errno(r, "Failed to sync user journal: %m");
}
if (s->sync_event_source) {
if (r < 0)
log_error_errno(r, "Failed to disable sync timer source: %m");
}
s->sync_scheduled = false;
}
static void do_vacuum(
Server *s,
const char *id,
JournalFile *f,
const char* path,
const char *p;
int r;
if (!f)
return;
r = journal_directory_vacuum(p, metrics->max_use, s->max_retention_usec, &s->oldest_file_usec, false);
if (r < 0 && r != -ENOENT)
log_error_errno(r, "Failed to vacuum %s: %m", p);
}
void server_vacuum(Server *s) {
char ids[33];
int r;
log_debug("Vacuuming...");
s->oldest_file_usec = 0;
r = sd_id128_get_machine(&machine);
if (r < 0) {
log_error_errno(r, "Failed to get machine ID: %m");
return;
}
s->cached_available_space_timestamp = 0;
}
static void server_cache_machine_id(Server *s) {
int r;
assert(s);
r = sd_id128_get_machine(&id);
if (r < 0)
return;
}
static void server_cache_boot_id(Server *s) {
int r;
assert(s);
r = sd_id128_get_boot(&id);
if (r < 0)
return;
}
static void server_cache_hostname(Server *s) {
_cleanup_free_ char *t = NULL;
char *x;
assert(s);
t = gethostname_malloc();
if (!t)
return;
x = strappend("_HOSTNAME=", t);
if (!x)
return;
free(s->hostname_field);
s->hostname_field = x;
}
static bool shall_try_append_again(JournalFile *f, int r) {
/* -E2BIG Hit configured limit
-EFBIG Hit fs limit
-EDQUOT Quota limit hit
-ENOSPC Disk full
-EIO I/O error of some kind (mmap)
-EHOSTDOWN Other machine
-EBUSY Unclean shutdown
-EPROTONOSUPPORT Unsupported feature
-EBADMSG Corrupted
-ENODATA Truncated
-ESHUTDOWN Already archived */
else if (r == -EHOSTDOWN)
else if (r == -EBUSY)
else if (r == -EPROTONOSUPPORT)
else if (r == -EIO)
else
return false;
return true;
}
JournalFile *f;
bool vacuumed = false;
int r;
assert(s);
assert(n > 0);
f = find_journal(s, uid);
if (!f)
return;
if (journal_file_rotate_suggested(f, s->max_file_usec)) {
server_rotate(s);
server_vacuum(s);
vacuumed = true;
f = find_journal(s, uid);
if (!f)
return;
}
if (r >= 0) {
return;
}
if (vacuumed || !shall_try_append_again(f, r)) {
unsigned i;
for (i = 0; i < n; i++)
return;
}
server_rotate(s);
server_vacuum(s);
f = find_journal(s, uid);
if (!f)
return;
log_debug("Retrying write.");
if (r < 0) {
unsigned i;
for (i = 0; i < n; i++)
log_error_errno(r, "Failed to write entry (%d items, %zu bytes) despite vacuuming, ignoring: %m", n, size);
} else
}
static void dispatch_message_real(
Server *s,
const char *unit_id,
int priority,
pid_t object_pid) {
char *x;
int r;
char *t, *c;
bool owner_valid = false;
#ifdef HAVE_AUDIT
#endif
assert(s);
assert(n > 0);
if (ucred) {
if (r >= 0) {
x = strappenda("_COMM=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
}
if (r >= 0) {
x = strappenda("_EXE=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
}
if (r >= 0) {
x = strappenda("_CMDLINE=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
}
if (r >= 0) {
x = strappenda("_CAP_EFFECTIVE=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
}
#ifdef HAVE_AUDIT
if (r >= 0) {
}
if (r >= 0) {
}
#endif
if (r >= 0) {
x = strappenda("_SYSTEMD_CGROUP=", c);
IOVEC_SET_STRING(iovec[n++], x);
r = cg_path_get_session(c, &t);
if (r >= 0) {
free(t);
}
if (cg_path_get_owner_uid(c, &owner) >= 0) {
owner_valid = true;
}
if (cg_path_get_unit(c, &t) >= 0) {
x = strappenda("_SYSTEMD_UNIT=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
IOVEC_SET_STRING(iovec[n++], x);
}
if (cg_path_get_user_unit(c, &t) >= 0) {
x = strappenda("_SYSTEMD_USER_UNIT=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
IOVEC_SET_STRING(iovec[n++], x);
}
if (cg_path_get_slice(c, &t) >= 0) {
x = strappenda("_SYSTEMD_SLICE=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
}
free(c);
} else if (unit_id) {
IOVEC_SET_STRING(iovec[n++], x);
}
#ifdef HAVE_SELINUX
if (mac_selinux_use()) {
if (label) {
IOVEC_SET_STRING(iovec[n++], x);
} else {
IOVEC_SET_STRING(iovec[n++], x);
}
}
}
#endif
}
assert(n <= m);
if (object_pid) {
if (r >= 0) {
}
if (r >= 0) {
}
r = get_process_comm(object_pid, &t);
if (r >= 0) {
x = strappenda("OBJECT_COMM=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
}
r = get_process_exe(object_pid, &t);
if (r >= 0) {
x = strappenda("OBJECT_EXE=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
}
r = get_process_cmdline(object_pid, 0, false, &t);
if (r >= 0) {
x = strappenda("OBJECT_CMDLINE=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
}
#ifdef HAVE_AUDIT
if (r >= 0) {
}
if (r >= 0) {
}
#endif
if (r >= 0) {
x = strappenda("OBJECT_SYSTEMD_CGROUP=", c);
IOVEC_SET_STRING(iovec[n++], x);
r = cg_path_get_session(c, &t);
if (r >= 0) {
x = strappenda("OBJECT_SYSTEMD_SESSION=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
}
if (cg_path_get_owner_uid(c, &owner) >= 0) {
}
if (cg_path_get_unit(c, &t) >= 0) {
x = strappenda("OBJECT_SYSTEMD_UNIT=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
}
if (cg_path_get_user_unit(c, &t) >= 0) {
x = strappenda("OBJECT_SYSTEMD_USER_UNIT=", t);
free(t);
IOVEC_SET_STRING(iovec[n++], x);
}
free(c);
}
}
assert(n <= m);
if (tv) {
}
/* Note that strictly speaking storing the boot id here is
* redundant since the entry includes this in-line
* anyway. However, we need this indexed, too. */
if (!isempty(s->boot_id_field))
if (!isempty(s->machine_id_field))
if (!isempty(s->hostname_field))
assert(n <= m);
/* Split up strictly by any UID */
/* Split up by login UIDs. We do this only if the
* realuid is not root, in order not to accidentally
* leak privileged information to the user that is
* logged by a privileged process that is part of an
* unprivileged session. */
journal_uid = owner;
else
journal_uid = 0;
}
int n = 0;
assert(s);
}
}
void server_dispatch_message(
Server *s,
const char *unit_id,
int priority,
pid_t object_pid) {
int rl, r;
char *c;
assert(s);
if (n == 0)
return;
return;
/* Stop early in case the information will not be stored
* in a journal. */
if (s->storage == STORAGE_NONE)
return;
if (!ucred)
goto finish;
if (r < 0)
goto finish;
*
* So let's cut of everything past the third /, since that is
* where user directories start */
if (c) {
if (c) {
if (c)
*c = 0;
}
}
if (rl == 0)
return;
/* Write a suppression message if we suppressed something */
if (rl > 1)
}
int r;
char *fn;
char ids[33];
r = sd_id128_get_machine(&machine);
if (r < 0)
return log_error_errno(r, "Failed to get machine id: %m");
if (!s->system_journal &&
/* If in auto mode: first try to create the machine
* path, but not the prefix.
*
* the machine path */
if (s->storage == STORAGE_PERSISTENT)
r = journal_file_open_reliably(fn, O_RDWR|O_CREAT, 0640, s->compress, s->seal, &s->system_metrics, s->mmap, NULL, &s->system_journal);
if (r >= 0)
server_fix_perms(s, s->system_journal, 0);
else if (r < 0) {
log_warning_errno(r, "Failed to open system journal: %m");
r = 0;
}
}
if (!s->runtime_journal &&
(s->storage != STORAGE_NONE)) {
if (!fn)
return -ENOMEM;
if (s->system_journal) {
/* Try to open the runtime journal, but only
* if it already exists, so that we can flush
* it into the system journal */
r = journal_file_open(fn, O_RDWR, 0640, s->compress, false, &s->runtime_metrics, s->mmap, NULL, &s->runtime_journal);
if (r < 0) {
if (r != -ENOENT)
log_warning_errno(r, "Failed to open runtime journal: %m");
r = 0;
}
} else {
/* OK, we really need the runtime journal, so create
* it if necessary. */
r = journal_file_open_reliably(fn, O_RDWR|O_CREAT, 0640, s->compress, false, &s->runtime_metrics, s->mmap, NULL, &s->runtime_journal);
if (r < 0)
return log_error_errno(r, "Failed to open runtime journal: %m");
}
if (s->runtime_journal)
server_fix_perms(s, s->runtime_journal, 0);
}
available_space(s, true);
return r;
}
int server_flush_to_var(Server *s) {
sd_journal *j = NULL;
char ts[FORMAT_TIMESPAN_MAX];
unsigned n = 0;
int r;
assert(s);
if (s->storage != STORAGE_AUTO &&
s->storage != STORAGE_PERSISTENT)
return 0;
if (!s->runtime_journal)
return 0;
system_journal_open(s, true);
if (!s->system_journal)
return 0;
log_debug("Flushing to /var...");
r = sd_id128_get_machine(&machine);
if (r < 0)
return r;
r = sd_journal_open(&j, SD_JOURNAL_RUNTIME_ONLY);
if (r < 0)
return log_error_errno(r, "Failed to read runtime journal: %m");
SD_JOURNAL_FOREACH(j) {
JournalFile *f;
f = j->current_file;
assert(f && f->current_offset > 0);
n++;
if (r < 0) {
log_error_errno(r, "Can't read entry: %m");
goto finish;
}
if (r >= 0)
continue;
if (!shall_try_append_again(s->system_journal, r)) {
log_error_errno(r, "Can't write entry: %m");
goto finish;
}
server_rotate(s);
server_vacuum(s);
if (!s->system_journal) {
log_notice("Didn't flush runtime journal since rotation of system journal wasn't successful.");
r = -EIO;
goto finish;
}
log_debug("Retrying write.");
if (r < 0) {
log_error_errno(r, "Can't write entry: %m");
goto finish;
}
}
s->runtime_journal = NULL;
if (r >= 0)
sd_journal_close(j);
server_driver_message(s, SD_ID128_NULL, "Time spent on flushing to /var is %s for %u entries.", format_timespan(ts, sizeof(ts), now(CLOCK_MONOTONIC) - start, 0), n);
return r;
}
assert(s);
return -EIO;
}
for (;;) {
union {
/* We use NAME_MAX space for the SELinux label
* here. The kernel currently enforces no
* limit, but according to suggestions from
* the SELinux people this will change and it
* will probably be identical to NAME_MAX. For
* now we use that, but this should be updated
* one day when the final limit is known. */
CMSG_SPACE(sizeof(struct timeval)) +
CMSG_SPACE(sizeof(int)) + /* fd */
} control = {};
union sockaddr_union sa = {};
.msg_iovlen = 1,
.msg_control = &control,
.msg_controllen = sizeof(control),
.msg_namelen = sizeof(sa),
};
ssize_t n;
unsigned n_fds = 0;
int v = 0;
size_t m;
/* Try to get the right size, if we can. (Not all
* sockets support SIOCINQ, hence we just try, but
* don't rely on it. */
/* Fix it up, if it is too small. We use the same fixed value as auditd here. Awful! */
return log_oom();
if (n < 0) {
return 0;
return -errno;
}
}
}
/* And a trailing NUL, just in case */
s->buffer[n] = 0;
if (n > 0 && n_fds == 0)
else if (n_fds > 0)
log_warning("Got file descriptors via syslog socket. Ignoring.");
if (n > 0 && n_fds == 0)
else if (n == 0 && n_fds == 1)
else if (n_fds > 0)
log_warning("Got too many file descriptors via native socket. Ignoring.");
} else {
if (n > 0 && n_fds == 0)
else if (n_fds > 0)
log_warning("Got file descriptors via audit socket. Ignoring.");
}
}
}
static int dispatch_sigusr1(sd_event_source *es, const struct signalfd_siginfo *si, void *userdata) {
assert(s);
server_sync(s);
server_vacuum(s);
return 0;
}
static int dispatch_sigusr2(sd_event_source *es, const struct signalfd_siginfo *si, void *userdata) {
assert(s);
server_rotate(s);
server_vacuum(s);
return 0;
}
static int dispatch_sigterm(sd_event_source *es, const struct signalfd_siginfo *si, void *userdata) {
assert(s);
sd_event_exit(s->event, 0);
return 0;
}
static int setup_signals(Server *s) {
int r;
assert(s);
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
if (r < 0)
return r;
return 0;
}
static int server_parse_proc_cmdline(Server *s) {
const char *w, *state;
size_t l;
int r;
r = proc_cmdline(&line);
if (r < 0) {
log_warning_errno(r, "Failed to read /proc/cmdline, ignoring: %m");
return 0;
}
_cleanup_free_ char *word;
if (!word)
return -ENOMEM;
if (r < 0)
else
s->forward_to_syslog = r;
if (r < 0)
else
s->forward_to_kmsg = r;
if (r < 0)
else
s->forward_to_console = r;
if (r < 0)
else
s->forward_to_wall = r;
log_warning("Invalid systemd.journald parameter. Ignoring.");
}
/* do not warn about state here, since probably systemd already did */
return 0;
}
static int server_parse_config_file(Server *s) {
assert(s);
return config_parse_many("/etc/systemd/journald.conf",
"Journal\0",
false, s);
}
assert(s);
server_sync(s);
return 0;
}
int r;
assert(s);
/* Immediately sync to disk when this is of priority CRIT, ALERT, EMERG */
server_sync(s);
return 0;
}
if (s->sync_scheduled)
return 0;
if (s->sync_interval_usec > 0) {
if (r < 0)
return r;
when += s->sync_interval_usec;
if (!s->sync_event_source) {
r = sd_event_add_time(
s->event,
&s->sync_event_source,
when, 0,
server_dispatch_sync, s);
if (r < 0)
return r;
} else {
if (r < 0)
return r;
}
if (r < 0)
return r;
s->sync_scheduled = true;
}
return 0;
}
static int dispatch_hostname_change(sd_event_source *es, int fd, uint32_t revents, void *userdata) {
assert(s);
return 0;
}
static int server_open_hostname(Server *s) {
int r;
assert(s);
if (s->hostname_fd < 0)
r = sd_event_add_io(s->event, &s->hostname_event_source, s->hostname_fd, 0, dispatch_hostname_change, s);
if (r < 0) {
/* kernels prior to 3.2 don't support polling this file. Ignore
* the failure. */
if (r == -EPERM) {
log_warning("Failed to register hostname fd in event loop: %s. Ignoring.",
strerror(-r));
return 0;
}
return log_error_errno(r, "Failed to register hostname fd in event loop: %m");
}
if (r < 0)
return log_error_errno(r, "Failed to adjust priority of host name event source: %m");
return 0;
}
int server_init(Server *s) {
int n, r, fd;
assert(s);
zero(*s);
s->compress = true;
s->seal = true;
s->sync_scheduled = false;
s->forward_to_wall = true;
s->max_level_store = LOG_DEBUG;
s->max_level_syslog = LOG_DEBUG;
s->max_level_kmsg = LOG_NOTICE;
s->max_level_console = LOG_INFO;
s->max_level_wall = LOG_EMERG;
if (!!s->rate_limit_interval ^ !!s->rate_limit_burst) {
s->rate_limit_interval, s->rate_limit_burst);
s->rate_limit_interval = s->rate_limit_burst = 0;
}
if (!s->user_journals)
return log_oom();
s->mmap = mmap_cache_new();
if (!s->mmap)
return log_oom();
r = sd_event_default(&s->event);
if (r < 0)
return log_error_errno(r, "Failed to create event loop: %m");
sd_event_set_watchdog(s->event, true);
n = sd_listen_fds(true);
if (n < 0)
return log_error_errno(n, "Failed to read listening file descriptors from environment: %m");
if (s->native_fd >= 0) {
log_error("Too many native sockets passed.");
return -EINVAL;
}
if (s->stdout_fd >= 0) {
log_error("Too many stdout sockets passed.");
return -EINVAL;
}
if (s->syslog_fd >= 0) {
return -EINVAL;
}
if (s->audit_fd >= 0) {
log_error("Too many audit sockets passed.");
return -EINVAL;
}
} else {
/* Let's close the fd, better be safe than
sorry. The fd might reference some resource
that we really want to release if we don't
make use of it. */
safe_close(fd);
}
}
r = server_open_syslog_socket(s);
if (r < 0)
return r;
r = server_open_native_socket(s);
if (r < 0)
return r;
r = server_open_stdout_socket(s);
if (r < 0)
return r;
r = server_open_dev_kmsg(s);
if (r < 0)
return r;
r = server_open_audit(s);
if (r < 0)
return r;
r = server_open_kernel_seqnum(s);
if (r < 0)
return r;
r = server_open_hostname(s);
if (r < 0)
return r;
r = setup_signals(s);
if (r < 0)
return r;
if (!s->udev)
return -ENOMEM;
if (!s->rate_limit)
return -ENOMEM;
r = cg_get_root_path(&s->cgroup_root);
if (r < 0)
return r;
r = system_journal_open(s, false);
if (r < 0)
return r;
return 0;
}
void server_maybe_append_tags(Server *s) {
#ifdef HAVE_GCRYPT
JournalFile *f;
Iterator i;
usec_t n;
n = now(CLOCK_REALTIME);
if (s->system_journal)
ORDERED_HASHMAP_FOREACH(f, s->user_journals, i)
#endif
}
void server_done(Server *s) {
JournalFile *f;
assert(s);
while (s->stdout_streams)
if (s->system_journal)
if (s->runtime_journal)
while ((f = ordered_hashmap_steal_first(s->user_journals)))
sd_event_unref(s->event);
safe_close(s->syslog_fd);
safe_close(s->native_fd);
safe_close(s->stdout_fd);
safe_close(s->dev_kmsg_fd);
safe_close(s->audit_fd);
safe_close(s->hostname_fd);
if (s->rate_limit)
if (s->kernel_seqnum)
free(s->cgroup_root);
free(s->hostname_field);
if (s->mmap)
mmap_cache_unref(s->mmap);
if (s->udev)
udev_unref(s->udev);
}