journald: rename primary object from "Server" to "Manager"

In all our daemons the primary entrypoint object is called "Manager".
But so far there was one exception: in journald it was called "Server".
Let's normalize that, and stick to the same nomenclature everywhere, to
make journald less special.

No real code change, just some search&replace.
This commit is contained in:
Lennart Poettering
2025-05-14 13:02:26 +02:00
parent d6319768bd
commit c55f87062d
37 changed files with 1208 additions and 1195 deletions
+4 -4
View File
@@ -5,13 +5,13 @@
#include "journald-audit.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_(server_freep) Server *s = NULL;
_cleanup_(manager_freep) Manager *m = NULL;
fuzz_setup_logging();
assert_se(server_new(&s) >= 0);
dummy_server_init(s, data, size);
process_audit_string(s, 0, s->buffer, size);
assert_se(manager_new(&m) >= 0);
dummy_manager_init(m, data, size);
process_audit_string(m, 0, m->buffer, size);
return 0;
}
+4 -4
View File
@@ -5,16 +5,16 @@
#include "journald-kmsg.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_(server_freep) Server *s = NULL;
_cleanup_(manager_freep) Manager *m = NULL;
if (size == 0)
return 0;
fuzz_setup_logging();
assert_se(server_new(&s) >= 0);
dummy_server_init(s, data, size);
dev_kmsg_record(s, s->buffer, size);
assert_se(manager_new(&m) >= 0);
dummy_manager_init(m, data, size);
dev_kmsg_record(m, m->buffer, size);
return 0;
}
+5 -5
View File
@@ -10,7 +10,7 @@
#include "tmpfile-util.h"
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_(server_freep) Server *s = NULL;
_cleanup_(manager_freep) Manager *m = NULL;
_cleanup_close_ int sealed_fd = -EBADF, unsealed_fd = -EBADF;
_cleanup_(unlink_tempfilep) char name[] = "/tmp/fuzz-journald-native-fd.XXXXXX";
char *label = NULL;
@@ -20,8 +20,8 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
fuzz_setup_logging();
assert_se(server_new(&s) >= 0);
dummy_server_init(s, NULL, 0);
assert_se(manager_new(&m) >= 0);
dummy_manager_init(m, NULL, 0);
sealed_fd = memfd_new_and_seal(NULL, data, size);
assert_se(sealed_fd >= 0);
@@ -30,13 +30,13 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
.uid = geteuid(),
.gid = getegid(),
};
(void) server_process_native_file(s, sealed_fd, &ucred, tv, label, label_len);
(void) manager_process_native_file(m, sealed_fd, &ucred, tv, label, label_len);
unsealed_fd = mkostemp_safe(name);
assert_se(unsealed_fd >= 0);
assert_se(write(unsealed_fd, data, size) == (ssize_t) size);
assert_se(lseek(unsealed_fd, 0, SEEK_SET) == 0);
(void) server_process_native_file(s, unsealed_fd, &ucred, tv, label, label_len);
(void) manager_process_native_file(m, unsealed_fd, &ucred, tv, label, label_len);
return 0;
}
+1 -1
View File
@@ -7,6 +7,6 @@
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
fuzz_setup_logging();
fuzz_journald_processing_function(data, size, server_process_native_message);
fuzz_journald_processing_function(data, size, manager_process_native_message);
return 0;
}
+6 -6
View File
@@ -11,7 +11,7 @@
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
_cleanup_close_pair_ int stream_fds[2] = EBADF_PAIR;
_cleanup_(server_freep) Server *s = NULL;
_cleanup_(manager_freep) Manager *m = NULL;
StdoutStream *stream;
int v, fd0;
@@ -21,17 +21,17 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
fuzz_setup_logging();
assert_se(socketpair(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0, stream_fds) >= 0);
assert_se(server_new(&s) >= 0);
dummy_server_init(s, NULL, 0);
assert_se(manager_new(&m) >= 0);
dummy_manager_init(m, NULL, 0);
assert_se(stdout_stream_install(s, stream_fds[0], &stream) >= 0);
assert_se(stdout_stream_install(m, stream_fds[0], &stream) >= 0);
fd0 = TAKE_FD(stream_fds[0]); /* avoid double close */
assert_se(write(stream_fds[1], data, size) == (ssize_t) size);
while (ioctl(fd0, SIOCINQ, &v) == 0 && v)
sd_event_run(s->event, UINT64_MAX);
sd_event_run(m->event, UINT64_MAX);
if (s->n_stdout_streams > 0)
if (m->n_stdout_streams > 0)
stdout_stream_terminate(stream);
return 0;
+1 -1
View File
@@ -7,6 +7,6 @@
int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) {
fuzz_setup_logging();
fuzz_journald_processing_function(data, size, server_process_syslog_message);
fuzz_journald_processing_function(data, size, manager_process_syslog_message);
return 0;
}
+12 -12
View File
@@ -4,27 +4,27 @@
#include "alloc-util.h"
#include "fuzz-journald.h"
#include "journald-server.h"
#include "journald-manager.h"
void dummy_server_init(Server *s, const uint8_t *buffer, size_t size) {
assert(s);
void dummy_manager_init(Manager *m, const uint8_t *buffer, size_t size) {
assert(m);
s->storage = STORAGE_NONE;
assert_se(sd_event_default(&s->event) >= 0);
m->storage = STORAGE_NONE;
assert_se(sd_event_default(&m->event) >= 0);
if (buffer) {
s->buffer = memdup_suffix0(buffer, size);
assert_se(s->buffer);
m->buffer = memdup_suffix0(buffer, size);
assert_se(m->buffer);
}
}
void fuzz_journald_processing_function(
const uint8_t *data,
size_t size,
void (*f)(Server *s, const char *buf, size_t raw_len, const struct ucred *ucred, const struct timeval *tv, const char *label, size_t label_len)
void (*f)(Manager *m, const char *buf, size_t raw_len, const struct ucred *ucred, const struct timeval *tv, const char *label, size_t label_len)
) {
_cleanup_(server_freep) Server *s = NULL;
_cleanup_(manager_freep) Manager *m = NULL;
char *label = NULL;
size_t label_len = 0;
struct ucred *ucred = NULL;
@@ -33,7 +33,7 @@ void fuzz_journald_processing_function(
if (size == 0)
return;
assert_se(server_new(&s) >= 0);
dummy_server_init(s, data, size);
(*f)(s, s->buffer, size, ucred, tv, label, label_len);
assert_se(manager_new(&m) >= 0);
dummy_manager_init(m, data, size);
(*f)(m, m->buffer, size, ucred, tv, label, label_len);
}
+3 -3
View File
@@ -1,12 +1,12 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "journald-server.h"
#include "journald-manager.h"
void dummy_server_init(Server *s, const uint8_t *buffer, size_t size);
void dummy_manager_init(Manager *m, const uint8_t *buffer, size_t size);
void fuzz_journald_processing_function(
const uint8_t *data,
size_t size,
void (*f)(Server *s, const char *buf, size_t raw_len, const struct ucred *ucred, const struct timeval *tv, const char *label, size_t label_len)
void (*f)(Manager *m, const char *buf, size_t raw_len, const struct ucred *ucred, const struct timeval *tv, const char *label, size_t label_len)
);
+25 -25
View File
@@ -10,7 +10,7 @@
#include "iovec-util.h"
#include "journal-internal.h"
#include "journald-audit.h"
#include "journald-server.h"
#include "journald-manager.h"
#include "missing_audit.h"
#include "string-util.h"
@@ -332,17 +332,17 @@ static int map_all_fields(
}
}
void process_audit_string(Server *s, int type, const char *data, size_t size) {
void process_audit_string(Manager *m, int type, const char *data, size_t size) {
size_t n = 0, z;
uint64_t seconds, msec, id;
const char *p, *type_name;
char id_field[STRLEN("_AUDIT_ID=") + DECIMAL_STR_MAX(uint64_t)],
type_field[STRLEN("_AUDIT_TYPE=") + DECIMAL_STR_MAX(int)];
struct iovec iovec[N_IOVEC_META_FIELDS + 7 + N_IOVEC_AUDIT_FIELDS];
char *m, *type_field_name;
char *mm, *type_field_name;
int k;
assert(s);
assert(m);
if (size <= 0)
return;
@@ -390,16 +390,16 @@ void process_audit_string(Server *s, int type, const char *data, size_t size) {
type_field_name = strjoina("_AUDIT_TYPE_NAME=", type_name);
iovec[n++] = IOVEC_MAKE_STRING(type_field_name);
m = strjoina("MESSAGE=", type_name, " ", p);
iovec[n++] = IOVEC_MAKE_STRING(m);
mm = strjoina("MESSAGE=", type_name, " ", p);
iovec[n++] = IOVEC_MAKE_STRING(mm);
z = n;
map_all_fields(p, map_fields_kernel, "_AUDIT_FIELD_", true, iovec, &n, n + N_IOVEC_AUDIT_FIELDS);
server_dispatch_message(s, iovec, n, ELEMENTSOF(iovec), NULL,
TIMEVAL_STORE((usec_t) seconds * USEC_PER_SEC + (usec_t) msec * USEC_PER_MSEC),
LOG_NOTICE, 0);
manager_dispatch_message(m, iovec, n, ELEMENTSOF(iovec), NULL,
TIMEVAL_STORE((usec_t) seconds * USEC_PER_SEC + (usec_t) msec * USEC_PER_MSEC),
LOG_NOTICE, 0);
/* free() all entries that map_all_fields() added. All others
* are allocated on the stack or are constant. */
@@ -408,8 +408,8 @@ void process_audit_string(Server *s, int type, const char *data, size_t size) {
free(iovec[z].iov_base);
}
void server_process_audit_message(
Server *s,
void manager_process_audit_message(
Manager *m,
const void *buffer,
size_t buffer_size,
const struct ucred *ucred,
@@ -418,7 +418,7 @@ void server_process_audit_message(
const struct nlmsghdr *nl = buffer;
assert(s);
assert(m);
if (buffer_size < ALIGN(sizeof(struct nlmsghdr)))
return;
@@ -452,7 +452,7 @@ void server_process_audit_message(
if (nl->nlmsg_type < AUDIT_FIRST_USER_MSG && nl->nlmsg_type != AUDIT_USER)
return;
process_audit_string(s, nl->nlmsg_type, NLMSG_DATA(nl), nl->nlmsg_len - ALIGN(sizeof(struct nlmsghdr)));
process_audit_string(m, nl->nlmsg_type, NLMSG_DATA(nl), nl->nlmsg_len - ALIGN(sizeof(struct nlmsghdr)));
}
static int enable_audit(int fd, bool b) {
@@ -500,18 +500,18 @@ static int enable_audit(int fd, bool b) {
return 0;
}
int server_open_audit(Server *s) {
int manager_open_audit(Manager *m) {
int r;
if (s->audit_fd < 0) {
if (m->audit_fd < 0) {
static const union sockaddr_union sa = {
.nl.nl_family = AF_NETLINK,
.nl.nl_pid = 0,
.nl.nl_groups = AUDIT_NLGRP_READLOG,
};
s->audit_fd = socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC|SOCK_NONBLOCK, NETLINK_AUDIT);
if (s->audit_fd < 0) {
m->audit_fd = socket(AF_NETLINK, SOCK_RAW|SOCK_CLOEXEC|SOCK_NONBLOCK, NETLINK_AUDIT);
if (m->audit_fd < 0) {
if (ERRNO_IS_NOT_SUPPORTED(errno))
log_debug("Audit not supported in the kernel.");
else
@@ -520,31 +520,31 @@ int server_open_audit(Server *s) {
return 0;
}
if (bind(s->audit_fd, &sa.sa, sizeof(sa.nl)) < 0) {
if (bind(m->audit_fd, &sa.sa, sizeof(sa.nl)) < 0) {
log_warning_errno(errno,
"Failed to join audit multicast group. "
"The kernel is probably too old or multicast reading is not supported. "
"Ignoring: %m");
s->audit_fd = safe_close(s->audit_fd);
m->audit_fd = safe_close(m->audit_fd);
return 0;
}
} else
(void) fd_nonblock(s->audit_fd, true);
(void) fd_nonblock(m->audit_fd, true);
r = setsockopt_int(s->audit_fd, SOL_SOCKET, SO_PASSCRED, true);
r = setsockopt_int(m->audit_fd, SOL_SOCKET, SO_PASSCRED, true);
if (r < 0)
return log_error_errno(r, "Failed to set SO_PASSCRED on audit socket: %m");
r = sd_event_add_io(s->event, &s->audit_event_source, s->audit_fd, EPOLLIN, server_process_datagram, s);
r = sd_event_add_io(m->event, &m->audit_event_source, m->audit_fd, EPOLLIN, manager_process_datagram, m);
if (r < 0)
return log_error_errno(r, "Failed to add audit fd to event loop: %m");
if (s->set_audit >= 0) {
if (m->set_audit >= 0) {
/* We are listening now, try to enable audit if configured so */
r = enable_audit(s->audit_fd, s->set_audit);
r = enable_audit(m->audit_fd, m->set_audit);
if (r < 0)
log_warning_errno(r, "Failed to issue audit enable call: %m");
else if (s->set_audit > 0)
else if (m->set_audit > 0)
log_debug("Auditing in kernel turned on.");
else
log_debug("Auditing in kernel turned off.");
+4 -4
View File
@@ -3,10 +3,10 @@
#include "socket-util.h"
typedef struct Server Server;
typedef struct Manager Manager;
void server_process_audit_message(Server *s, const void *buffer, size_t buffer_size, const struct ucred *ucred, const union sockaddr_union *sa, socklen_t salen);
void manager_process_audit_message(Manager *m, const void *buffer, size_t buffer_size, const struct ucred *ucred, const union sockaddr_union *sa, socklen_t salen);
void process_audit_string(Server *s, int type, const char *data, size_t size);
void process_audit_string(Manager *m, int type, const char *data, size_t size);
int server_open_audit(Server *s);
int manager_open_audit(Manager *m);
+6 -6
View File
@@ -10,7 +10,7 @@
#include "format-util.h"
#include "iovec-util.h"
#include "journald-console.h"
#include "journald-server.h"
#include "journald-manager.h"
#include "parse-util.h"
#include "process-util.h"
#include "stdio-util.h"
@@ -31,8 +31,8 @@ static bool prefix_timestamp(void) {
return cached_printk_time;
}
void server_forward_console(
Server *s,
void manager_forward_console(
Manager *m,
int priority,
const char *identifier,
const char *message,
@@ -47,10 +47,10 @@ void server_forward_console(
const char *tty, *color_on = "", *color_off = "";
int n = 0;
assert(s);
assert(m);
assert(message);
if (LOG_PRI(priority) > s->max_level_console)
if (LOG_PRI(priority) > m->max_level_console)
return;
/* First: timestamp */
@@ -89,7 +89,7 @@ void server_forward_console(
iovec[n++] = IOVEC_MAKE_STRING(color_off);
iovec[n++] = IOVEC_MAKE_STRING("\n");
tty = s->tty_path ?: "/dev/console";
tty = m->tty_path ?: "/dev/console";
/* Before you ask: yes, on purpose we open/close the console for each log line we write individually. This is a
* good strategy to avoid journald getting killed by the kernel's SAK concept (it doesn't fix this entirely,
+2 -2
View File
@@ -3,6 +3,6 @@
#include <sys/socket.h>
typedef struct Server Server;
typedef struct Manager Manager;
void server_forward_console(Server *s, int priority, const char *identifier, const char *message, const struct ucred *ucred);
void manager_forward_console(Manager *m, int priority, const char *identifier, const char *message, const struct ucred *ucred);
+78 -78
View File
@@ -16,7 +16,7 @@
#include "journal-util.h"
#include "journald-client.h"
#include "journald-context.h"
#include "journald-server.h"
#include "journald-manager.h"
#include "parse-util.h"
#include "path-util.h"
#include "process-util.h"
@@ -104,15 +104,15 @@ static int client_context_compare(const void *a, const void *b) {
return CMP(x->pid, y->pid);
}
static int client_context_new(Server *s, pid_t pid, ClientContext **ret) {
static int client_context_new(Manager *m, pid_t pid, ClientContext **ret) {
_cleanup_free_ ClientContext *c = NULL;
int r;
assert(s);
assert(m);
assert(pid_is_valid(pid));
assert(ret);
r = prioq_ensure_allocated(&s->client_contexts_lru, client_context_compare);
r = prioq_ensure_allocated(&m->client_contexts_lru, client_context_compare);
if (r < 0)
return r;
@@ -131,12 +131,12 @@ static int client_context_new(Server *s, pid_t pid, ClientContext **ret) {
.timestamp = USEC_INFINITY,
.extra_fields_mtime = NSEC_INFINITY,
.log_level_max = -1,
.log_ratelimit_interval = s->ratelimit_interval,
.log_ratelimit_burst = s->ratelimit_burst,
.log_ratelimit_interval = m->ratelimit_interval,
.log_ratelimit_burst = m->ratelimit_burst,
.capability_quintet = CAPABILITY_QUINTET_NULL,
};
r = hashmap_ensure_put(&s->client_contexts, NULL, PID_TO_PTR(pid), c);
r = hashmap_ensure_put(&m->client_contexts, NULL, PID_TO_PTR(pid), c);
if (r < 0)
return r;
@@ -144,8 +144,8 @@ static int client_context_new(Server *s, pid_t pid, ClientContext **ret) {
return 0;
}
static void client_context_reset(Server *s, ClientContext *c) {
assert(s);
static void client_context_reset(Manager *m, ClientContext *c) {
assert(m);
assert(c);
c->timestamp = USEC_INFINITY;
@@ -180,8 +180,8 @@ static void client_context_reset(Server *s, ClientContext *c) {
c->log_level_max = -1;
c->log_ratelimit_interval = s->ratelimit_interval;
c->log_ratelimit_burst = s->ratelimit_burst;
c->log_ratelimit_interval = m->ratelimit_interval;
c->log_ratelimit_burst = m->ratelimit_burst;
c->log_filter_allowed_patterns = set_free(c->log_filter_allowed_patterns);
c->log_filter_denied_patterns = set_free(c->log_filter_denied_patterns);
@@ -189,18 +189,18 @@ static void client_context_reset(Server *s, ClientContext *c) {
c->capability_quintet = CAPABILITY_QUINTET_NULL;
}
static ClientContext* client_context_free(Server *s, ClientContext *c) {
assert(s);
static ClientContext* client_context_free(Manager *m, ClientContext *c) {
assert(m);
if (!c)
return NULL;
assert_se(hashmap_remove(s->client_contexts, PID_TO_PTR(c->pid)) == c);
assert_se(hashmap_remove(m->client_contexts, PID_TO_PTR(c->pid)) == c);
if (c->in_lru)
assert_se(prioq_remove(s->client_contexts_lru, c, &c->lru_index) >= 0);
assert_se(prioq_remove(m->client_contexts_lru, c, &c->lru_index) >= 0);
client_context_reset(s, c);
client_context_reset(m, c);
return mfree(c);
}
@@ -275,14 +275,14 @@ static int client_context_read_label(
return 0;
}
static int client_context_read_cgroup(Server *s, ClientContext *c, const char *unit_id) {
static int client_context_read_cgroup(Manager *m, ClientContext *c, const char *unit_id) {
_cleanup_free_ char *t = NULL;
int r;
assert(c);
/* Try to acquire the current cgroup path */
r = cg_pid_get_path_shifted(c->pid, s->cgroup_root, &t);
r = cg_pid_get_path_shifted(c->pid, m->cgroup_root, &t);
if (r < 0 || empty_or_root(t)) {
/* We use the unit ID passed in as fallback if we have nothing cached yet and cg_pid_get_path_shifted()
* failed or process is running in a root cgroup. Zombie processes are automatically migrated to root cgroup
@@ -326,13 +326,13 @@ static int client_context_read_cgroup(Server *s, ClientContext *c, const char *u
}
static int client_context_read_invocation_id(
Server *s,
Manager *m,
ClientContext *c) {
_cleanup_free_ char *p = NULL, *value = NULL;
int r;
assert(s);
assert(m);
assert(c);
/* Read the invocation ID of a unit off a unit.
@@ -360,7 +360,7 @@ static int client_context_read_invocation_id(
}
static int client_context_read_log_level_max(
Server *s,
Manager *m,
ClientContext *c) {
_cleanup_free_ char *value = NULL;
@@ -384,7 +384,7 @@ static int client_context_read_log_level_max(
}
static int client_context_read_extra_fields(
Server *s,
Manager *m,
ClientContext *c) {
_cleanup_free_ struct iovec *iovec = NULL;
@@ -510,14 +510,14 @@ static int client_context_read_log_ratelimit_burst(ClientContext *c) {
}
static void client_context_really_refresh(
Server *s,
Manager *m,
ClientContext *c,
const struct ucred *ucred,
const char *label, size_t label_size,
const char *unit_id,
usec_t timestamp) {
assert(s);
assert(m);
assert(c);
assert(pid_is_valid(c->pid));
@@ -531,10 +531,10 @@ static void client_context_really_refresh(
(void) audit_session_from_pid(&PIDREF_MAKE_FROM_PID(c->pid), &c->auditid);
(void) audit_loginuid_from_pid(&PIDREF_MAKE_FROM_PID(c->pid), &c->loginuid);
(void) client_context_read_cgroup(s, c, unit_id);
(void) client_context_read_invocation_id(s, c);
(void) client_context_read_log_level_max(s, c);
(void) client_context_read_extra_fields(s, c);
(void) client_context_read_cgroup(m, c, unit_id);
(void) client_context_read_invocation_id(m, c);
(void) client_context_read_log_level_max(m, c);
(void) client_context_read_extra_fields(m, c);
(void) client_context_read_log_ratelimit_interval(c);
(void) client_context_read_log_ratelimit_burst(c);
@@ -542,19 +542,19 @@ static void client_context_really_refresh(
if (c->in_lru) {
assert(c->n_ref == 0);
prioq_reshuffle(s->client_contexts_lru, c, &c->lru_index);
prioq_reshuffle(m->client_contexts_lru, c, &c->lru_index);
}
}
void client_context_maybe_refresh(
Server *s,
Manager *m,
ClientContext *c,
const struct ucred *ucred,
const char *label, size_t label_size,
const char *unit_id,
usec_t timestamp) {
assert(s);
assert(m);
assert(c);
if (timestamp == USEC_INFINITY)
@@ -567,7 +567,7 @@ void client_context_maybe_refresh(
/* If the data isn't pinned and if the cashed data is older than the upper limit, we flush it out
* entirely. This follows the logic that as long as an entry is pinned the PID reuse is unlikely. */
if (c->n_ref == 0 && c->timestamp + MAX_USEC < timestamp) {
client_context_reset(s, c);
client_context_reset(m, c);
goto refresh;
}
@@ -588,44 +588,44 @@ void client_context_maybe_refresh(
return;
refresh:
client_context_really_refresh(s, c, ucred, label, label_size, unit_id, timestamp);
client_context_really_refresh(m, c, ucred, label, label_size, unit_id, timestamp);
}
static void client_context_try_shrink_to(Server *s, size_t limit) {
static void client_context_try_shrink_to(Manager *m, size_t limit) {
ClientContext *c;
usec_t t;
assert(s);
assert(m);
/* Flush any cache entries for PIDs that have already moved on. Don't do this
* too often, since it's a slow process. */
t = now(CLOCK_MONOTONIC);
if (s->last_cache_pid_flush + MAX_USEC < t) {
unsigned n = prioq_size(s->client_contexts_lru), idx = 0;
if (m->last_cache_pid_flush + MAX_USEC < t) {
unsigned n = prioq_size(m->client_contexts_lru), idx = 0;
/* We do a number of iterations based on the initial size of the prioq. When we remove an
* item, a new item is moved into its places, and items to the right might be reshuffled.
*/
for (unsigned i = 0; i < n; i++) {
c = prioq_peek_by_index(s->client_contexts_lru, idx);
c = prioq_peek_by_index(m->client_contexts_lru, idx);
assert(c->n_ref == 0);
if (pid_is_unwaited(c->pid) == 0)
client_context_free(s, c);
client_context_free(m, c);
else
idx++;
}
s->last_cache_pid_flush = t;
m->last_cache_pid_flush = t;
}
/* Bring the number of cache entries below the indicated limit, so that we can create a new entry without
* breaching the limit. Note that we only flush out entries that aren't pinned here. This means the number of
* cache entries may very well grow beyond the limit, if all entries stored remain pinned. */
while (hashmap_size(s->client_contexts) > limit) {
c = prioq_pop(s->client_contexts_lru);
while (hashmap_size(m->client_contexts) > limit) {
c = prioq_pop(m->client_contexts_lru);
if (!c)
break; /* All remaining entries are pinned, give up */
@@ -634,33 +634,33 @@ static void client_context_try_shrink_to(Server *s, size_t limit) {
c->in_lru = false;
client_context_free(s, c);
client_context_free(m, c);
}
}
void client_context_flush_regular(Server *s) {
client_context_try_shrink_to(s, 0);
void client_context_flush_regular(Manager *m) {
client_context_try_shrink_to(m, 0);
}
void client_context_flush_all(Server *s) {
assert(s);
void client_context_flush_all(Manager *m) {
assert(m);
/* Flush out all remaining entries. This assumes all references are already dropped. */
s->my_context = client_context_release(s, s->my_context);
s->pid1_context = client_context_release(s, s->pid1_context);
m->my_context = client_context_release(m, m->my_context);
m->pid1_context = client_context_release(m, m->pid1_context);
client_context_flush_regular(s);
client_context_flush_regular(m);
assert(prioq_isempty(s->client_contexts_lru));
assert(hashmap_isempty(s->client_contexts));
assert(prioq_isempty(m->client_contexts_lru));
assert(hashmap_isempty(m->client_contexts));
s->client_contexts_lru = prioq_free(s->client_contexts_lru);
s->client_contexts = hashmap_free(s->client_contexts);
m->client_contexts_lru = prioq_free(m->client_contexts_lru);
m->client_contexts = hashmap_free(m->client_contexts);
}
static int client_context_get_internal(
Server *s,
Manager *m,
pid_t pid,
const struct ucred *ucred,
const char *label, size_t label_len,
@@ -671,80 +671,80 @@ static int client_context_get_internal(
ClientContext *c;
int r;
assert(s);
assert(m);
assert(ret);
if (!pid_is_valid(pid))
return -EINVAL;
c = hashmap_get(s->client_contexts, PID_TO_PTR(pid));
c = hashmap_get(m->client_contexts, PID_TO_PTR(pid));
if (c) {
if (add_ref) {
if (c->in_lru) {
/* The entry wasn't pinned so far, let's remove it from the LRU list then */
assert(c->n_ref == 0);
assert_se(prioq_remove(s->client_contexts_lru, c, &c->lru_index) >= 0);
assert_se(prioq_remove(m->client_contexts_lru, c, &c->lru_index) >= 0);
c->in_lru = false;
}
c->n_ref++;
}
client_context_maybe_refresh(s, c, ucred, label, label_len, unit_id, USEC_INFINITY);
client_context_maybe_refresh(m, c, ucred, label, label_len, unit_id, USEC_INFINITY);
*ret = c;
return 0;
}
client_context_try_shrink_to(s, cache_max()-1);
client_context_try_shrink_to(m, cache_max()-1);
r = client_context_new(s, pid, &c);
r = client_context_new(m, pid, &c);
if (r < 0)
return r;
if (add_ref)
c->n_ref++;
else {
r = prioq_put(s->client_contexts_lru, c, &c->lru_index);
r = prioq_put(m->client_contexts_lru, c, &c->lru_index);
if (r < 0) {
client_context_free(s, c);
client_context_free(m, c);
return r;
}
c->in_lru = true;
}
client_context_really_refresh(s, c, ucred, label, label_len, unit_id, USEC_INFINITY);
client_context_really_refresh(m, c, ucred, label, label_len, unit_id, USEC_INFINITY);
*ret = c;
return 0;
}
int client_context_get(
Server *s,
Manager *m,
pid_t pid,
const struct ucred *ucred,
const char *label, size_t label_len,
const char *unit_id,
ClientContext **ret) {
return client_context_get_internal(s, pid, ucred, label, label_len, unit_id, false, ret);
return client_context_get_internal(m, pid, ucred, label, label_len, unit_id, false, ret);
}
int client_context_acquire(
Server *s,
Manager *m,
pid_t pid,
const struct ucred *ucred,
const char *label, size_t label_len,
const char *unit_id,
ClientContext **ret) {
return client_context_get_internal(s, pid, ucred, label, label_len, unit_id, true, ret);
return client_context_get_internal(m, pid, ucred, label, label_len, unit_id, true, ret);
};
ClientContext *client_context_release(Server *s, ClientContext *c) {
assert(s);
ClientContext *client_context_release(Manager *m, ClientContext *c) {
assert(m);
if (!c)
return NULL;
@@ -759,40 +759,40 @@ ClientContext *client_context_release(Server *s, ClientContext *c) {
/* The entry is not pinned anymore, let's add it to the LRU prioq if we can. If we can't we'll drop it
* right-away */
if (prioq_put(s->client_contexts_lru, c, &c->lru_index) < 0)
client_context_free(s, c);
if (prioq_put(m->client_contexts_lru, c, &c->lru_index) < 0)
client_context_free(m, c);
else
c->in_lru = true;
return NULL;
}
void client_context_acquire_default(Server *s) {
void client_context_acquire_default(Manager *m) {
int r;
assert(s);
assert(m);
/* Ensure that our own and PID1's contexts are always pinned. Our own context is particularly useful to
* generate driver messages. */
if (!s->my_context) {
if (!m->my_context) {
struct ucred ucred = {
.pid = getpid_cached(),
.uid = getuid(),
.gid = getgid(),
};
r = client_context_acquire(s, ucred.pid, &ucred, NULL, 0, NULL, &s->my_context);
r = client_context_acquire(m, ucred.pid, &ucred, NULL, 0, NULL, &m->my_context);
if (r < 0)
log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to acquire our own context, ignoring: %m");
}
if (!s->namespace && !s->pid1_context) {
if (!m->namespace && !m->pid1_context) {
/* Acquire PID1's context, but only if we are in non-namespaced mode, since PID 1 is only
* going to log to the non-namespaced journal instance. */
r = client_context_acquire(s, 1, NULL, NULL, 0, NULL, &s->pid1_context);
r = client_context_acquire(m, 1, NULL, NULL, 0, NULL, &m->pid1_context);
if (r < 0)
log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to acquire PID1's context, ignoring: %m");
+8 -8
View File
@@ -12,7 +12,7 @@
#include "set.h"
#include "time-util.h"
typedef struct Server Server;
typedef struct Manager Manager;
typedef struct ClientContext {
unsigned n_ref;
@@ -62,7 +62,7 @@ typedef struct ClientContext {
} ClientContext;
int client_context_get(
Server *s,
Manager *m,
pid_t pid,
const struct ucred *ucred,
const char *label, size_t label_len,
@@ -70,26 +70,26 @@ int client_context_get(
ClientContext **ret);
int client_context_acquire(
Server *s,
Manager *m,
pid_t pid,
const struct ucred *ucred,
const char *label, size_t label_len,
const char *unit_id,
ClientContext **ret);
ClientContext* client_context_release(Server *s, ClientContext *c);
ClientContext* client_context_release(Manager *m, ClientContext *c);
void client_context_maybe_refresh(
Server *s,
Manager *m,
ClientContext *c,
const struct ucred *ucred,
const char *label, size_t label_size,
const char *unit_id,
usec_t tstamp);
void client_context_acquire_default(Server *s);
void client_context_flush_all(Server *s);
void client_context_flush_regular(Server *s);
void client_context_acquire_default(Manager *m);
void client_context_flush_all(Manager *m);
void client_context_flush_regular(Manager *m);
static inline size_t client_context_extra_fields_n_iovec(const ClientContext *c) {
return c ? c->extra_fields_n_iovec : 0;
+34 -34
View File
@@ -7,7 +7,7 @@ _Pragma("GCC diagnostic ignored \"-Wzero-as-null-pointer-constant\"")
#include <stddef.h>
#include <sys/socket.h>
#include "conf-parser.h"
#include "journald-server.h"
#include "journald-manager.h"
%}
struct ConfigPerfItem;
%null_strings
@@ -20,37 +20,37 @@ struct ConfigPerfItem;
%struct-type
%includes
%%
Journal.Storage, config_parse_storage, 0, offsetof(Server, storage)
Journal.Compress, config_parse_compress, 0, offsetof(Server, compress)
Journal.Seal, config_parse_bool, 0, offsetof(Server, seal)
Journal.ReadKMsg, config_parse_bool, 0, offsetof(Server, read_kmsg)
Journal.Audit, config_parse_tristate, 0, offsetof(Server, set_audit)
Journal.SyncIntervalSec, config_parse_sec, 0, offsetof(Server, sync_interval_usec)
Journal.Storage, config_parse_storage, 0, offsetof(Manager, storage)
Journal.Compress, config_parse_compress, 0, offsetof(Manager, compress)
Journal.Seal, config_parse_bool, 0, offsetof(Manager, seal)
Journal.ReadKMsg, config_parse_bool, 0, offsetof(Manager, read_kmsg)
Journal.Audit, config_parse_tristate, 0, offsetof(Manager, set_audit)
Journal.SyncIntervalSec, config_parse_sec, 0, offsetof(Manager, sync_interval_usec)
# The following is a legacy name for compatibility
Journal.RateLimitInterval, config_parse_sec, 0, offsetof(Server, ratelimit_interval)
Journal.RateLimitIntervalSec,config_parse_sec, 0, offsetof(Server, ratelimit_interval)
Journal.RateLimitBurst, config_parse_unsigned, 0, offsetof(Server, ratelimit_burst)
Journal.SystemMaxUse, config_parse_iec_uint64, 0, offsetof(Server, system_storage.metrics.max_use)
Journal.SystemMaxFileSize, config_parse_iec_uint64, 0, offsetof(Server, system_storage.metrics.max_size)
Journal.SystemKeepFree, config_parse_iec_uint64, 0, offsetof(Server, system_storage.metrics.keep_free)
Journal.SystemMaxFiles, config_parse_uint64, 0, offsetof(Server, system_storage.metrics.n_max_files)
Journal.RuntimeMaxUse, config_parse_iec_uint64, 0, offsetof(Server, runtime_storage.metrics.max_use)
Journal.RuntimeMaxFileSize, config_parse_iec_uint64, 0, offsetof(Server, runtime_storage.metrics.max_size)
Journal.RuntimeKeepFree, config_parse_iec_uint64, 0, offsetof(Server, runtime_storage.metrics.keep_free)
Journal.RuntimeMaxFiles, config_parse_uint64, 0, offsetof(Server, runtime_storage.metrics.n_max_files)
Journal.MaxRetentionSec, config_parse_sec, 0, offsetof(Server, max_retention_usec)
Journal.MaxFileSec, config_parse_sec, 0, offsetof(Server, max_file_usec)
Journal.ForwardToSyslog, config_parse_bool, 0, offsetof(Server, forward_to_syslog)
Journal.ForwardToKMsg, config_parse_bool, 0, offsetof(Server, forward_to_kmsg)
Journal.ForwardToConsole, config_parse_bool, 0, offsetof(Server, forward_to_console)
Journal.ForwardToWall, config_parse_bool, 0, offsetof(Server, forward_to_wall)
Journal.ForwardToSocket, config_parse_forward_to_socket, 0, offsetof(Server, forward_to_socket)
Journal.TTYPath, config_parse_path, 0, offsetof(Server, tty_path)
Journal.MaxLevelStore, config_parse_log_level, 0, offsetof(Server, max_level_store)
Journal.MaxLevelSyslog, config_parse_log_level, 0, offsetof(Server, max_level_syslog)
Journal.MaxLevelKMsg, config_parse_log_level, 0, offsetof(Server, max_level_kmsg)
Journal.MaxLevelConsole, config_parse_log_level, 0, offsetof(Server, max_level_console)
Journal.MaxLevelWall, config_parse_log_level, 0, offsetof(Server, max_level_wall)
Journal.MaxLevelSocket, config_parse_log_level, 0, offsetof(Server, max_level_socket)
Journal.SplitMode, config_parse_split_mode, 0, offsetof(Server, split_mode)
Journal.LineMax, config_parse_line_max, 0, offsetof(Server, line_max)
Journal.RateLimitInterval, config_parse_sec, 0, offsetof(Manager, ratelimit_interval)
Journal.RateLimitIntervalSec,config_parse_sec, 0, offsetof(Manager, ratelimit_interval)
Journal.RateLimitBurst, config_parse_unsigned, 0, offsetof(Manager, ratelimit_burst)
Journal.SystemMaxUse, config_parse_iec_uint64, 0, offsetof(Manager, system_storage.metrics.max_use)
Journal.SystemMaxFileSize, config_parse_iec_uint64, 0, offsetof(Manager, system_storage.metrics.max_size)
Journal.SystemKeepFree, config_parse_iec_uint64, 0, offsetof(Manager, system_storage.metrics.keep_free)
Journal.SystemMaxFiles, config_parse_uint64, 0, offsetof(Manager, system_storage.metrics.n_max_files)
Journal.RuntimeMaxUse, config_parse_iec_uint64, 0, offsetof(Manager, runtime_storage.metrics.max_use)
Journal.RuntimeMaxFileSize, config_parse_iec_uint64, 0, offsetof(Manager, runtime_storage.metrics.max_size)
Journal.RuntimeKeepFree, config_parse_iec_uint64, 0, offsetof(Manager, runtime_storage.metrics.keep_free)
Journal.RuntimeMaxFiles, config_parse_uint64, 0, offsetof(Manager, runtime_storage.metrics.n_max_files)
Journal.MaxRetentionSec, config_parse_sec, 0, offsetof(Manager, max_retention_usec)
Journal.MaxFileSec, config_parse_sec, 0, offsetof(Manager, max_file_usec)
Journal.ForwardToSyslog, config_parse_bool, 0, offsetof(Manager, forward_to_syslog)
Journal.ForwardToKMsg, config_parse_bool, 0, offsetof(Manager, forward_to_kmsg)
Journal.ForwardToConsole, config_parse_bool, 0, offsetof(Manager, forward_to_console)
Journal.ForwardToWall, config_parse_bool, 0, offsetof(Manager, forward_to_wall)
Journal.ForwardToSocket, config_parse_forward_to_socket, 0, offsetof(Manager, forward_to_socket)
Journal.TTYPath, config_parse_path, 0, offsetof(Manager, tty_path)
Journal.MaxLevelStore, config_parse_log_level, 0, offsetof(Manager, max_level_store)
Journal.MaxLevelSyslog, config_parse_log_level, 0, offsetof(Manager, max_level_syslog)
Journal.MaxLevelKMsg, config_parse_log_level, 0, offsetof(Manager, max_level_kmsg)
Journal.MaxLevelConsole, config_parse_log_level, 0, offsetof(Manager, max_level_console)
Journal.MaxLevelWall, config_parse_log_level, 0, offsetof(Manager, max_level_wall)
Journal.MaxLevelSocket, config_parse_log_level, 0, offsetof(Manager, max_level_socket)
Journal.SplitMode, config_parse_split_mode, 0, offsetof(Manager, split_mode)
Journal.LineMax, config_parse_line_max, 0, offsetof(Manager, line_max)
+56 -56
View File
@@ -18,7 +18,7 @@
#include "iovec-util.h"
#include "journal-internal.h"
#include "journald-kmsg.h"
#include "journald-server.h"
#include "journald-manager.h"
#include "journald-syslog.h"
#include "log.h"
#include "parse-util.h"
@@ -26,8 +26,8 @@
#include "stdio-util.h"
#include "string-util.h"
void server_forward_kmsg(
Server *s,
void manager_forward_kmsg(
Manager *m,
int priority,
const char *identifier,
const char *message,
@@ -39,15 +39,15 @@ void server_forward_kmsg(
header_pid[STRLEN("[]: ") + DECIMAL_STR_MAX(pid_t) + 1];
size_t n = 0;
assert(s);
assert(m);
assert(priority >= 0);
assert(priority <= 999);
assert(message);
if (_unlikely_(LOG_PRI(priority) > s->max_level_kmsg))
if (_unlikely_(LOG_PRI(priority) > m->max_level_kmsg))
return;
if (_unlikely_(s->dev_kmsg_fd < 0))
if (_unlikely_(m->dev_kmsg_fd < 0))
return;
/* Never allow messages with kernel facility to be written to
@@ -79,7 +79,7 @@ void server_forward_kmsg(
iovec[n++] = IOVEC_MAKE_STRING(message);
iovec[n++] = IOVEC_MAKE_STRING("\n");
if (writev(s->dev_kmsg_fd, iovec, n) < 0)
if (writev(m->dev_kmsg_fd, iovec, n) < 0)
log_debug_errno(errno, "Failed to write to /dev/kmsg for logging, ignoring: %m");
}
@@ -96,7 +96,7 @@ static bool is_us(const char *identifier, const char *pid) {
streq(identifier, program_invocation_short_name);
}
void dev_kmsg_record(Server *s, char *p, size_t l) {
void dev_kmsg_record(Manager *m, char *p, size_t l) {
_cleanup_free_ char *message = NULL, *syslog_pid = NULL, *syslog_identifier = NULL, *identifier = NULL, *pid = NULL;
struct iovec iovec[N_IOVEC_META_FIELDS + 7 + N_IOVEC_KERNEL_FIELDS + 2 + N_IOVEC_UDEV_FIELDS];
@@ -110,7 +110,7 @@ void dev_kmsg_record(Server *s, char *p, size_t l) {
int saved_log_max_level = INT_MAX;
ClientContext *c = NULL;
assert(s);
assert(m);
assert(p);
if (l <= 0)
@@ -126,7 +126,7 @@ void dev_kmsg_record(Server *s, char *p, size_t l) {
if (r < 0 || priority < 0 || priority > 999)
return;
if (s->forward_to_kmsg && LOG_FAC(priority) != LOG_KERN)
if (m->forward_to_kmsg && LOG_FAC(priority) != LOG_KERN)
return;
/* seqnum */
@@ -141,23 +141,23 @@ void dev_kmsg_record(Server *s, char *p, size_t l) {
if (r < 0)
return;
if (s->kernel_seqnum) {
if (m->kernel_seqnum) {
/* We already read this one? */
if (serial < *s->kernel_seqnum)
if (serial < *m->kernel_seqnum)
return;
/* Did we lose any? */
if (serial > *s->kernel_seqnum)
server_driver_message(s, 0,
LOG_MESSAGE_ID(SD_MESSAGE_JOURNAL_MISSED_STR),
LOG_MESSAGE("Missed %"PRIu64" kernel messages",
serial - *s->kernel_seqnum));
if (serial > *m->kernel_seqnum)
manager_driver_message(m, 0,
LOG_MESSAGE_ID(SD_MESSAGE_JOURNAL_MISSED_STR),
LOG_MESSAGE("Missed %"PRIu64" kernel messages",
serial - *m->kernel_seqnum));
/* Make sure we never read this one again. Note that
* we always store the next message serial we expect
* here, simply because this makes handling the first
* message with serial 0 easy. */
*s->kernel_seqnum = serial + 1;
*m->kernel_seqnum = serial + 1;
}
/* CLOCK_BOOTTIME timestamp */
@@ -192,7 +192,7 @@ void dev_kmsg_record(Server *s, char *p, size_t l) {
k = e + 1;
for (j = 0; l > 0 && j < N_IOVEC_KERNEL_FIELDS; j++) {
char *m;
char *mm;
/* Metadata fields attached */
if (*k != ' ')
@@ -206,13 +206,13 @@ void dev_kmsg_record(Server *s, char *p, size_t l) {
*e = 0;
if (cunescape_length_with_prefix(k, e - k, "_KERNEL_", UNESCAPE_RELAX, &m) < 0)
if (cunescape_length_with_prefix(k, e - k, "_KERNEL_", UNESCAPE_RELAX, &mm) < 0)
break;
if (startswith(m, "_KERNEL_DEVICE="))
kernel_device = m + 15;
if (startswith(mm, "_KERNEL_DEVICE="))
kernel_device = mm + 15;
iovec[n++] = IOVEC_MAKE_STRING(m);
iovec[n++] = IOVEC_MAKE_STRING(mm);
z++;
l -= (e - k) + 1;
@@ -287,11 +287,11 @@ void dev_kmsg_record(Server *s, char *p, size_t l) {
/* Avoid logging any new messages when we're processing messages generated by ourselves via
* log_info() and friends to avoid infinite loops. */
if (is_us(identifier, pid)) {
if (!ratelimit_below(&s->kmsg_own_ratelimit))
if (!ratelimit_below(&m->kmsg_own_ratelimit))
return;
saved_log_max_level = log_get_max_level();
c = s->my_context;
c = m->my_context;
log_set_max_level(LOG_NULL);
}
@@ -311,28 +311,28 @@ void dev_kmsg_record(Server *s, char *p, size_t l) {
if (cunescape_length_with_prefix(p, pl, "MESSAGE=", UNESCAPE_RELAX, &message) >= 0)
iovec[n++] = IOVEC_MAKE_STRING(message);
server_dispatch_message(s, iovec, n, ELEMENTSOF(iovec), c, NULL, priority, 0);
manager_dispatch_message(m, iovec, n, ELEMENTSOF(iovec), c, NULL, priority, 0);
if (saved_log_max_level != INT_MAX)
log_set_max_level(saved_log_max_level);
s->dev_kmsg_timestamp = usec;
sync_req_revalidate_by_timestamp(s);
m->dev_kmsg_timestamp = usec;
sync_req_revalidate_by_timestamp(m);
finish:
for (j = 0; j < z; j++)
free(iovec[j].iov_base);
}
static int server_read_dev_kmsg(Server *s) {
static int manager_read_dev_kmsg(Manager *m) {
char buffer[8192+1]; /* the kernel-side limit per record is 8K currently */
ssize_t l;
assert(s);
assert(s->dev_kmsg_fd >= 0);
assert(s->read_kmsg);
assert(m);
assert(m->dev_kmsg_fd >= 0);
assert(m->read_kmsg);
l = read(s->dev_kmsg_fd, buffer, sizeof(buffer) - 1);
l = read(m->dev_kmsg_fd, buffer, sizeof(buffer) - 1);
if (l == 0)
return 0;
if (l < 0) {
@@ -342,25 +342,25 @@ static int server_read_dev_kmsg(Server *s) {
return log_ratelimit_error_errno(errno, JOURNAL_LOG_RATELIMIT, "Failed to read from /dev/kmsg: %m");
}
dev_kmsg_record(s, buffer, l);
dev_kmsg_record(m, buffer, l);
return 1;
}
int server_flush_dev_kmsg(Server *s) {
int manager_flush_dev_kmsg(Manager *m) {
int r;
assert(s);
assert(m);
if (s->dev_kmsg_fd < 0)
if (m->dev_kmsg_fd < 0)
return 0;
if (!s->read_kmsg)
if (!m->read_kmsg)
return 0;
log_debug("Flushing /dev/kmsg...");
for (;;) {
r = server_read_dev_kmsg(s);
r = manager_read_dev_kmsg(m);
if (r < 0)
return r;
@@ -372,10 +372,10 @@ int server_flush_dev_kmsg(Server *s) {
}
static int dispatch_dev_kmsg(sd_event_source *es, int fd, uint32_t revents, void *userdata) {
Server *s = ASSERT_PTR(userdata);
Manager *m = ASSERT_PTR(userdata);
assert(es);
assert(fd == s->dev_kmsg_fd);
assert(fd == m->dev_kmsg_fd);
if (revents & EPOLLERR)
log_ratelimit_warning(JOURNAL_LOG_RATELIMIT,
@@ -384,17 +384,17 @@ static int dispatch_dev_kmsg(sd_event_source *es, int fd, uint32_t revents, void
if (!(revents & EPOLLIN))
log_error("Got invalid event from epoll for /dev/kmsg: %"PRIx32, revents);
return server_read_dev_kmsg(s);
return manager_read_dev_kmsg(m);
}
int server_open_dev_kmsg(Server *s) {
int manager_open_dev_kmsg(Manager *m) {
int r;
assert(s);
assert(s->dev_kmsg_fd < 0);
assert(!s->dev_kmsg_event_source);
assert(m);
assert(m->dev_kmsg_fd < 0);
assert(!m->dev_kmsg_event_source);
mode_t mode = O_CLOEXEC|O_NONBLOCK|O_NOCTTY|(s->read_kmsg ? O_RDWR : O_WRONLY);
mode_t mode = O_CLOEXEC|O_NONBLOCK|O_NOCTTY|(m->read_kmsg ? O_RDWR : O_WRONLY);
_cleanup_close_ int fd = open("/dev/kmsg", mode);
if (fd < 0) {
@@ -403,13 +403,13 @@ int server_open_dev_kmsg(Server *s) {
return 0;
}
if (!s->read_kmsg) {
s->dev_kmsg_fd = TAKE_FD(fd);
if (!m->read_kmsg) {
m->dev_kmsg_fd = TAKE_FD(fd);
return 0;
}
_cleanup_(sd_event_source_unrefp) sd_event_source *es = NULL;
r = sd_event_add_io(s->event, &es, fd, EPOLLIN, dispatch_dev_kmsg, s);
r = sd_event_add_io(m->event, &es, fd, EPOLLIN, dispatch_dev_kmsg, m);
if (r < 0)
return log_error_errno(r, "Failed to add /dev/kmsg fd to event loop: %m");
@@ -417,23 +417,23 @@ int server_open_dev_kmsg(Server *s) {
if (r < 0)
return log_error_errno(r, "Failed to adjust priority of kmsg event source: %m");
s->dev_kmsg_fd = TAKE_FD(fd);
s->dev_kmsg_event_source = TAKE_PTR(es);
m->dev_kmsg_fd = TAKE_FD(fd);
m->dev_kmsg_event_source = TAKE_PTR(es);
return 0;
}
int server_open_kernel_seqnum(Server *s) {
int manager_open_kernel_seqnum(Manager *m) {
int r;
assert(s);
assert(m);
/* We store the seqnum we last read in an mmapped file. That way we can just use it like a variable,
* but it is persistent and automatically flushed at reboot. */
if (!s->read_kmsg)
if (!m->read_kmsg)
return 0;
r = server_map_seqnum_file(s, "kernel-seqnum", sizeof(uint64_t), (void**) &s->kernel_seqnum);
r = manager_map_seqnum_file(m, "kernel-seqnum", sizeof(uint64_t), (void**) &m->kernel_seqnum);
if (r < 0)
return log_error_errno(r, "Failed to map kernel seqnum file: %m");
+6 -6
View File
@@ -4,13 +4,13 @@
#include <stddef.h>
#include <sys/socket.h>
typedef struct Server Server;
typedef struct Manager Manager;
int server_open_dev_kmsg(Server *s);
int server_flush_dev_kmsg(Server *s);
int manager_open_dev_kmsg(Manager *m);
int manager_flush_dev_kmsg(Manager *m);
void server_forward_kmsg(Server *s, int priority, const char *identifier, const char *message, const struct ucred *ucred);
void manager_forward_kmsg(Manager *m, int priority, const char *identifier, const char *message, const struct ucred *ucred);
int server_open_kernel_seqnum(Server *s);
int manager_open_kernel_seqnum(Manager *m);
void dev_kmsg_record(Server *s, char *p, size_t l);
void dev_kmsg_record(Manager *m, char *p, size_t l);
File diff suppressed because it is too large Load Diff
@@ -67,7 +67,7 @@ typedef struct SeqnumData {
uint64_t seqnum;
} SeqnumData;
typedef struct Server {
typedef struct Manager {
char *namespace;
int syslog_fd;
@@ -195,9 +195,9 @@ typedef struct Server {
/* Pending synchronization requests with non-zero rqlen counter */
LIST_HEAD(SyncReq, sync_req_pending_rqlen);
} Server;
} Manager;
#define SERVER_MACHINE_ID(s) ((s)->machine_id_field + STRLEN("_MACHINE_ID="))
#define MANAGER_MACHINE_ID(s) ((s)->machine_id_field + STRLEN("_MACHINE_ID="))
/* Extra fields for any log messages */
#define N_IOVEC_META_FIELDS 24
@@ -217,9 +217,9 @@ typedef struct Server {
/* audit: Maximum number of extra fields we'll import from audit messages */
#define N_IOVEC_AUDIT_FIELDS 64
void server_dispatch_message(Server *s, struct iovec *iovec, size_t n, size_t m, ClientContext *c, const struct timeval *tv, int priority, pid_t object_pid);
void server_driver_message_internal(Server *s, pid_t object_pid, const char *format, ...) _sentinel_;
#define server_driver_message(...) server_driver_message_internal(__VA_ARGS__, NULL)
void manager_dispatch_message(Manager *m, struct iovec *iovec, size_t n, size_t k, ClientContext *c, const struct timeval *tv, int priority, pid_t object_pid);
void manager_driver_message_internal(Manager *m, pid_t object_pid, const char *format, ...) _sentinel_;
#define manager_driver_message(...) manager_driver_message_internal(__VA_ARGS__, NULL)
/* gperf lookup function */
const struct ConfigPerfItem* journald_gperf_lookup(const char *key, GPERF_LEN_TYPE length);
@@ -237,21 +237,21 @@ CONFIG_PARSER_PROTOTYPE(config_parse_split_mode);
const char* split_mode_to_string(SplitMode s) _const_;
SplitMode split_mode_from_string(const char *s) _pure_;
int server_new(Server **ret);
int server_init(Server *s, const char *namespace);
Server* server_free(Server *s);
DEFINE_TRIVIAL_CLEANUP_FUNC(Server*, server_free);
void server_full_sync(Server *s, bool wait);
void server_vacuum(Server *s, bool verbose);
void server_rotate(Server *s);
void server_full_rotate(Server *s);
int server_flush_to_var(Server *s, bool require_flag_file);
void server_full_flush(Server *s);
int server_relinquish_var(Server *s);
void server_maybe_append_tags(Server *s);
int server_process_datagram(sd_event_source *es, int fd, uint32_t revents, void *userdata);
void server_space_usage_message(Server *s, JournalStorage *storage);
int manager_new(Manager **ret);
int manager_init(Manager *m, const char *namespace);
Manager* manager_free(Manager *m);
DEFINE_TRIVIAL_CLEANUP_FUNC(Manager*, manager_free);
void manager_full_sync(Manager *m, bool wait);
void manager_vacuum(Manager *m, bool verbose);
void manager_rotate(Manager *m);
void manager_full_rotate(Manager *m);
int manager_flush_to_var(Manager *m, bool require_flag_file);
void manager_full_flush(Manager *m);
int manager_relinquish_var(Manager *m);
void manager_maybe_append_tags(Manager *m);
int manager_process_datagram(sd_event_source *es, int fd, uint32_t revents, void *userdata);
void manager_space_usage_message(Manager *m, JournalStorage *storage);
int server_start_or_stop_idle_timer(Server *s);
int manager_start_or_stop_idle_timer(Manager *m);
int server_map_seqnum_file(Server *s, const char *fname, size_t size, void **ret);
int manager_map_seqnum_file(Manager *m, const char *fname, size_t size, void **ret);
+39 -39
View File
@@ -16,8 +16,8 @@
#include "journald-client.h"
#include "journald-console.h"
#include "journald-kmsg.h"
#include "journald-manager.h"
#include "journald-native.h"
#include "journald-server.h"
#include "journald-syslog.h"
#include "journald-wall.h"
#include "memfd-util.h"
@@ -36,7 +36,7 @@ static bool allow_object_pid(const struct ucred *ucred) {
return ucred && ucred->uid == 0;
}
static void server_process_entry_meta(
static void manager_process_entry_meta(
const char *p, size_t l,
const struct ucred *ucred,
int *priority,
@@ -91,8 +91,8 @@ static void server_process_entry_meta(
}
}
static int server_process_entry(
Server *s,
static int manager_process_entry(
Manager *m,
const void *buffer, size_t *remaining,
ClientContext *context,
const struct ucred *ucred,
@@ -175,7 +175,7 @@ static int server_process_entry(
iovec[n++] = IOVEC_MAKE((char*) p, l);
entry_size += l;
server_process_entry_meta(p, l, ucred,
manager_process_entry_meta(p, l, ucred,
&priority,
&identifier,
&message,
@@ -228,7 +228,7 @@ static int server_process_entry(
entry_size += iovec[n].iov_len;
n++;
server_process_entry_meta(k, (e - p) + 1 + l, ucred,
manager_process_entry_meta(k, (e - p) + 1 + l, ucred,
&priority,
&identifier,
&message,
@@ -260,26 +260,26 @@ static int server_process_entry(
if (message) {
/* Ensure message is not NULL, otherwise strlen(message) would crash. This check needs to
* be here until server_process_entry() is able to process messages containing \0 characters,
* be here until manager_process_entry() is able to process messages containing \0 characters,
* as we would have access to the actual size of message. */
r = client_context_check_keep_log(context, message, strlen(message));
if (r <= 0)
goto finish;
if (s->forward_to_syslog)
server_forward_syslog(s, syslog_fixup_facility(priority), identifier, message, ucred, tv);
if (m->forward_to_syslog)
manager_forward_syslog(m, syslog_fixup_facility(priority), identifier, message, ucred, tv);
if (s->forward_to_kmsg)
server_forward_kmsg(s, priority, identifier, message, ucred);
if (m->forward_to_kmsg)
manager_forward_kmsg(m, priority, identifier, message, ucred);
if (s->forward_to_console)
server_forward_console(s, priority, identifier, message, ucred);
if (m->forward_to_console)
manager_forward_console(m, priority, identifier, message, ucred);
if (s->forward_to_wall)
server_forward_wall(s, priority, identifier, message, ucred);
if (m->forward_to_wall)
manager_forward_wall(m, priority, identifier, message, ucred);
}
server_dispatch_message(s, iovec, n, MALLOC_ELEMENTSOF(iovec), context, tv, priority, object_pid);
manager_dispatch_message(m, iovec, n, MALLOC_ELEMENTSOF(iovec), context, tv, priority, object_pid);
finish:
for (j = 0; j < n; j++) {
@@ -298,8 +298,8 @@ finish:
return r;
}
void server_process_native_message(
Server *s,
void manager_process_native_message(
Manager *m,
const char *buffer, size_t buffer_size,
const struct ucred *ucred,
const struct timeval *tv,
@@ -309,11 +309,11 @@ void server_process_native_message(
ClientContext *context = NULL;
int r;
assert(s);
assert(m);
assert(buffer || buffer_size == 0);
if (ucred && pid_is_valid(ucred->pid)) {
r = client_context_get(s, ucred->pid, ucred, label, label_len, NULL, &context);
r = client_context_get(m, ucred->pid, ucred, label, label_len, NULL, &context);
if (r < 0)
log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to retrieve credentials for PID " PID_FMT ", ignoring: %m",
@@ -321,14 +321,14 @@ void server_process_native_message(
}
do {
r = server_process_entry(s,
r = manager_process_entry(m,
(const uint8_t*) buffer + (buffer_size - remaining), &remaining,
context, ucred, tv, label, label_len);
} while (r == 0);
}
int server_process_native_file(
Server *s,
int manager_process_native_file(
Manager *m,
int fd,
const struct ucred *ucred,
const struct timeval *tv,
@@ -340,7 +340,7 @@ int server_process_native_file(
/* Data is in the passed fd, probably it didn't fit in a datagram. */
assert(s);
assert(m);
assert(fd >= 0);
if (fstat(fd, &st) < 0)
@@ -409,7 +409,7 @@ int server_process_native_file(
return log_ratelimit_error_errno(errno, JOURNAL_LOG_RATELIMIT,
"Failed to map memfd: %m");
server_process_native_message(s, p, st.st_size, ucred, tv, label, label_len);
manager_process_native_message(m, p, st.st_size, ucred, tv, label, label_len);
assert_se(munmap(p, ps) >= 0);
return 0;
@@ -450,18 +450,18 @@ int server_process_native_file(
return log_ratelimit_error_errno(errno, JOURNAL_LOG_RATELIMIT,
"Failed to read file: %m");
if (n > 0)
server_process_native_message(s, p, n, ucred, tv, label, label_len);
manager_process_native_message(m, p, n, ucred, tv, label, label_len);
return 0;
}
int server_open_native_socket(Server *s, const char *native_socket) {
int manager_open_native_socket(Manager *m, const char *native_socket) {
int r;
assert(s);
assert(m);
assert(native_socket);
if (s->native_fd < 0) {
if (m->native_fd < 0) {
union sockaddr_union sa;
size_t sa_len;
@@ -470,39 +470,39 @@ int server_open_native_socket(Server *s, const char *native_socket) {
return log_error_errno(r, "Unable to use namespace path %s for AF_UNIX socket: %m", native_socket);
sa_len = r;
s->native_fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
if (s->native_fd < 0)
m->native_fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
if (m->native_fd < 0)
return log_error_errno(errno, "socket() failed: %m");
(void) sockaddr_un_unlink(&sa.un);
r = bind(s->native_fd, &sa.sa, sa_len);
r = bind(m->native_fd, &sa.sa, sa_len);
if (r < 0)
return log_error_errno(errno, "bind(%s) failed: %m", sa.un.sun_path);
(void) chmod(sa.un.sun_path, 0666);
} else
(void) fd_nonblock(s->native_fd, true);
(void) fd_nonblock(m->native_fd, true);
r = setsockopt_int(s->native_fd, SOL_SOCKET, SO_PASSCRED, true);
r = setsockopt_int(m->native_fd, SOL_SOCKET, SO_PASSCRED, true);
if (r < 0)
return log_error_errno(r, "SO_PASSCRED failed: %m");
if (mac_selinux_use()) {
r = setsockopt_int(s->native_fd, SOL_SOCKET, SO_PASSSEC, true);
r = setsockopt_int(m->native_fd, SOL_SOCKET, SO_PASSSEC, true);
if (r < 0)
log_warning_errno(r, "SO_PASSSEC failed: %m");
}
r = setsockopt_int(s->native_fd, SOL_SOCKET, SO_TIMESTAMP, true);
r = setsockopt_int(m->native_fd, SOL_SOCKET, SO_TIMESTAMP, true);
if (r < 0)
return log_error_errno(r, "SO_TIMESTAMP failed: %m");
r = sd_event_add_io(s->event, &s->native_event_source, s->native_fd, EPOLLIN, server_process_datagram, s);
r = sd_event_add_io(m->event, &m->native_event_source, m->native_fd, EPOLLIN, manager_process_datagram, m);
if (r < 0)
return log_error_errno(r, "Failed to add native server fd to event loop: %m");
return log_error_errno(r, "Failed to add native manager fd to event loop: %m");
r = sd_event_source_set_priority(s->native_event_source, SD_EVENT_PRIORITY_NORMAL+5);
r = sd_event_source_set_priority(m->native_event_source, SD_EVENT_PRIORITY_NORMAL+5);
if (r < 0)
return log_error_errno(r, "Failed to adjust native event source priority: %m");
+6 -6
View File
@@ -4,10 +4,10 @@
#include <stddef.h>
#include <sys/socket.h>
typedef struct Server Server;
typedef struct Manager Manager;
void server_process_native_message(
Server *s,
void manager_process_native_message(
Manager *m,
const char *buffer,
size_t buffer_size,
const struct ucred *ucred,
@@ -15,12 +15,12 @@ void server_process_native_message(
const char *label,
size_t label_len);
int server_process_native_file(
Server *s,
int manager_process_native_file(
Manager *m,
int fd,
const struct ucred *ucred,
const struct timeval *tv,
const char *label,
size_t label_len);
int server_open_native_socket(Server *s, const char *native_socket);
int manager_open_native_socket(Manager *m, const char *native_socket);
+14 -14
View File
@@ -6,7 +6,7 @@
#include "fd-util.h"
#include "iovec-util.h"
#include "journald-server.h"
#include "journald-manager.h"
#include "journald-socket.h"
#include "log.h"
#include "macro.h"
@@ -14,21 +14,21 @@
#include "socket-util.h"
#include "sparse-endian.h"
static int server_open_forward_socket(Server *s) {
static int manager_open_forward_socket(Manager *m) {
_cleanup_close_ int socket_fd = -EBADF;
const SocketAddress *addr;
int family;
assert(s);
assert(m);
/* Noop if there is nothing to do. */
if (s->forward_to_socket.sockaddr.sa.sa_family == AF_UNSPEC || s->namespace)
if (m->forward_to_socket.sockaddr.sa.sa_family == AF_UNSPEC || m->namespace)
return 0;
/* All ready, nothing to do. */
if (s->forward_socket_fd >= 0)
if (m->forward_socket_fd >= 0)
return 1;
addr = &s->forward_to_socket;
addr = &m->forward_to_socket;
family = socket_address_family(addr);
@@ -43,7 +43,7 @@ static int server_open_forward_socket(Server *s) {
if (connect(socket_fd, &addr->sockaddr.sa, addr->size) < 0)
return log_debug_errno(errno, "Failed to connect to remote address for forwarding, ignoring: %m");
s->forward_socket_fd = TAKE_FD(socket_fd);
m->forward_socket_fd = TAKE_FD(socket_fd);
log_debug("Successfully connected to remote address for forwarding.");
return 1;
}
@@ -67,8 +67,8 @@ static inline bool must_serialize(struct iovec iov) {
return false;
}
int server_forward_socket(
Server *s,
int manager_forward_socket(
Manager *m,
const struct iovec *iovec,
size_t n_iovec,
const dual_timestamp *ts,
@@ -80,15 +80,15 @@ int server_forward_socket(
le64_t *len;
int r;
assert(s);
assert(m);
assert(iovec);
assert(n_iovec > 0);
assert(ts);
if (LOG_PRI(priority) > s->max_level_socket)
if (LOG_PRI(priority) > m->max_level_socket)
return 0;
r = server_open_forward_socket(s);
r = manager_open_forward_socket(m);
if (r <= 0)
return r;
@@ -152,12 +152,12 @@ int server_forward_socket(
xsprintf(monotonic_buf, "__MONOTONIC_TIMESTAMP="USEC_FMT"\n\n", ts->monotonic);
iov[iov_idx++] = IOVEC_MAKE_STRING(monotonic_buf);
if (writev(s->forward_socket_fd, iov, iov_idx) < 0) {
if (writev(m->forward_socket_fd, iov, iov_idx) < 0) {
log_debug_errno(errno, "Failed to forward log message over socket: %m");
/* If we failed to send once we will probably fail again so wait for a new connection to
* establish before attempting to forward again. */
s->forward_socket_fd = safe_close(s->forward_socket_fd);
m->forward_socket_fd = safe_close(m->forward_socket_fd);
}
return 0;
+2 -2
View File
@@ -5,6 +5,6 @@
#include "time-util.h"
typedef struct Server Server;
typedef struct Manager Manager;
int server_forward_socket(Server *s, const struct iovec *iovec, size_t n, const dual_timestamp *ts, int priority);
int manager_forward_socket(Manager *m, const struct iovec *iovec, size_t n, const dual_timestamp *ts, int priority);
+66 -67
View File
@@ -25,7 +25,7 @@
#include "journald-console.h"
#include "journald-context.h"
#include "journald-kmsg.h"
#include "journald-server.h"
#include "journald-manager.h"
#include "journald-stream.h"
#include "journald-syslog.h"
#include "journald-wall.h"
@@ -69,16 +69,16 @@ StdoutStream* stdout_stream_free(StdoutStream *s) {
while (s->stream_sync_reqs)
stream_sync_req_free(s->stream_sync_reqs);
if (s->server) {
if (s->manager) {
if (s->context)
client_context_release(s->server, s->context);
client_context_release(s->manager, s->context);
assert(s->server->n_stdout_streams > 0);
s->server->n_stdout_streams--;
LIST_REMOVE(stdout_stream, s->server->stdout_streams, s);
assert(s->manager->n_stdout_streams > 0);
s->manager->n_stdout_streams--;
LIST_REMOVE(stdout_stream, s->manager->stdout_streams, s);
if (s->in_notify_queue)
LIST_REMOVE(stdout_stream_notify_queue, s->server->stdout_streams_notify_queue, s);
LIST_REMOVE(stdout_stream_notify_queue, s->manager->stdout_streams_notify_queue, s);
}
sd_event_source_disable_unref(s->event_source);
@@ -108,9 +108,9 @@ void stdout_stream_terminate(StdoutStream *s) {
sync_req_revalidate(TAKE_PTR(req));
}
Server *server = s->server;
Manager *manager = s->manager;
stdout_stream_free(TAKE_PTR(s));
(void) server_start_or_stop_idle_timer(server); /* Maybe we are idle now? */
(void) manager_start_or_stop_idle_timer(manager); /* Maybe we are idle now? */
}
static int stdout_stream_save(StdoutStream *s) {
@@ -132,7 +132,7 @@ static int stdout_stream_save(StdoutStream *s) {
"Failed to stat connected stream: %m");
/* We use device and inode numbers as identifier for the stream */
r = asprintf(&s->state_file, "%s/streams/%lu:%lu", s->server->runtime_directory, (unsigned long) st.st_dev, (unsigned long) st.st_ino);
r = asprintf(&s->state_file, "%s/streams/%lu:%lu", s->manager->runtime_directory, (unsigned long) st.st_dev, (unsigned long) st.st_ino);
if (r < 0)
return log_oom();
}
@@ -186,19 +186,18 @@ static int stdout_stream_save(StdoutStream *s) {
if (r < 0)
goto fail;
if (rename(temp_path, s->state_file) < 0) {
r = -errno;
r = RET_NERRNO(rename(temp_path, s->state_file));
if (r < 0)
goto fail;
}
temp_path = mfree(temp_path);
if (!s->fdstore && !s->in_notify_queue) {
LIST_PREPEND(stdout_stream_notify_queue, s->server->stdout_streams_notify_queue, s);
LIST_PREPEND(stdout_stream_notify_queue, s->manager->stdout_streams_notify_queue, s);
s->in_notify_queue = true;
if (s->server->notify_event_source) {
r = sd_event_source_set_enabled(s->server->notify_event_source, SD_EVENT_ON);
if (s->manager->notify_event_source) {
r = sd_event_source_set_enabled(s->manager->notify_event_source, SD_EVENT_ON);
if (r < 0)
log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT, "Failed to enable notify event source: %m");
}
@@ -232,9 +231,9 @@ static int stdout_stream_log(
assert(line_break < _LINE_BREAK_MAX);
if (s->context)
(void) client_context_maybe_refresh(s->server, s->context, NULL, NULL, 0, NULL, USEC_INFINITY);
(void) client_context_maybe_refresh(s->manager, s->context, NULL, NULL, 0, NULL, USEC_INFINITY);
else if (pid_is_valid(s->ucred.pid)) {
r = client_context_acquire(s->server, s->ucred.pid, &s->ucred, s->label, strlen_ptr(s->label), s->unit_id, &s->context);
r = client_context_acquire(s->manager, s->ucred.pid, &s->ucred, s->label, strlen_ptr(s->label), s->unit_id, &s->context);
if (r < 0)
log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to acquire client context, ignoring: %m");
@@ -255,17 +254,17 @@ static int stdout_stream_log(
if (r <= 0)
return r;
if (s->forward_to_syslog || s->server->forward_to_syslog)
server_forward_syslog(s->server, syslog_fixup_facility(priority), s->identifier, p, &s->ucred, NULL);
if (s->forward_to_syslog || s->manager->forward_to_syslog)
manager_forward_syslog(s->manager, syslog_fixup_facility(priority), s->identifier, p, &s->ucred, NULL);
if (s->forward_to_kmsg || s->server->forward_to_kmsg)
server_forward_kmsg(s->server, priority, s->identifier, p, &s->ucred);
if (s->forward_to_kmsg || s->manager->forward_to_kmsg)
manager_forward_kmsg(s->manager, priority, s->identifier, p, &s->ucred);
if (s->forward_to_console || s->server->forward_to_console)
server_forward_console(s->server, priority, s->identifier, p, &s->ucred);
if (s->forward_to_console || s->manager->forward_to_console)
manager_forward_console(s->manager, priority, s->identifier, p, &s->ucred);
if (s->server->forward_to_wall)
server_forward_wall(s->server, priority, s->identifier, p, &s->ucred);
if (s->manager->forward_to_wall)
manager_forward_wall(s->manager, priority, s->identifier, p, &s->ucred);
m = N_IOVEC_META_FIELDS + 7 + client_context_extra_fields_n_iovec(s->context);
iovec = newa(struct iovec, m);
@@ -306,7 +305,7 @@ static int stdout_stream_log(
if (message)
iovec[n++] = IOVEC_MAKE_STRING(message);
server_dispatch_message(s->server, iovec, n, m, s->context, NULL, priority, 0);
manager_dispatch_message(s->manager, iovec, n, m, s->context, NULL, priority, 0);
return 0;
}
@@ -458,7 +457,7 @@ static size_t stdout_stream_line_max(StdoutStream *s) {
return STDOUT_STREAM_SETUP_PROTOCOL_LINE_MAX;
/* After the protocol's "setup" phase is complete, let's use whatever the user configured */
return s->server->line_max;
return s->manager->line_max;
}
static int stdout_stream_scan(
@@ -561,7 +560,7 @@ static int stdout_stream_process(sd_event_source *es, int fd, uint32_t revents,
/* Try to make use of the allocated buffer in full, but never read more than the configured line size. Also,
* always leave room for a terminating NUL we might need to add. */
limit = MIN(allocated - 1, MAX(s->server->line_max, STDOUT_STREAM_SETUP_PROTOCOL_LINE_MAX));
limit = MIN(allocated - 1, MAX(s->manager->line_max, STDOUT_STREAM_SETUP_PROTOCOL_LINE_MAX));
assert(s->length <= limit);
iovec = IOVEC_MAKE(s->buffer + s->length, limit - s->length);
@@ -591,7 +590,7 @@ static int stdout_stream_process(sd_event_source *es, int fd, uint32_t revents,
if (r < 0)
goto terminate;
s->context = client_context_release(s->server, s->context);
s->context = client_context_release(s->manager, s->context);
p = s->buffer + s->length;
} else {
@@ -623,12 +622,12 @@ terminate:
return 0;
}
int stdout_stream_install(Server *s, int fd, StdoutStream **ret) {
int stdout_stream_install(Manager *m, int fd, StdoutStream **ret) {
_cleanup_(stdout_stream_freep) StdoutStream *stream = NULL;
sd_id128_t id;
int r;
assert(s);
assert(m);
assert(fd >= 0);
r = sd_id128_randomize(&id);
@@ -663,7 +662,7 @@ int stdout_stream_install(Server *s, int fd, StdoutStream **ret) {
(void) shutdown(fd, SHUT_WR);
r = sd_event_add_io(s->event, &stream->event_source, fd, EPOLLIN, stdout_stream_process, stream);
r = sd_event_add_io(m->event, &stream->event_source, fd, EPOLLIN, stdout_stream_process, stream);
if (r < 0)
return log_ratelimit_error_errno(r, JOURNAL_LOG_RATELIMIT, "Failed to add stream to event loop: %m");
@@ -673,11 +672,11 @@ int stdout_stream_install(Server *s, int fd, StdoutStream **ret) {
stream->fd = fd;
stream->server = s;
LIST_PREPEND(stdout_stream, s->stdout_streams, stream);
s->n_stdout_streams++;
stream->manager = m;
LIST_PREPEND(stdout_stream, m->stdout_streams, stream);
m->n_stdout_streams++;
(void) server_start_or_stop_idle_timer(s); /* Maybe no longer idle? */
(void) manager_start_or_stop_idle_timer(m); /* Maybe no longer idle? */
if (ret)
*ret = stream;
@@ -688,7 +687,7 @@ int stdout_stream_install(Server *s, int fd, StdoutStream **ret) {
static int stdout_stream_new(sd_event_source *es, int listen_fd, uint32_t revents, void *userdata) {
_cleanup_close_ int fd = -EBADF;
Server *s = ASSERT_PTR(userdata);
Manager *m = ASSERT_PTR(userdata);
int r;
if (revents != EPOLLIN)
@@ -696,7 +695,7 @@ static int stdout_stream_new(sd_event_source *es, int listen_fd, uint32_t revent
"Got invalid event from epoll for stdout server fd: %" PRIx32,
revents);
fd = accept4(s->stdout_fd, NULL, NULL, SOCK_NONBLOCK|SOCK_CLOEXEC);
fd = accept4(m->stdout_fd, NULL, NULL, SOCK_NONBLOCK|SOCK_CLOEXEC);
if (fd < 0) {
if (ERRNO_IS_ACCEPT_AGAIN(errno))
return 0;
@@ -704,7 +703,7 @@ static int stdout_stream_new(sd_event_source *es, int listen_fd, uint32_t revent
return log_ratelimit_error_errno(errno, JOURNAL_LOG_RATELIMIT, "Failed to accept stdout connection: %m");
}
if (s->n_stdout_streams >= STDOUT_STREAMS_MAX) {
if (m->n_stdout_streams >= STDOUT_STREAMS_MAX) {
struct ucred u = UCRED_INVALID;
(void) getpeercred(fd, &u);
@@ -715,23 +714,23 @@ static int stdout_stream_new(sd_event_source *es, int listen_fd, uint32_t revent
*/
fd = safe_close(fd);
server_driver_message(s, u.pid, LOG_MESSAGE("Too many stdout streams, refusing connection."));
manager_driver_message(m, u.pid, LOG_MESSAGE("Too many stdout streams, refusing connection."));
server_notify_stream(s, /* stream= */ NULL);
manager_notify_stream(m, /* stream= */ NULL);
return 0;
}
StdoutStream *stream;
r = stdout_stream_install(s, fd, &stream);
r = stdout_stream_install(m, fd, &stream);
if (r < 0) {
server_notify_stream(s, /* stream= */ NULL);
manager_notify_stream(m, /* stream= */ NULL);
return r;
}
TAKE_FD(fd);
/* Tell the synchronization logic that we dropped one item from the incoming connection queue */
server_notify_stream(s, stream);
manager_notify_stream(m, stream);
return 0;
}
@@ -750,7 +749,7 @@ static int stdout_stream_load(StdoutStream *stream, const char *fname) {
assert(fname);
if (!stream->state_file) {
stream->state_file = path_join(stream->server->runtime_directory, "streams", fname);
stream->state_file = path_join(stream->manager->runtime_directory, "streams", fname);
if (!stream->state_file)
return log_oom();
}
@@ -810,19 +809,19 @@ static int stdout_stream_load(StdoutStream *stream, const char *fname) {
return 0;
}
static int stdout_stream_restore(Server *s, const char *fname, int fd) {
static int stdout_stream_restore(Manager *m, const char *fname, int fd) {
StdoutStream *stream;
int r;
assert(s);
assert(m);
assert(fname);
assert(fd >= 0);
if (s->n_stdout_streams >= STDOUT_STREAMS_MAX)
if (m->n_stdout_streams >= STDOUT_STREAMS_MAX)
return log_warning_errno(SYNTHETIC_ERRNO(ENOBUFS),
"Too many stdout streams, refusing restoring of stream.");
r = stdout_stream_install(s, fd, &stream);
r = stdout_stream_install(m, fd, &stream);
if (r < 0)
return r;
@@ -835,12 +834,12 @@ static int stdout_stream_restore(Server *s, const char *fname, int fd) {
return 0;
}
int server_restore_streams(Server *s, FDSet *fds) {
int manager_restore_streams(Manager *m, FDSet *fds) {
_cleanup_closedir_ DIR *d = NULL;
const char *path;
int r;
path = strjoina(s->runtime_directory, "/streams");
path = strjoina(m->runtime_directory, "/streams");
d = opendir(path);
if (!d) {
if (errno == ENOENT)
@@ -879,7 +878,7 @@ int server_restore_streams(Server *s, FDSet *fds) {
fdset_remove(fds, fd);
r = stdout_stream_restore(s, de->d_name, fd);
r = stdout_stream_restore(m, de->d_name, fd);
if (r < 0)
safe_close(fd);
}
@@ -890,13 +889,13 @@ fail:
return log_error_errno(errno, "Failed to read streams directory: %m");
}
int server_open_stdout_socket(Server *s, const char *stdout_socket) {
int manager_open_stdout_socket(Manager *m, const char *stdout_socket) {
int r;
assert(s);
assert(m);
assert(stdout_socket);
if (s->stdout_fd < 0) {
if (m->stdout_fd < 0) {
union sockaddr_union sa;
socklen_t sa_len;
@@ -905,28 +904,28 @@ int server_open_stdout_socket(Server *s, const char *stdout_socket) {
return log_error_errno(r, "Unable to use namespace path %s for AF_UNIX socket: %m", stdout_socket);
sa_len = r;
s->stdout_fd = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
if (s->stdout_fd < 0)
m->stdout_fd = socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
if (m->stdout_fd < 0)
return log_error_errno(errno, "socket() failed: %m");
(void) sockaddr_un_unlink(&sa.un);
r = bind(s->stdout_fd, &sa.sa, sa_len);
r = bind(m->stdout_fd, &sa.sa, sa_len);
if (r < 0)
return log_error_errno(errno, "bind(%s) failed: %m", sa.un.sun_path);
(void) chmod(sa.un.sun_path, 0666);
if (listen(s->stdout_fd, SOMAXCONN_DELUXE) < 0)
if (listen(m->stdout_fd, SOMAXCONN_DELUXE) < 0)
return log_error_errno(errno, "listen(%s) failed: %m", sa.un.sun_path);
} else
(void) fd_nonblock(s->stdout_fd, true);
(void) fd_nonblock(m->stdout_fd, true);
r = sd_event_add_io(s->event, &s->stdout_event_source, s->stdout_fd, EPOLLIN, stdout_stream_new, s);
r = sd_event_add_io(m->event, &m->stdout_event_source, m->stdout_fd, EPOLLIN, stdout_stream_new, m);
if (r < 0)
return log_error_errno(r, "Failed to add stdout server fd to event source: %m");
r = sd_event_source_set_priority(s->stdout_event_source, SD_EVENT_PRIORITY_NORMAL+5);
r = sd_event_source_set_priority(m->stdout_event_source, SD_EVENT_PRIORITY_NORMAL+5);
if (r < 0)
return log_error_errno(r, "Failed to adjust priority of stdout server event source: %m");
@@ -948,8 +947,8 @@ void stdout_stream_send_notify(StdoutStream *s) {
assert(s);
assert(!s->fdstore);
assert(s->in_notify_queue);
assert(s->server);
assert(s->server->notify_fd >= 0);
assert(s->manager);
assert(s->manager->notify_fd >= 0);
/* Store the connection fd in PID 1, so that we get it passed
* in again on next start */
@@ -964,7 +963,7 @@ void stdout_stream_send_notify(StdoutStream *s) {
memcpy(CMSG_DATA(cmsg), &s->fd, sizeof(int));
l = sendmsg(s->server->notify_fd, &msghdr, MSG_DONTWAIT|MSG_NOSIGNAL);
l = sendmsg(s->manager->notify_fd, &msghdr, MSG_DONTWAIT|MSG_NOSIGNAL);
if (l < 0) {
if (errno == EAGAIN)
return;
@@ -975,6 +974,6 @@ void stdout_stream_send_notify(StdoutStream *s) {
s->fdstore = 1;
}
LIST_REMOVE(stdout_stream_notify_queue, s->server->stdout_streams_notify_queue, s);
LIST_REMOVE(stdout_stream_notify_queue, s->manager->stdout_streams_notify_queue, s);
s->in_notify_queue = false;
}
+5 -5
View File
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
typedef struct Server Server;
typedef struct Manager Manager;
typedef struct StdoutStream StdoutStream;
typedef struct StreamSyncReq StreamSyncReq;
@@ -20,7 +20,7 @@ typedef enum StdoutStreamState {
} StdoutStreamState;
struct StdoutStream {
Server *server;
Manager *manager;
StdoutStreamState state;
int fd;
@@ -55,10 +55,10 @@ struct StdoutStream {
LIST_HEAD(StreamSyncReq, stream_sync_reqs);
};
int server_open_stdout_socket(Server *s, const char *stdout_socket);
int server_restore_streams(Server *s, FDSet *fds);
int manager_open_stdout_socket(Manager *m, const char *stdout_socket);
int manager_restore_streams(Manager *m, FDSet *fds);
StdoutStream* stdout_stream_free(StdoutStream *s);
int stdout_stream_install(Server *s, int fd, StdoutStream **ret);
int stdout_stream_install(Manager *m, int fd, StdoutStream **ret);
void stdout_stream_terminate(StdoutStream *s);
void stdout_stream_send_notify(StdoutStream *s);
+38 -38
View File
@@ -6,7 +6,7 @@
#include "sd-varlink.h"
#include "io-util.h"
#include "journald-server.h"
#include "journald-manager.h"
#include "journald-stream.h"
#include "journald-sync.h"
#include "journald-varlink.h"
@@ -49,7 +49,7 @@ static bool sync_req_is_complete(SyncReq *req) {
int r;
assert(req);
assert(req->server);
assert(req->manager);
/* In case the clock jumped backwards, let's adjust the timestamp, to guarantee reasonably quick
* termination */
@@ -61,18 +61,18 @@ static bool sync_req_is_complete(SyncReq *req) {
/* If this sync request is still in the priority queue it means we still need to check if
* incoming message timestamps are now newer than then sync request timestamp. */
if (req->server->native_fd >= 0 &&
req->server->native_timestamp < req->realtime) {
r = fd_wait_for_event(req->server->native_fd, POLLIN, /* timeout= */ 0);
if (req->manager->native_fd >= 0 &&
req->manager->native_timestamp < req->realtime) {
r = fd_wait_for_event(req->manager->native_fd, POLLIN, /* timeout= */ 0);
if (r < 0)
log_debug_errno(r, "Failed to determine pending IO events of native socket, ignoring: %m");
else if (r != 0) /* if there's more queued we need to wait for the timestamp to pass. If it's idle though we are done here. */
return false;
}
if (req->server->syslog_fd >= 0&&
req->server->syslog_timestamp < req->realtime) {
r = fd_wait_for_event(req->server->syslog_fd, POLLIN, /* timeout= */ 0);
if (req->manager->syslog_fd >= 0&&
req->manager->syslog_timestamp < req->realtime) {
r = fd_wait_for_event(req->manager->syslog_fd, POLLIN, /* timeout= */ 0);
if (r < 0)
log_debug_errno(r, "Failed to determine pending IO events of syslog socket, ignoring: %m");
else if (r != 0)
@@ -82,22 +82,22 @@ static bool sync_req_is_complete(SyncReq *req) {
/* This sync request is fulfilled for the native + syslog datagram streams? Then, let's
* remove this sync request from the priority queue, so that we dont need to consider it
* anymore. */
assert(prioq_remove(req->server->sync_req_realtime_prioq, req, &req->realtime_prioq_idx) > 0);
assert(prioq_remove(req->manager->sync_req_realtime_prioq, req, &req->realtime_prioq_idx) > 0);
}
if (req->boottime_prioq_idx != PRIOQ_IDX_NULL) {
/* Very similar to the above, but for /dev/kmsg we operate on the CLOCK_BOOTTIME clock */
if (req->server->dev_kmsg_fd >= 0 &&
req->server->dev_kmsg_timestamp < req->boottime) {
r = fd_wait_for_event(req->server->dev_kmsg_fd, POLLIN, /* timeout= */ 0);
if (req->manager->dev_kmsg_fd >= 0 &&
req->manager->dev_kmsg_timestamp < req->boottime) {
r = fd_wait_for_event(req->manager->dev_kmsg_fd, POLLIN, /* timeout= */ 0);
if (r < 0)
log_debug_errno(r, "Failed to determine pending IO events of /dev/kmsg file descriptor, ignoring: %m");
else if (r != 0)
return false;
}
assert(prioq_remove(req->server->sync_req_boottime_prioq, req, &req->boottime_prioq_idx) > 0);
assert(prioq_remove(req->manager->sync_req_boottime_prioq, req, &req->boottime_prioq_idx) > 0);
}
/* If there are still streams with pending counters, we still need to look into things */
@@ -127,15 +127,15 @@ SyncReq* sync_req_free(SyncReq *req) {
if (!req)
return NULL;
if (req->server) {
if (req->manager) {
if (req->realtime_prioq_idx != PRIOQ_IDX_NULL)
assert_se(prioq_remove(req->server->sync_req_realtime_prioq, req, &req->realtime_prioq_idx) > 0);
assert_se(prioq_remove(req->manager->sync_req_realtime_prioq, req, &req->realtime_prioq_idx) > 0);
if (req->boottime_prioq_idx != PRIOQ_IDX_NULL)
assert_se(prioq_remove(req->server->sync_req_boottime_prioq, req, &req->boottime_prioq_idx) > 0);
assert_se(prioq_remove(req->manager->sync_req_boottime_prioq, req, &req->boottime_prioq_idx) > 0);
if (req->pending_rqlen > 0)
LIST_REMOVE(pending_rqlen, req->server->sync_req_pending_rqlen, req);
LIST_REMOVE(pending_rqlen, req->manager->sync_req_pending_rqlen, req);
}
req->idle_event_source = sd_event_source_disable_unref(req->idle_event_source);
@@ -183,10 +183,10 @@ static int sync_req_add_stream(SyncReq *req, StdoutStream *ss) {
return 1;
}
int sync_req_new(Server *s, sd_varlink *link, SyncReq **ret) {
int sync_req_new(Manager *m, sd_varlink *link, SyncReq **ret) {
int r;
assert(s);
assert(m);
assert(link);
assert(ret);
@@ -195,7 +195,7 @@ int sync_req_new(Server *s, sd_varlink *link, SyncReq **ret) {
return -ENOMEM;
*req = (SyncReq) {
.server = s,
.manager = m,
.link = sd_varlink_ref(link),
.realtime_prioq_idx = PRIOQ_IDX_NULL,
.boottime_prioq_idx = PRIOQ_IDX_NULL,
@@ -239,19 +239,19 @@ int sync_req_new(Server *s, sd_varlink *link, SyncReq **ret) {
req->realtime = now(CLOCK_REALTIME);
req->boottime = now(CLOCK_BOOTTIME);
if (s->native_event_source || s->syslog_event_source) {
r = prioq_ensure_put(&s->sync_req_realtime_prioq, sync_req_realtime_compare, req, &req->realtime_prioq_idx);
if (m->native_event_source || m->syslog_event_source) {
r = prioq_ensure_put(&m->sync_req_realtime_prioq, sync_req_realtime_compare, req, &req->realtime_prioq_idx);
if (r < 0)
return r;
}
if (s->dev_kmsg_event_source) {
r = prioq_ensure_put(&s->sync_req_boottime_prioq, sync_req_boottime_compare, req, &req->boottime_prioq_idx);
if (m->dev_kmsg_event_source) {
r = prioq_ensure_put(&m->sync_req_boottime_prioq, sync_req_boottime_compare, req, &req->boottime_prioq_idx);
if (r < 0)
return r;
}
r = sd_event_add_defer(s->event, &req->idle_event_source, on_idle, req);
r = sd_event_add_defer(m->event, &req->idle_event_source, on_idle, req);
if (r < 0)
return r;
@@ -263,7 +263,7 @@ int sync_req_new(Server *s, sd_varlink *link, SyncReq **ret) {
/* Now determine the pending byte counter for each stdout stream. If non-zero allocate a
* StreamSyncReq for the stream to keep track of it */
LIST_FOREACH(stdout_stream, ss, s->stdout_streams) {
LIST_FOREACH(stdout_stream, ss, m->stdout_streams) {
r = sync_req_add_stream(req, ss);
if (r < 0)
return r;
@@ -271,11 +271,11 @@ int sync_req_new(Server *s, sd_varlink *link, SyncReq **ret) {
/* Also track how many pending, incoming stream sockets there are currently, so that we process them
* too */
r = af_unix_get_qlen(s->stdout_fd, &req->pending_rqlen);
r = af_unix_get_qlen(m->stdout_fd, &req->pending_rqlen);
if (r < 0)
log_warning_errno(r, "Failed to determine current incoming queue length, ignoring: %m");
if (req->pending_rqlen > 0)
LIST_PREPEND(pending_rqlen, s->sync_req_pending_rqlen, req);
LIST_PREPEND(pending_rqlen, m->sync_req_pending_rqlen, req);
*ret = TAKE_PTR(req);
return 0;
@@ -310,7 +310,7 @@ static void sync_req_advance_rqlen_revalidate(SyncReq *req, uint32_t current_rql
/* If there are no more connections to wait for, remove us from the list of synchronization
* requests with non-zero pending connection counters */
if (n == 0)
LIST_REMOVE(pending_rqlen, req->server->sync_req_pending_rqlen, req);
LIST_REMOVE(pending_rqlen, req->manager->sync_req_pending_rqlen, req);
}
req->pending_rqlen = n;
@@ -318,26 +318,26 @@ static void sync_req_advance_rqlen_revalidate(SyncReq *req, uint32_t current_rql
sync_req_revalidate(req);
}
void server_notify_stream(Server *s, StdoutStream *ss) {
void manager_notify_stream(Manager *m, StdoutStream *ss) {
int r;
assert(s);
assert(m);
/* Invoked whenever a new connection was accept()ed, i.e. dropped off the queue of pending incoming
* connections. */
if (!s->sync_req_pending_rqlen)
if (!m->sync_req_pending_rqlen)
return;
uint32_t current_qlen;
r = af_unix_get_qlen(s->stdout_fd, &current_qlen);
r = af_unix_get_qlen(m->stdout_fd, &current_qlen);
if (r < 0) {
log_warning_errno(r, "Failed to determine current AF_UNIX stream socket pending connections, ignoring: %m");
current_qlen = UINT32_MAX;
}
LIST_FOREACH(pending_rqlen, sr, s->sync_req_pending_rqlen)
LIST_FOREACH(pending_rqlen, sr, m->sync_req_pending_rqlen)
/* NB: this might invalidate the SyncReq object! */
sync_req_advance_rqlen_revalidate(sr, current_qlen, ss);
}
@@ -355,18 +355,18 @@ bool sync_req_revalidate(SyncReq *req) {
return true;
}
void sync_req_revalidate_by_timestamp(Server *s) {
assert(s);
void sync_req_revalidate_by_timestamp(Manager *m) {
assert(m);
/* Go through the pending sync requests by timestamp, and complete those for which a sync is now
* complete. */
SyncReq *req;
while ((req = prioq_peek(s->sync_req_realtime_prioq)))
while ((req = prioq_peek(m->sync_req_realtime_prioq)))
if (!sync_req_revalidate(req))
break;
while ((req = prioq_peek(s->sync_req_boottime_prioq)))
while ((req = prioq_peek(m->sync_req_boottime_prioq)))
if (!sync_req_revalidate(req))
break;
}
+5 -5
View File
@@ -1,7 +1,7 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
typedef struct Server Server;
typedef struct Manager Manager;
typedef struct StreamSyncReq StreamSyncReq;
typedef struct SyncReq SyncReq;
@@ -23,7 +23,7 @@ struct StreamSyncReq {
/* Encapsulates a synchronization request */
struct SyncReq {
Server *server;
Manager *manager;
sd_varlink *link;
bool offline; /* if true, we'll offline the journal files after sync is complete */
@@ -46,11 +46,11 @@ StreamSyncReq *stream_sync_req_free(StreamSyncReq *ssr);
DEFINE_TRIVIAL_CLEANUP_FUNC(StreamSyncReq*, stream_sync_req_free);
void stream_sync_req_advance_revalidate(StreamSyncReq *ssr, size_t p);
int sync_req_new(Server *s, sd_varlink *link, SyncReq **ret);
int sync_req_new(Manager *m, sd_varlink *link, SyncReq **ret);
SyncReq* sync_req_free(SyncReq *req);
DEFINE_TRIVIAL_CLEANUP_FUNC(SyncReq*, sync_req_free);
bool sync_req_revalidate(SyncReq *req);
void sync_req_revalidate_by_timestamp(Server *s);
void sync_req_revalidate_by_timestamp(Manager *m);
void server_notify_stream(Server *s, StdoutStream *ss);
void manager_notify_stream(Manager *m, StdoutStream *ss);
+69 -55
View File
@@ -14,7 +14,7 @@
#include "journald-client.h"
#include "journald-console.h"
#include "journald-kmsg.h"
#include "journald-server.h"
#include "journald-manager.h"
#include "journald-syslog.h"
#include "journald-wall.h"
#include "process-util.h"
@@ -28,7 +28,7 @@
#define WARN_FORWARD_SYSLOG_MISSED_USEC (30 * USEC_PER_SEC)
static void forward_syslog_iovec(
Server *s,
Manager *m,
const struct iovec *iovec,
unsigned n_iovec,
const struct ucred *ucred,
@@ -45,11 +45,11 @@ static void forward_syslog_iovec(
const char *j;
int r;
assert(s);
assert(m);
assert(iovec);
assert(n_iovec > 0);
j = strjoina(s->runtime_directory, "/syslog");
j = strjoina(m->runtime_directory, "/syslog");
r = sockaddr_un_set_path(&sa.un, j);
if (r < 0) {
log_debug_errno(r, "Forwarding socket path %s too long for AF_UNIX, not forwarding: %m", j);
@@ -75,13 +75,13 @@ static void forward_syslog_iovec(
/* Forward the syslog message we received via /dev/log to /run/systemd/syslog. Unfortunately we
* currently can't set the SO_TIMESTAMP auxiliary data, and hence we don't. */
if (sendmsg(s->syslog_fd, &msghdr, MSG_NOSIGNAL) >= 0)
if (sendmsg(m->syslog_fd, &msghdr, MSG_NOSIGNAL) >= 0)
return;
/* The socket is full? I guess the syslog implementation is
* too slow, and we shouldn't wait for that... */
if (errno == EAGAIN) {
s->n_forward_syslog_missed++;
m->n_forward_syslog_missed++;
return;
}
@@ -96,11 +96,11 @@ static void forward_syslog_iovec(
u.pid = getpid_cached();
memcpy(CMSG_DATA(cmsg), &u, sizeof(struct ucred));
if (sendmsg(s->syslog_fd, &msghdr, MSG_NOSIGNAL) >= 0)
if (sendmsg(m->syslog_fd, &msghdr, MSG_NOSIGNAL) >= 0)
return;
if (errno == EAGAIN) {
s->n_forward_syslog_missed++;
m->n_forward_syslog_missed++;
return;
}
}
@@ -109,20 +109,34 @@ static void forward_syslog_iovec(
log_debug_errno(errno, "Failed to forward syslog message: %m");
}
static void forward_syslog_raw(Server *s, int priority, const char *buffer, size_t buffer_len, const struct ucred *ucred, const struct timeval *tv) {
static void forward_syslog_raw(
Manager *m,
int priority,
const char *buffer,
size_t buffer_len,
const struct ucred *ucred,
const struct timeval *tv) {
struct iovec iovec;
assert(s);
assert(m);
assert(buffer);
if (LOG_PRI(priority) > s->max_level_syslog)
if (LOG_PRI(priority) > m->max_level_syslog)
return;
iovec = IOVEC_MAKE((char *) buffer, buffer_len);
forward_syslog_iovec(s, &iovec, 1, ucred, tv);
forward_syslog_iovec(m, &iovec, 1, ucred, tv);
}
void server_forward_syslog(Server *s, int priority, const char *identifier, const char *message, const struct ucred *ucred, const struct timeval *tv) {
void manager_forward_syslog(
Manager *m,
int priority,
const char *identifier,
const char *message,
const struct ucred *ucred,
const struct timeval *tv) {
struct iovec iovec[5];
char header_priority[DECIMAL_STR_MAX(priority) + 3], header_time[64],
header_pid[STRLEN("[]: ") + DECIMAL_STR_MAX(pid_t) + 1];
@@ -130,12 +144,12 @@ void server_forward_syslog(Server *s, int priority, const char *identifier, cons
struct tm tm;
_cleanup_free_ char *ident_buf = NULL;
assert(s);
assert(m);
assert(priority >= 0);
assert(priority <= 999);
assert(message);
if (LOG_PRI(priority) > s->max_level_syslog)
if (LOG_PRI(priority) > m->max_level_syslog)
return;
/* First: priority field */
@@ -170,7 +184,7 @@ void server_forward_syslog(Server *s, int priority, const char *identifier, cons
/* Fourth: message */
iovec[n++] = IOVEC_MAKE_STRING(message);
forward_syslog_iovec(s, iovec, n, ucred, tv);
forward_syslog_iovec(m, iovec, n, ucred, tv);
}
int syslog_fixup_facility(int priority) {
@@ -303,8 +317,8 @@ static int syslog_skip_timestamp(const char **buf) {
return p - t;
}
void server_process_syslog_message(
Server *s,
void manager_process_syslog_message(
Manager *m,
const char *buf,
size_t raw_len,
const struct ucred *ucred,
@@ -320,10 +334,10 @@ void server_process_syslog_message(
int priority = LOG_USER | LOG_INFO, r;
ClientContext *context = NULL;
struct iovec *iovec;
size_t n = 0, m, i, leading_ws, syslog_ts_len;
size_t n = 0, mm, i, leading_ws, syslog_ts_len;
bool store_raw;
assert(s);
assert(m);
assert(buf);
/* The message cannot be empty. */
assert(raw_len > 0);
@@ -332,7 +346,7 @@ void server_process_syslog_message(
assert(buf[raw_len] == '\0');
if (ucred && pid_is_valid(ucred->pid)) {
r = client_context_get(s, ucred->pid, ucred, label, label_len, NULL, &context);
r = client_context_get(m, ucred->pid, ucred, label, label_len, NULL, &context);
if (r < 0)
log_ratelimit_warning_errno(r, JOURNAL_LOG_RATELIMIT,
"Failed to retrieve credentials for PID " PID_FMT ", ignoring: %m",
@@ -384,20 +398,20 @@ void server_process_syslog_message(
syslog_parse_identifier(&msg, &identifier, &pid);
if (s->forward_to_syslog)
forward_syslog_raw(s, priority, buf, raw_len, ucred, tv);
if (m->forward_to_syslog)
forward_syslog_raw(m, priority, buf, raw_len, ucred, tv);
if (s->forward_to_kmsg)
server_forward_kmsg(s, priority, identifier, msg, ucred);
if (m->forward_to_kmsg)
manager_forward_kmsg(m, priority, identifier, msg, ucred);
if (s->forward_to_console)
server_forward_console(s, priority, identifier, msg, ucred);
if (m->forward_to_console)
manager_forward_console(m, priority, identifier, msg, ucred);
if (s->forward_to_wall)
server_forward_wall(s, priority, identifier, msg, ucred);
if (m->forward_to_wall)
manager_forward_wall(m, priority, identifier, msg, ucred);
m = N_IOVEC_META_FIELDS + 8 + client_context_extra_fields_n_iovec(context);
iovec = newa(struct iovec, m);
mm = N_IOVEC_META_FIELDS + 8 + client_context_extra_fields_n_iovec(context);
iovec = newa(struct iovec, mm);
iovec[n++] = IOVEC_MAKE_STRING("_TRANSPORT=syslog");
@@ -451,16 +465,16 @@ void server_process_syslog_message(
iovec[n++] = IOVEC_MAKE(msg_raw, hlen + raw_len);
}
server_dispatch_message(s, iovec, n, m, context, tv, priority, 0);
manager_dispatch_message(m, iovec, n, mm, context, tv, priority, 0);
}
int server_open_syslog_socket(Server *s, const char *syslog_socket) {
int manager_open_syslog_socket(Manager *m, const char *syslog_socket) {
int r;
assert(s);
assert(m);
assert(syslog_socket);
if (s->syslog_fd < 0) {
if (m->syslog_fd < 0) {
union sockaddr_union sa;
socklen_t sa_len;
@@ -469,62 +483,62 @@ int server_open_syslog_socket(Server *s, const char *syslog_socket) {
return log_error_errno(r, "Unable to use namespace path %s for AF_UNIX socket: %m", syslog_socket);
sa_len = r;
s->syslog_fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
if (s->syslog_fd < 0)
m->syslog_fd = socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0);
if (m->syslog_fd < 0)
return log_error_errno(errno, "socket() failed: %m");
(void) sockaddr_un_unlink(&sa.un);
r = bind(s->syslog_fd, &sa.sa, sa_len);
r = bind(m->syslog_fd, &sa.sa, sa_len);
if (r < 0)
return log_error_errno(errno, "bind(%s) failed: %m", sa.un.sun_path);
(void) chmod(sa.un.sun_path, 0666);
} else
(void) fd_nonblock(s->syslog_fd, true);
(void) fd_nonblock(m->syslog_fd, true);
r = setsockopt_int(s->syslog_fd, SOL_SOCKET, SO_PASSCRED, true);
r = setsockopt_int(m->syslog_fd, SOL_SOCKET, SO_PASSCRED, true);
if (r < 0)
return log_error_errno(r, "SO_PASSCRED failed: %m");
if (mac_selinux_use()) {
r = setsockopt_int(s->syslog_fd, SOL_SOCKET, SO_PASSSEC, true);
r = setsockopt_int(m->syslog_fd, SOL_SOCKET, SO_PASSSEC, true);
if (r < 0)
log_warning_errno(r, "SO_PASSSEC failed: %m");
}
r = setsockopt_int(s->syslog_fd, SOL_SOCKET, SO_TIMESTAMP, true);
r = setsockopt_int(m->syslog_fd, SOL_SOCKET, SO_TIMESTAMP, true);
if (r < 0)
return log_error_errno(r, "SO_TIMESTAMP failed: %m");
r = sd_event_add_io(s->event, &s->syslog_event_source, s->syslog_fd, EPOLLIN, server_process_datagram, s);
r = sd_event_add_io(m->event, &m->syslog_event_source, m->syslog_fd, EPOLLIN, manager_process_datagram, m);
if (r < 0)
return log_error_errno(r, "Failed to add syslog server fd to event loop: %m");
return log_error_errno(r, "Failed to add syslog sevrer fd to event loop: %m");
r = sd_event_source_set_priority(s->syslog_event_source, SD_EVENT_PRIORITY_NORMAL+5);
r = sd_event_source_set_priority(m->syslog_event_source, SD_EVENT_PRIORITY_NORMAL+5);
if (r < 0)
return log_error_errno(r, "Failed to adjust syslog event source priority: %m");
return 0;
}
void server_maybe_warn_forward_syslog_missed(Server *s) {
void manager_maybe_warn_forward_syslog_missed(Manager *m) {
usec_t n;
assert(s);
assert(m);
if (s->n_forward_syslog_missed <= 0)
if (m->n_forward_syslog_missed <= 0)
return;
n = now(CLOCK_MONOTONIC);
if (s->last_warn_forward_syslog_missed + WARN_FORWARD_SYSLOG_MISSED_USEC > n)
if (m->last_warn_forward_syslog_missed + WARN_FORWARD_SYSLOG_MISSED_USEC > n)
return;
server_driver_message(s, 0,
LOG_MESSAGE_ID(SD_MESSAGE_FORWARD_SYSLOG_MISSED_STR),
LOG_MESSAGE("Forwarding to syslog missed %u messages.",
s->n_forward_syslog_missed));
manager_driver_message(m, 0,
LOG_MESSAGE_ID(SD_MESSAGE_FORWARD_SYSLOG_MISSED_STR),
LOG_MESSAGE("Forwarding to syslog missed %u messages.",
m->n_forward_syslog_missed));
s->n_forward_syslog_missed = 0;
s->last_warn_forward_syslog_missed = n;
m->n_forward_syslog_missed = 0;
m->last_warn_forward_syslog_missed = n;
}
+5 -5
View File
@@ -5,15 +5,15 @@
#include "macro.h"
typedef struct Server Server;
typedef struct Manager Manager;
int syslog_fixup_facility(int priority) _const_;
size_t syslog_parse_identifier(const char **buf, char **identifier, char **pid);
void server_forward_syslog(Server *s, int priority, const char *identifier, const char *message, const struct ucred *ucred, const struct timeval *tv);
void manager_forward_syslog(Manager *m, int priority, const char *identifier, const char *message, const struct ucred *ucred, const struct timeval *tv);
void server_process_syslog_message(Server *s, const char *buf, size_t buf_len, const struct ucred *ucred, const struct timeval *tv, const char *label, size_t label_len);
int server_open_syslog_socket(Server *s, const char *syslog_socket);
void manager_process_syslog_message(Manager *m, const char *buf, size_t buf_len, const struct ucred *ucred, const struct timeval *tv, const char *label, size_t label_len);
int manager_open_syslog_socket(Manager *m, const char *syslog_socket);
void server_maybe_warn_forward_syslog_missed(Server *s);
void manager_maybe_warn_forward_syslog_missed(Manager *m);
+31 -31
View File
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "journald-server.h"
#include "journald-manager.h"
#include "journald-sync.h"
#include "journald-varlink.h"
#include "varlink-io.systemd.Journal.h"
@@ -17,11 +17,11 @@ void sync_req_varlink_reply(SyncReq *req) {
* anymore. */
if (req->offline)
server_full_sync(req->server, /* wait = */ true);
manager_full_sync(req->manager, /* wait = */ true);
/* Disconnect the SyncReq from the Varlink connection object, and free it */
_cleanup_(sd_varlink_unrefp) sd_varlink *vl = TAKE_PTR(req->link);
sd_varlink_set_userdata(vl, req->server); /* reinstall server object */
sd_varlink_set_userdata(vl, req->manager); /* reinstall manager object */
req = sync_req_free(req);
r = sd_varlink_reply(vl, NULL);
@@ -37,7 +37,7 @@ static int vl_method_synchronize(sd_varlink *link, sd_json_variant *parameters,
{}
};
Server *s = ASSERT_PTR(userdata);
Manager *m = ASSERT_PTR(userdata);
int r;
assert(link);
@@ -66,7 +66,7 @@ static int vl_method_synchronize(sd_varlink *link, sd_json_variant *parameters,
_cleanup_(sync_req_freep) SyncReq *sr = NULL;
r = sync_req_new(s, link, &sr);
r = sync_req_new(m, link, &sr);
if (r < 0)
return r;
@@ -78,7 +78,7 @@ static int vl_method_synchronize(sd_varlink *link, sd_json_variant *parameters,
}
static int vl_method_rotate(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
Server *s = ASSERT_PTR(userdata);
Manager *m = ASSERT_PTR(userdata);
int r;
assert(link);
@@ -92,13 +92,13 @@ static int vl_method_rotate(sd_varlink *link, sd_json_variant *parameters, sd_va
return r;
log_info("Received client request to rotate journal, rotating.");
server_full_rotate(s);
manager_full_rotate(m);
return sd_varlink_reply(link, NULL);
}
static int vl_method_flush_to_var(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
Server *s = ASSERT_PTR(userdata);
Manager *m = ASSERT_PTR(userdata);
int r;
assert(link);
@@ -111,17 +111,17 @@ static int vl_method_flush_to_var(sd_varlink *link, sd_json_variant *parameters,
if (r < 0)
return r;
if (s->namespace)
if (m->namespace)
return sd_varlink_error(link, "io.systemd.Journal.NotSupportedByNamespaces", NULL);
log_info("Received client request to flush runtime journal.");
server_full_flush(s);
manager_full_flush(m);
return sd_varlink_reply(link, NULL);
}
static int vl_method_relinquish_var(sd_varlink *link, sd_json_variant *parameters, sd_varlink_method_flags_t flags, void *userdata) {
Server *s = ASSERT_PTR(userdata);
Manager *m = ASSERT_PTR(userdata);
int r;
assert(link);
@@ -134,65 +134,65 @@ static int vl_method_relinquish_var(sd_varlink *link, sd_json_variant *parameter
if (r < 0)
return r;
if (s->namespace)
if (m->namespace)
return sd_varlink_error(link, "io.systemd.Journal.NotSupportedByNamespaces", NULL);
log_info("Received client request to relinquish %s access.", s->system_storage.path);
server_relinquish_var(s);
log_info("Received client request to relinquish %s access.", m->system_storage.path);
manager_relinquish_var(m);
return sd_varlink_reply(link, NULL);
}
static int vl_connect(sd_varlink_server *server, sd_varlink *link, void *userdata) {
Server *s = ASSERT_PTR(userdata);
Manager *m = ASSERT_PTR(userdata);
assert(server);
assert(link);
(void) server_start_or_stop_idle_timer(s); /* maybe we are no longer idle */
(void) manager_start_or_stop_idle_timer(m); /* maybe we are no longer idle */
return 0;
}
static void vl_disconnect(sd_varlink_server *server, sd_varlink *link, void *userdata) {
Server *s = ASSERT_PTR(userdata);
Manager *m = ASSERT_PTR(userdata);
assert(server);
assert(link);
void *u = sd_varlink_get_userdata(link);
if (u != s) {
if (u != m) {
/* If this is a Varlink connection that does not have the Server object as userdata, then it has a SyncReq object instead. Let's finish it. */
SyncReq *req = u;
sd_varlink_set_userdata(link, s); /* reinstall server object */
sd_varlink_set_userdata(link, m); /* reinstall server object */
sync_req_free(req);
}
(void) server_start_or_stop_idle_timer(s); /* maybe we are idle now */
(void) manager_start_or_stop_idle_timer(m); /* maybe we are idle now */
}
int server_open_varlink(Server *s, const char *socket, int fd) {
int manager_open_varlink(Manager *m, const char *socket, int fd) {
int r;
assert(s);
assert(m);
r = varlink_server_new(
&s->varlink_server,
&m->varlink_server,
SD_VARLINK_SERVER_ACCOUNT_UID|SD_VARLINK_SERVER_INHERIT_USERDATA,
s);
m);
if (r < 0)
return log_error_errno(r, "Failed to allocate varlink server object: %m");
r = sd_varlink_server_add_interface_many(
s->varlink_server,
m->varlink_server,
&vl_interface_io_systemd_Journal,
&vl_interface_io_systemd_service);
if (r < 0)
return log_error_errno(r, "Failed to add Journal interface to varlink server: %m");
r = sd_varlink_server_bind_method_many(
s->varlink_server,
m->varlink_server,
"io.systemd.Journal.Synchronize", vl_method_synchronize,
"io.systemd.Journal.Rotate", vl_method_rotate,
"io.systemd.Journal.FlushToVar", vl_method_flush_to_var,
@@ -203,22 +203,22 @@ int server_open_varlink(Server *s, const char *socket, int fd) {
if (r < 0)
return r;
r = sd_varlink_server_bind_connect(s->varlink_server, vl_connect);
r = sd_varlink_server_bind_connect(m->varlink_server, vl_connect);
if (r < 0)
return r;
r = sd_varlink_server_bind_disconnect(s->varlink_server, vl_disconnect);
r = sd_varlink_server_bind_disconnect(m->varlink_server, vl_disconnect);
if (r < 0)
return r;
if (fd < 0)
r = sd_varlink_server_listen_address(s->varlink_server, socket, 0666);
r = sd_varlink_server_listen_address(m->varlink_server, socket, 0666);
else
r = sd_varlink_server_listen_fd(s->varlink_server, fd);
r = sd_varlink_server_listen_fd(m->varlink_server, fd);
if (r < 0)
return r;
r = sd_varlink_server_attach_event(s->varlink_server, s->event, SD_EVENT_PRIORITY_NORMAL);
r = sd_varlink_server_attach_event(m->varlink_server, m->event, SD_EVENT_PRIORITY_NORMAL);
if (r < 0)
return r;
+2 -2
View File
@@ -1,9 +1,9 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#pragma once
#include "journald-server.h"
#include "journald-manager.h"
#include "journald-sync.h"
int server_open_varlink(Server *s, const char *socket, int fd);
int manager_open_varlink(Manager *m, const char *socket, int fd);
void sync_req_varlink_reply(SyncReq *req);
+5 -5
View File
@@ -2,14 +2,14 @@
#include "alloc-util.h"
#include "format-util.h"
#include "journald-server.h"
#include "journald-manager.h"
#include "journald-wall.h"
#include "process-util.h"
#include "string-util.h"
#include "wall.h"
void server_forward_wall(
Server *s,
void manager_forward_wall(
Manager *m,
int priority,
const char *identifier,
const char *message,
@@ -19,10 +19,10 @@ void server_forward_wall(
const char *l;
int r;
assert(s);
assert(m);
assert(message);
if (LOG_PRI(priority) > s->max_level_wall)
if (LOG_PRI(priority) > m->max_level_wall)
return;
if (ucred) {
+2 -2
View File
@@ -3,6 +3,6 @@
#include <sys/socket.h>
typedef struct Server Server;
typedef struct Manager Manager;
void server_forward_wall(Server *s, int priority, const char *identifier, const char *message, const struct ucred *ucred);
void manager_forward_wall(Manager *m, int priority, const char *identifier, const char *message, const struct ucred *ucred);
+28 -28
View File
@@ -8,7 +8,7 @@
#include "format-util.h"
#include "journal-authenticate.h"
#include "journald-kmsg.h"
#include "journald-server.h"
#include "journald-manager.h"
#include "journald-syslog.h"
#include "main-func.h"
#include "process-util.h"
@@ -16,7 +16,7 @@
#include "terminal-util.h"
static int run(int argc, char *argv[]) {
_cleanup_(server_freep) Server *s = NULL;
_cleanup_(manager_freep) Manager *m = NULL;
const char *namespace;
LogTarget log_target;
int r;
@@ -48,83 +48,83 @@ static int run(int argc, char *argv[]) {
sigbus_install();
r = server_new(&s);
r = manager_new(&m);
if (r < 0)
return log_oom();
r = server_init(s, namespace);
r = manager_init(m, namespace);
if (r < 0)
return r;
server_vacuum(s, /* verbose = */ false);
server_flush_to_var(s, /* require_flag_file = */ true);
server_flush_dev_kmsg(s);
manager_vacuum(m, /* verbose = */ false);
manager_flush_to_var(m, /* require_flag_file = */ true);
manager_flush_dev_kmsg(m);
if (s->namespace)
log_debug("systemd-journald running as PID "PID_FMT" for namespace '%s'.", getpid_cached(), s->namespace);
if (m->namespace)
log_debug("systemd-journald running as PID "PID_FMT" for namespace '%s'.", getpid_cached(), m->namespace);
else
log_debug("systemd-journald running as PID "PID_FMT" for the system.", getpid_cached());
server_driver_message(s, 0,
LOG_MESSAGE_ID(SD_MESSAGE_JOURNAL_START_STR),
LOG_MESSAGE("Journal started"));
manager_driver_message(m, 0,
LOG_MESSAGE_ID(SD_MESSAGE_JOURNAL_START_STR),
LOG_MESSAGE("Journal started"));
/* Make sure to send the usage message *after* flushing the
* journal so entries from the runtime journals are ordered
* before this message. See #4190 for some details. */
server_space_usage_message(s, NULL);
manager_space_usage_message(m, NULL);
for (;;) {
usec_t t, n;
r = sd_event_get_state(s->event);
r = sd_event_get_state(m->event);
if (r < 0)
return log_error_errno(r, "Failed to get event loop state: %m");
if (r == SD_EVENT_FINISHED)
break;
r = sd_event_now(s->event, CLOCK_REALTIME, &n);
r = sd_event_now(m->event, CLOCK_REALTIME, &n);
if (r < 0)
return log_error_errno(r, "Failed to get the current time: %m");
if (s->max_retention_usec > 0 && s->oldest_file_usec > 0) {
if (m->max_retention_usec > 0 && m->oldest_file_usec > 0) {
/* Calculate when to rotate the next time */
t = usec_sub_unsigned(usec_add(s->oldest_file_usec, s->max_retention_usec), n);
t = usec_sub_unsigned(usec_add(m->oldest_file_usec, m->max_retention_usec), n);
/* The retention time is reached, so let's vacuum! */
if (t <= 0) {
log_info("Retention time reached, vacuuming.");
server_vacuum(s, /* verbose = */ false);
manager_vacuum(m, /* verbose = */ false);
continue;
}
} else
t = USEC_INFINITY;
#if HAVE_GCRYPT
if (s->system_journal) {
if (m->system_journal) {
usec_t u;
if (journal_file_next_evolve_usec(s->system_journal, &u))
if (journal_file_next_evolve_usec(m->system_journal, &u))
t = MIN(t, usec_sub_unsigned(u, n));
}
#endif
r = sd_event_run(s->event, t);
r = sd_event_run(m->event, t);
if (r < 0)
return log_error_errno(r, "Failed to run event loop: %m");
server_maybe_append_tags(s);
server_maybe_warn_forward_syslog_missed(s);
manager_maybe_append_tags(m);
manager_maybe_warn_forward_syslog_missed(m);
}
if (s->namespace)
log_debug("systemd-journald stopped as PID "PID_FMT" for namespace '%s'.", getpid_cached(), s->namespace);
if (m->namespace)
log_debug("systemd-journald stopped as PID "PID_FMT" for namespace '%s'.", getpid_cached(), m->namespace);
else
log_debug("systemd-journald stopped as PID "PID_FMT" for the system.", getpid_cached());
server_driver_message(s, 0,
LOG_MESSAGE_ID(SD_MESSAGE_JOURNAL_STOP_STR),
LOG_MESSAGE("Journal stopped"));
manager_driver_message(m, 0,
LOG_MESSAGE_ID(SD_MESSAGE_JOURNAL_STOP_STR),
LOG_MESSAGE("Journal stopped"));
return 0;
}
+1 -1
View File
@@ -9,9 +9,9 @@ systemd_journald_extract_sources = files(
'journald-console.c',
'journald-context.c',
'journald-kmsg.c',
'journald-manager.c',
'journald-native.c',
'journald-rate-limit.c',
'journald-server.c',
'journald-socket.c',
'journald-stream.c',
'journald-sync.c',
+1 -1
View File
@@ -5,7 +5,7 @@
#include <string.h>
#include <sys/un.h>
#include "journald-server.h"
#include "journald-manager.h"
#include "log.h"
#include "path-util.h"
#include "socket-util.h"
+1 -1
View File
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-2.1-or-later */
#include "journald-server.h"
#include "journald-manager.h"
#include "test-tables.h"
#include "tests.h"