journald-server.c revision 4ec3cd7391e119b597375c547cf4ed50fce9f115
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering This file is part of systemd.
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering Copyright 2011 Lennart Poettering
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering systemd is free software; you can redistribute it and/or modify it
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering under the terms of the GNU Lesser General Public License as published by
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering (at your option) any later version.
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering systemd is distributed in the hope that it will be useful, but
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering Lesser General Public License for more details.
5430f7f2bc7330f3088b894166bf3524a067e3d8Lennart Poettering You should have received a copy of the GNU Lesser General Public License
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering#define DEFAULT_SYNC_INTERVAL_USEC (5*USEC_PER_MINUTE)
bb99a35a873c35e80b0b47fe045081022660374dLennart Poettering#define DEFAULT_RATE_LIMIT_INTERVAL (30*USEC_PER_SEC)
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering#define DEFAULT_MAX_FILE_USEC USEC_PER_MONTH
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering#define RECHECK_AVAILABLE_SPACE_USEC (30*USEC_PER_SEC)
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poetteringstatic const char* const storage_table[_STORAGE_MAX] = {
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart PoetteringDEFINE_STRING_TABLE_LOOKUP(storage, Storage);
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart PoetteringDEFINE_CONFIG_PARSE_ENUM(config_parse_storage, storage, Storage, "Failed to parse storage setting");
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poetteringstatic const char* const split_mode_table[_SPLIT_MAX] = {
18c7ed186be28800a2eeb37ad31c9c44480d3d9cLennart PoetteringDEFINE_STRING_TABLE_LOOKUP(split_mode, SplitMode);
18c7ed186be28800a2eeb37ad31c9c44480d3d9cLennart PoetteringDEFINE_CONFIG_PARSE_ENUM(config_parse_split_mode, split_mode, SplitMode, "Failed to parse split mode setting");
18c7ed186be28800a2eeb37ad31c9c44480d3d9cLennart Poetteringstatic uint64_t available_space(Server *s, bool verbose) {
1ae464e09376853c52075ec4d8a6bfc4b4036d0cThomas Hindoe Paaboel Andersen uint64_t sum = 0, ss_avail = 0, avail = 0;
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering const char *f;
d0bbc21caa6e68693a47db60c93e99422bf2a858Lennart Poettering if (s->cached_available_space_timestamp + RECHECK_AVAILABLE_SPACE_USEC > ts
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering p = strappend(f, sd_id128_to_string(machine, ids));
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering if (fstatat(dirfd(d), de->d_name, &st, AT_SYMLINK_NOFOLLOW) < 0)
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering /* If we reached a high mark, we will always allow this much
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering * again, unless usage goes above max_use. This watermark
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering * value is cached so that we don't give up space on pressure,
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering * but hover below the maximum usage. */
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering s->cached_available_space = LESS_BY(MIN(m->max_use, avail), sum);
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering s->cached_available_space_timestamp = ts;
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering char fb1[FORMAT_BYTES_MAX], fb2[FORMAT_BYTES_MAX], fb3[FORMAT_BYTES_MAX],
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering fb4[FORMAT_BYTES_MAX], fb5[FORMAT_BYTES_MAX];
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering server_driver_message(s, SD_MESSAGE_JOURNAL_USAGE,
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering "%s journal is using %s (max allowed %s, "
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering "trying to leave %s free of %s available → current limit %s).",
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering s->system_journal ? "Permanent" : "Runtime",
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering format_bytes(fb2, sizeof(fb2), m->max_use),
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering format_bytes(fb3, sizeof(fb3), m->keep_free),
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering format_bytes(fb4, sizeof(fb4), ss_avail),
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering format_bytes(fb5, sizeof(fb5), s->cached_available_space + sum));
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poetteringvoid server_fix_perms(Server *s, JournalFile *f, uid_t uid) {
5c0aa72a4999bdcf03fe93ed5c8213c2b4c681f0Lennart Poettering log_warning_errno(r, "Failed to fix access mode on %s, ignoring: %m", f->path);
6e5abe1564070a760196b97031eca9cf5e95e8a2Zbigniew Jędrzejewski-Szmek log_warning_errno(errno, "Failed to read ACL on %s, ignoring: %m", f->path);
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering if (acl_create_entry(&acl, &entry) < 0 ||
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering log_warning_errno(errno, "Failed to patch ACL on %s, ignoring: %m", f->path);
5c0aa72a4999bdcf03fe93ed5c8213c2b4c681f0Lennart Poettering /* We do not recalculate the mask unconditionally here,
a5344d2c3b0f14e954ce1c0ef905c5b44bc5bf0aLennart Poettering * so that the fchmod() mask above stays intact. */
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering if (acl_get_permset(entry, &permset) < 0 ||
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering log_warning_errno(errno, "Failed to patch ACL on %s, ignoring: %m", f->path);
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering log_warning_errno(errno, "Failed to set ACL on %s, ignoring: %m", f->path);
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poetteringstatic JournalFile* find_journal(Server *s, uid_t uid) {
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering /* We split up user logs only on /var, not on /run. If the
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering * runtime file is open, we write to it exclusively, in order
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering * to guarantee proper order as soon as we flush /run to
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering * /var and close the runtime file. */
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering f = ordered_hashmap_get(s->user_journals, UINT32_TO_PTR(uid));
ee55db41442ad8055f5a84a339b1e0e22bc037c4Lennart Poettering if (asprintf(&p, "/var/log/journal/" SD_ID128_FORMAT_STR "/user-"UID_FMT".journal",
ee55db41442ad8055f5a84a339b1e0e22bc037c4Lennart Poettering while (ordered_hashmap_size(s->user_journals) >= USER_JOURNALS_MAX) {
ee55db41442ad8055f5a84a339b1e0e22bc037c4Lennart Poettering /* Too many open? Then let's close one */
ee55db41442ad8055f5a84a339b1e0e22bc037c4Lennart Poettering f = ordered_hashmap_steal_first(s->user_journals);
ee55db41442ad8055f5a84a339b1e0e22bc037c4Lennart Poettering r = journal_file_open_reliably(p, O_RDWR|O_CREAT, 0640, s->compress, s->seal, &s->system_metrics, s->mmap, NULL, &f);
7f3e62571a63ac90de6ac5eefeeb8d3e9aa6f49eLennart Poettering r = ordered_hashmap_put(s->user_journals, UINT32_TO_PTR(uid), f);
6c045c0b4c49c88a1d3b9360c05efa5084796d2dZbigniew Jędrzejewski-Szmekstatic int do_rotate(Server *s, JournalFile **f, const char* name,
8e33886ec582336564ae11b80023abe93d7599c0Zbigniew Jędrzejewski-Szmek r = journal_file_rotate(f, s->compress, seal);
c79e98eadd3056a36a662699fa650db5b1bca0c3Lennart Poettering log_error_errno(r, "Failed to rotate %s: %m",
c79e98eadd3056a36a662699fa650db5b1bca0c3Lennart Poettering log_error_errno(r, "Failed to create new %s journal: %m",
c79e98eadd3056a36a662699fa650db5b1bca0c3Lennart Poettering do_rotate(s, &s->runtime_journal, "runtime", false, 0);
73843b52585d42cc1a970a1c664818ece6942e9eLennart Poettering do_rotate(s, &s->system_journal, "system", s->seal, 0);
73843b52585d42cc1a970a1c664818ece6942e9eLennart Poettering ORDERED_HASHMAP_FOREACH_KEY(f, k, s->user_journals, i) {
c79e98eadd3056a36a662699fa650db5b1bca0c3Lennart Poettering r = do_rotate(s, &f, "user", s->seal, PTR_TO_UINT32(k));
3ee897d6c2401effbc82f5eef35fce405781d6c8Lennart Poettering ordered_hashmap_replace(s->user_journals, k, f);
fe6521272ba203ec8f0d5a94f0729960b3f90525Lennart Poettering /* Old file has been closed and deallocated */
18c7ed186be28800a2eeb37ad31c9c44480d3d9cLennart Poettering ordered_hashmap_remove(s->user_journals, k);
18c7ed186be28800a2eeb37ad31c9c44480d3d9cLennart Poettering r = journal_file_set_offline(s->system_journal);
18c7ed186be28800a2eeb37ad31c9c44480d3d9cLennart Poettering log_error_errno(r, "Failed to sync system journal: %m");
18c7ed186be28800a2eeb37ad31c9c44480d3d9cLennart Poettering ORDERED_HASHMAP_FOREACH_KEY(f, k, s->user_journals, i) {
18c7ed186be28800a2eeb37ad31c9c44480d3d9cLennart Poettering log_error_errno(r, "Failed to sync user journal: %m");
18c7ed186be28800a2eeb37ad31c9c44480d3d9cLennart Poettering r = sd_event_source_set_enabled(s->sync_event_source, SD_EVENT_OFF);
18c7ed186be28800a2eeb37ad31c9c44480d3d9cLennart Poettering log_error_errno(r, "Failed to disable sync timer source: %m");
18c7ed186be28800a2eeb37ad31c9c44480d3d9cLennart Poetteringstatic void do_vacuum(Server *s, char *ids, JournalFile *f, const char* path,
18c7ed186be28800a2eeb37ad31c9c44480d3d9cLennart Poettering r = journal_directory_vacuum(p, metrics->max_use, s->max_retention_usec, &s->oldest_file_usec, false);
18c7ed186be28800a2eeb37ad31c9c44480d3d9cLennart Poettering if (r < 0 && r != -ENOENT)
18c7ed186be28800a2eeb37ad31c9c44480d3d9cLennart Poettering log_error_errno(r, "Failed to vacuum %s: %m", p);
61c024b328d5493a334242a4d01ba923582093faZbigniew Jędrzejewski-Szmek log_error_errno(r, "Failed to get machine ID: %m");
1ae464e09376853c52075ec4d8a6bfc4b4036d0cThomas Hindoe Paaboel Andersen sd_id128_to_string(machine, ids);
fe6521272ba203ec8f0d5a94f0729960b3f90525Lennart Poettering do_vacuum(s, ids, s->system_journal, "/var/log/journal/", &s->system_metrics);
fe6521272ba203ec8f0d5a94f0729960b3f90525Lennart Poettering do_vacuum(s, ids, s->runtime_journal, "/run/log/journal/", &s->runtime_metrics);
fe6521272ba203ec8f0d5a94f0729960b3f90525Lennart Poetteringstatic void server_cache_machine_id(Server *s) {
4cd9a9d9ecf3a8835e21930f3215a5f5b74144beLennart Poettering sd_id128_to_string(id, stpcpy(s->machine_id_field, "_MACHINE_ID="));
4cd9a9d9ecf3a8835e21930f3215a5f5b74144beLennart Poetteringstatic void server_cache_boot_id(Server *s) {
224f2ee221e77c326d1d7761abb6e812432b2163Lennart Poettering sd_id128_to_string(id, stpcpy(s->boot_id_field, "_BOOT_ID="));
fe6521272ba203ec8f0d5a94f0729960b3f90525Lennart Poetteringstatic void server_cache_hostname(Server *s) {
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poetteringbool shall_try_append_again(JournalFile *f, int r) {
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering /* -E2BIG Hit configured limit
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering -EFBIG Hit fs limit
5ffa8c818120e35c89becd938d160235c069dd12Zbigniew Jędrzejewski-Szmek -EDQUOT Quota limit hit
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering -ENOSPC Disk full
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering -EHOSTDOWN Other machine
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering -EBUSY Unclean shutdown
1ae464e09376853c52075ec4d8a6bfc4b4036d0cThomas Hindoe Paaboel Andersen -EPROTONOSUPPORT Unsupported feature
1ae464e09376853c52075ec4d8a6bfc4b4036d0cThomas Hindoe Paaboel Andersen -EBADMSG Corrupted
1ae464e09376853c52075ec4d8a6bfc4b4036d0cThomas Hindoe Paaboel Andersen -ENODATA Truncated
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering -ESHUTDOWN Already archived */
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering if (r == -E2BIG || r == -EFBIG || r == -EDQUOT || r == -ENOSPC)
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering log_debug("%s: Allocation limit reached, rotating.", f->path);
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering else if (r == -EHOSTDOWN)
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering log_info("%s: Journal file from other machine, rotating.", f->path);
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering else if (r == -EBUSY)
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering log_info("%s: Unclean shutdown, rotating.", f->path);
3ed08c446cfaaae2b234fdfeb0c34ab6b4748c3eLennart Poettering log_info("%s: Unsupported feature, rotating.", f->path);
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering else if (r == -EBADMSG || r == -ENODATA || r == ESHUTDOWN)
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering log_warning("%s: Journal file corrupted, rotating.", f->path);
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poetteringstatic void write_to_journal(Server *s, uid_t uid, struct iovec *iovec, unsigned n, int priority) {
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering if (journal_file_rotate_suggested(f, s->max_file_usec)) {
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering log_debug("%s: Journal header limits reached or header out-of-date, rotating.", f->path);
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering r = journal_file_append_entry(f, NULL, iovec, n, &s->seqnum, NULL, NULL);
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering if (vacuumed || !shall_try_append_again(f, r)) {
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering for (i = 0; i < n; i++)
18c7ed186be28800a2eeb37ad31c9c44480d3d9cLennart Poettering log_error_errno(r, "Failed to write entry (%d items, %zu bytes), ignoring: %m", n, size);
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering r = journal_file_append_entry(f, NULL, iovec, n, &s->seqnum, NULL, NULL);
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering for (i = 0; i < n; i++)
b070e7f3c9ed680c821bd89d42506695f2438506Lennart Poettering log_error_errno(r, "Failed to write entry (%d items, %zu bytes) despite vacuuming, ignoring: %m", n, size);
18c7ed186be28800a2eeb37ad31c9c44480d3d9cLennart Poettering struct iovec *iovec, unsigned n, unsigned m,
18c7ed186be28800a2eeb37ad31c9c44480d3d9cLennart Poettering char pid[sizeof("_PID=") + DECIMAL_STR_MAX(pid_t)],
18c7ed186be28800a2eeb37ad31c9c44480d3d9cLennart Poettering uid[sizeof("_UID=") + DECIMAL_STR_MAX(uid_t)],
18c7ed186be28800a2eeb37ad31c9c44480d3d9cLennart Poettering gid[sizeof("_GID=") + DECIMAL_STR_MAX(gid_t)],
18c7ed186be28800a2eeb37ad31c9c44480d3d9cLennart Poettering owner_uid[sizeof("_SYSTEMD_OWNER_UID=") + DECIMAL_STR_MAX(uid_t)],
bool owner_valid = false;
#ifdef HAVE_AUDIT
assert(s);
assert(n > 0);
if (ucred) {
free(t);
free(t);
free(t);
free(t);
#ifdef HAVE_AUDIT
r = cg_path_get_session(c, &t);
free(t);
owner_valid = true;
if (cg_path_get_unit(c, &t) >= 0) {
free(t);
if (cg_path_get_user_unit(c, &t) >= 0) {
free(t);
if (cg_path_get_slice(c, &t) >= 0) {
free(t);
free(c);
} else if (unit_id) {
#ifdef HAVE_SELINUX
if (mac_selinux_use()) {
if (label) {
assert(n <= m);
if (object_pid) {
free(t);
free(t);
free(t);
#ifdef HAVE_AUDIT
r = cg_path_get_session(c, &t);
free(t);
if (cg_path_get_unit(c, &t) >= 0) {
free(t);
if (cg_path_get_user_unit(c, &t) >= 0) {
free(t);
free(c);
assert(n <= m);
if (tv) {
assert(n <= m);
journal_uid = 0;
assert(s);
void server_dispatch_message(
Server *s,
const char *unit_id,
int priority,
int rl, r;
assert(s);
if (!ucred)
goto finish;
goto finish;
if (rl == 0)
char *fn;
if (!s->system_journal &&
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 (!s->runtime_journal &&
if (!fn)
return -ENOMEM;
if (s->system_journal) {
r = journal_file_open(fn, O_RDWR, 0640, s->compress, false, &s->runtime_metrics, s->mmap, NULL, &s->runtime_journal);
if (r != -ENOENT)
r = journal_file_open_reliably(fn, O_RDWR|O_CREAT, 0640, s->compress, false, &s->runtime_metrics, s->mmap, NULL, &s->runtime_journal);
if (s->runtime_journal)
available_space(s, true);
assert(s);
if (!s->runtime_journal)
system_journal_open(s, true);
if (!s->system_journal)
SD_JOURNAL_FOREACH(j) {
JournalFile *f;
f = j->current_file;
goto finish;
goto finish;
server_rotate(s);
server_vacuum(s);
if (!s->system_journal) {
r = -EIO;
goto finish;
goto finish;
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);
assert(s);
return -EIO;
} control = {};
ssize_t n;
unsigned n_fds = 0;
size_t m;
return log_oom();
return -errno;
s->buffer[n] = 0;
if (n > 0 && n_fds == 0)
else if (n_fds > 0)
if (n > 0 && n_fds == 0)
else if (n_fds > 0)
if (n > 0 && n_fds == 0)
else if (n_fds > 0)
static int dispatch_sigusr1(sd_event_source *es, const struct signalfd_siginfo *si, void *userdata) {
assert(s);
server_sync(s);
server_vacuum(s);
static int dispatch_sigusr2(sd_event_source *es, const struct signalfd_siginfo *si, void *userdata) {
assert(s);
server_rotate(s);
server_vacuum(s);
static int dispatch_sigterm(sd_event_source *es, const struct signalfd_siginfo *si, void *userdata) {
assert(s);
assert(s);
const char *w, *state;
size_t l;
if (!word)
return -ENOMEM;
s->forward_to_syslog = r;
s->forward_to_kmsg = r;
s->forward_to_console = r;
s->forward_to_wall = r;
assert(s);
assert(s);
server_sync(s);
assert(s);
server_sync(s);
if (s->sync_scheduled)
if (s->sync_interval_usec > 0) {
if (!s->sync_event_source) {
r = sd_event_add_time(
s->event,
&s->sync_event_source,
when, 0,
server_dispatch_sync, s);
s->sync_scheduled = true;
static int dispatch_hostname_change(sd_event_source *es, int fd, uint32_t revents, void *userdata) {
assert(s);
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 == -EPERM) {
strerror(-r));
int n, r, fd;
assert(s);
zero(*s);
s->compress = true;
s->seal = true;
s->sync_scheduled = false;
s->forward_to_wall = true;
if (!s->user_journals)
return log_oom();
if (!s->mmap)
return log_oom();
n = sd_listen_fds(true);
if (s->native_fd >= 0) {
return -EINVAL;
if (s->stdout_fd >= 0) {
return -EINVAL;
if (s->syslog_fd >= 0) {
return -EINVAL;
if (s->audit_fd >= 0) {
return -EINVAL;
r = server_open_syslog_socket(s);
r = server_open_native_socket(s);
r = server_open_stdout_socket(s);
r = server_open_dev_kmsg(s);
r = server_open_audit(s);
r = server_open_kernel_seqnum(s);
r = server_open_hostname(s);
r = setup_signals(s);
if (!s->udev)
return -ENOMEM;
if (!s->rate_limit)
return -ENOMEM;
r = system_journal_open(s, false);
#ifdef HAVE_GCRYPT
JournalFile *f;
Iterator i;
usec_t n;
if (s->system_journal)
JournalFile *f;
assert(s);
while (s->stdout_streams)
if (s->system_journal)
if (s->runtime_journal)
if (s->rate_limit)
if (s->kernel_seqnum)
if (s->mmap)
if (s->udev)