[systemd-commits] 16 commits - TODO src/analyze src/bus-proxyd src/core src/journal src/journal-remote src/libsystemd src/libsystemd-network src/libsystemd-terminal src/modules-load src/network src/shared src/systemd src/sysv-generator src/test src/udev
Lennart Poettering
lennart at kemper.freedesktop.org
Thu Nov 27 13:16:42 PST 2014
TODO | 3
src/analyze/analyze-verify.c | 20 -
src/bus-proxyd/bus-policy.c | 173 ++++++--
src/bus-proxyd/bus-policy.h | 10
src/bus-proxyd/bus-proxyd.c | 509 +++++++++++++++++---------
src/bus-proxyd/test-bus-policy.c | 104 ++---
src/core/automount.c | 48 +-
src/core/busname.c | 61 +--
src/core/device.c | 4
src/core/execute.c | 16
src/core/job.c | 24 -
src/core/kmod-setup.c | 22 -
src/core/main.c | 2
src/core/manager.c | 21 -
src/core/mount.c | 59 +--
src/core/path.c | 4
src/core/scope.c | 12
src/core/selinux-access.c | 2
src/core/service.c | 191 ++++-----
src/core/slice.c | 2
src/core/snapshot.c | 12
src/core/socket.c | 156 +++----
src/core/swap.c | 42 +-
src/core/timer.c | 30 -
src/core/transaction.c | 39 +
src/core/unit.c | 42 +-
src/core/unit.h | 18
src/journal-remote/microhttpd-util.c | 7
src/journal/test-journal-interleaving.c | 6
src/libsystemd-network/dhcp-internal.h | 2
src/libsystemd-network/dhcp-server-internal.h | 2
src/libsystemd-network/dhcp6-internal.h | 2
src/libsystemd-network/ipv4ll-internal.h | 2
src/libsystemd-network/sd-icmp6-nd.c | 2
src/libsystemd-terminal/idev-keyboard.c | 2
src/libsystemd/sd-bus/bus-control.c | 7
src/libsystemd/sd-bus/bus-creds.c | 38 +
src/libsystemd/sd-bus/bus-creds.h | 2
src/libsystemd/sd-bus/bus-kernel.c | 109 +++++
src/libsystemd/sd-bus/bus-kernel.h | 2
src/libsystemd/sd-bus/bus-match.c | 3
src/libsystemd/sd-bus/bus-message.c | 13
src/libsystemd/sd-bus/sd-bus.c | 11
src/libsystemd/sd-bus/test-bus-kernel.c | 2
src/modules-load/modules-load.c | 2
src/network/networkd-address.c | 4
src/network/networkd-dhcp4.c | 64 +--
src/network/networkd-ipv4ll.c | 17
src/network/networkd-link.c | 182 ++++-----
src/network/networkd-link.h | 16
src/network/networkd-netdev-bond.c | 12
src/network/networkd-netdev-macvlan.c | 2
src/network/networkd-netdev-tunnel.c | 38 -
src/network/networkd-netdev-tuntap.c | 10
src/network/networkd-netdev-veth.c | 6
src/network/networkd-netdev-vlan.c | 2
src/network/networkd-netdev-vxlan.c | 12
src/network/networkd-netdev.c | 71 +--
src/network/networkd-netdev.h | 6
src/network/networkd.h | 16
src/shared/conf-parser.c | 18
src/shared/conf-parser.h | 14
src/shared/env-util.c | 2
src/shared/log.c | 230 ++++++-----
src/shared/log.h | 69 ++-
src/shared/util.c | 85 ++--
src/shared/util.h | 1
src/systemd/sd-bus.h | 1
src/sysv-generator/sysv-generator.c | 16
src/test/test-hostname.c | 2
src/udev/udev-builtin-kmod.c | 24 -
71 files changed, 1606 insertions(+), 1154 deletions(-)
New commits:
commit 3da44ef53b949021e960d6169e809e297f2b7f65
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Nov 27 21:56:39 2014 +0100
kmod-setup: simplify kernel command line parsing
diff --git a/src/core/kmod-setup.c b/src/core/kmod-setup.c
index 019858f..c0a05b9 100644
--- a/src/core/kmod-setup.c
+++ b/src/core/kmod-setup.c
@@ -49,25 +49,7 @@ static void systemd_kmod_log(
}
static bool cmdline_check_kdbus(void) {
- _cleanup_free_ char *line = NULL;
- const char *p;
- int r;
-
- r = proc_cmdline(&line);
- if (r < 0)
- return false;
-
- p = line;
- for (;;) {
- _cleanup_free_ char *word = NULL;
-
- r = unquote_first_word(&p, &word, true);
- if (r <= 0)
- return false;
-
- if (streq(word, "kdbus"))
- return true;
- }
+ return get_proc_cmdline_key("kdbus", NULL) > 0;
}
#endif
commit 1a29929959fd8f59e19ce60c25d1a1f7d910fac0
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Nov 27 21:28:13 2014 +0100
kdbus: set kernel attach mask before creating the first bus
diff --git a/src/core/manager.c b/src/core/manager.c
index 7af502a..0d1f5bb 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -722,7 +722,12 @@ static int manager_setup_kdbus(Manager *m) {
if (m->test_run || m->kdbus_fd >= 0)
return 0;
- m->kdbus_fd = bus_kernel_create_bus(m->running_as == SYSTEMD_SYSTEM ? "system" : "user", m->running_as == SYSTEMD_SYSTEM, &p);
+ bus_kernel_fix_attach_mask();
+
+ m->kdbus_fd = bus_kernel_create_bus(
+ m->running_as == SYSTEMD_SYSTEM ? "system" : "user",
+ m->running_as == SYSTEMD_SYSTEM, &p);
+
if (m->kdbus_fd < 0) {
log_debug("Failed to set up kdbus: %s", strerror(-m->kdbus_fd));
return m->kdbus_fd;
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 3bf7b07..759d566 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -32,6 +32,8 @@
#include "util.h"
#include "strv.h"
#include "memfd-util.h"
+#include "cgroup-util.h"
+#include "fileio.h"
#include "bus-internal.h"
#include "bus-message.h"
@@ -39,7 +41,6 @@
#include "bus-bloom.h"
#include "bus-util.h"
#include "bus-label.h"
-#include "cgroup-util.h"
#define UNIQUE_NAME_MAX (3+DECIMAL_STR_MAX(uint64_t))
@@ -1796,3 +1797,35 @@ int bus_kernel_realize_attach_flags(sd_bus *bus) {
return 0;
}
+
+int bus_kernel_fix_attach_mask(void) {
+ _cleanup_free_ char *mask = NULL;
+ uint64_t m = (uint32_t) -1;
+ char buf[2+16+2];
+ int r;
+
+ r = get_proc_cmdline_key("systemd.kdbus_attach_flags_mask=", &mask);
+ if (r < 0) {
+ log_warning_errno(-r, "Failed to read kernel command line: %m");
+ return r;
+ }
+
+ if (mask) {
+ const char *p = mask;
+
+ if (startswith(p, "0x"))
+ p += 2;
+
+ if (sscanf(p, "%" PRIx64, &m) != 1)
+ log_warning("Couldn't parse systemd.kdbus_attach_flags_mask= kernel command line parameter.");
+ }
+
+ sprintf(buf, "0x%" PRIx64 "\n", m);
+ r = write_string_file("/sys/module/kdbus/parameters/attach_flags_mask", buf);
+ if (r < 0) {
+ log_warning_errno(-r, "Failed to write kdbus attach mask: %m");
+ return r;
+ }
+
+ return 0;
+}
diff --git a/src/libsystemd/sd-bus/bus-kernel.h b/src/libsystemd/sd-bus/bus-kernel.h
index 8994b35..0db8fd3 100644
--- a/src/libsystemd/sd-bus/bus-kernel.h
+++ b/src/libsystemd/sd-bus/bus-kernel.h
@@ -89,3 +89,5 @@ int bus_kernel_try_close(sd_bus *bus);
int bus_kernel_drop_one(int fd);
int bus_kernel_realize_attach_flags(sd_bus *bus);
+
+int bus_kernel_fix_attach_mask(void);
diff --git a/src/libsystemd/sd-bus/test-bus-kernel.c b/src/libsystemd/sd-bus/test-bus-kernel.c
index 0e6c2ac..485c396 100644
--- a/src/libsystemd/sd-bus/test-bus-kernel.c
+++ b/src/libsystemd/sd-bus/test-bus-kernel.c
@@ -45,6 +45,8 @@ int main(int argc, char *argv[]) {
assert_se(asprintf(&name, "deine-mutter-%u", (unsigned) getpid()) >= 0);
+ bus_kernel_fix_attach_mask();
+
bus_ref = bus_kernel_create_bus(name, false, &bus_name);
if (bus_ref == -ENOENT)
return EXIT_TEST_SKIP;
diff --git a/src/shared/util.c b/src/shared/util.c
index e987abc..d3eec5f 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -6270,38 +6270,16 @@ int split_pair(const char *s, const char *sep, char **l, char **r) {
}
int shall_restore_state(void) {
- _cleanup_free_ char *line = NULL;
- const char *p;
+ _cleanup_free_ char *value = NULL;
int r;
- r = proc_cmdline(&line);
+ r = get_proc_cmdline_key("systemd.restore_state=", &value);
if (r < 0)
return r;
+ if (r == 0)
+ return true;
- r = 1;
- p = line;
-
- for (;;) {
- _cleanup_free_ char *word = NULL;
- const char *e;
- int k;
-
- k = unquote_first_word(&p, &word, true);
- if (k < 0)
- return k;
- if (k == 0)
- break;
-
- e = startswith(word, "systemd.restore_state=");
- if (!e)
- continue;
-
- k = parse_boolean(e);
- if (k >= 0)
- r = k;
- }
-
- return r;
+ return parse_boolean(value) != 0;
}
int proc_cmdline(char **ret) {
@@ -6352,6 +6330,59 @@ int parse_proc_cmdline(int (*parse_item)(const char *key, const char *value)) {
return 0;
}
+int get_proc_cmdline_key(const char *key, char **value) {
+ _cleanup_free_ char *line = NULL, *ret = NULL;
+ bool found = false;
+ const char *p;
+ int r;
+
+ assert(key);
+
+ r = proc_cmdline(&line);
+ if (r < 0)
+ return r;
+
+ p = line;
+ for (;;) {
+ _cleanup_free_ char *word = NULL;
+ const char *e;
+
+ r = unquote_first_word(&p, &word, true);
+ if (r < 0)
+ return r;
+ if (r == 0)
+ break;
+
+ /* Filter out arguments that are intended only for the
+ * initrd */
+ if (!in_initrd() && startswith(word, "rd."))
+ continue;
+
+ if (value) {
+ e = startswith(word, key);
+ if (!e)
+ continue;
+
+ r = free_and_strdup(&ret, e);
+ if (r < 0)
+ return r;
+
+ found = true;
+ } else {
+ if (streq(word, key))
+ found = true;
+ }
+ }
+
+ if (value) {
+ *value = ret;
+ ret = NULL;
+ }
+
+ return found;
+
+}
+
int container_get_leader(const char *machine, pid_t *pid) {
_cleanup_free_ char *s = NULL, *class = NULL;
const char *p;
diff --git a/src/shared/util.h b/src/shared/util.h
index d36a632..13da942 100644
--- a/src/shared/util.h
+++ b/src/shared/util.h
@@ -972,6 +972,7 @@ static inline void qsort_safe(void *base, size_t nmemb, size_t size,
int proc_cmdline(char **ret);
int parse_proc_cmdline(int (*parse_word)(const char *key, const char *value));
+int get_proc_cmdline_key(const char *parameter, char **value);
int container_get_leader(const char *machine, pid_t *pid);
commit 12f1caf40c8bbc8302c8458a364515628e621fa5
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Nov 27 20:28:51 2014 +0100
selinux: log selinux log messages with LOG_AUTH facility
diff --git a/src/core/selinux-access.c b/src/core/selinux-access.c
index a2cc850..0160d4f 100644
--- a/src/core/selinux-access.c
+++ b/src/core/selinux-access.c
@@ -112,7 +112,7 @@ _printf_(2, 3) static int log_callback(int type, const char *fmt, ...) {
#endif
va_start(ap, fmt);
- log_internalv(LOG_USER | LOG_INFO, 0, __FILE__, __LINE__, __FUNCTION__, fmt, ap);
+ log_internalv(LOG_AUTH | LOG_INFO, 0, __FILE__, __LINE__, __FUNCTION__, fmt, ap);
va_end(ap);
return 0;
commit 79008bddf679a5e0900369950eb346c9fa687107
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Nov 27 20:20:23 2014 +0100
log: rearrange log function naming
- Rename log_meta() → log_internal(), to follow naming scheme of most
other log functions that are usually invoked through macros, but never
directly.
- Rename log_info_object() to log_object_info(), simply because the
object should be before any other parameters, to follow OO-style
programming style.
diff --git a/src/analyze/analyze-verify.c b/src/analyze/analyze-verify.c
index 5b16b6c..f084579 100644
--- a/src/analyze/analyze-verify.c
+++ b/src/analyze/analyze-verify.c
@@ -74,7 +74,7 @@ static int verify_socket(Unit *u) {
/* This makes sure instance is created if necessary. */
r = socket_instantiate_service(SOCKET(u));
if (r < 0) {
- log_error_unit(u->id, "Socket %s cannot be started, failed to create instance.",
+ log_unit_error(u->id, "Socket %s cannot be started, failed to create instance.",
u->id);
return r;
}
@@ -84,10 +84,10 @@ static int verify_socket(Unit *u) {
Service *service;
service = SERVICE(UNIT_DEREF(SOCKET(u)->service));
- log_debug_unit(u->id, "%s uses %s", u->id, UNIT(service)->id);
+ log_unit_debug(u->id, "%s uses %s", u->id, UNIT(service)->id);
if (UNIT(service)->load_state != UNIT_LOADED) {
- log_error_unit(u->id, "Service %s not loaded, %s cannot be started.",
+ log_unit_error(u->id, "Service %s not loaded, %s cannot be started.",
UNIT(service)->id, u->id);
return -ENOENT;
}
@@ -101,7 +101,7 @@ static int verify_executable(Unit *u, ExecCommand *exec) {
return 0;
if (access(exec->path, X_OK) < 0) {
- log_error_unit(u->id, "%s: command %s is not executable: %m",
+ log_unit_error(u->id, "%s: command %s is not executable: %m",
u->id, exec->path);
return -errno;
}
@@ -145,15 +145,15 @@ static int verify_documentation(Unit *u, bool check_man) {
int r = 0, k;
STRV_FOREACH(p, u->documentation) {
- log_debug_unit(u->id, "%s: found documentation item %s.", u->id, *p);
+ log_unit_debug(u->id, "%s: found documentation item %s.", u->id, *p);
if (check_man && startswith(*p, "man:")) {
k = show_man_page(*p + 4, true);
if (k != 0) {
if (k < 0)
- log_error_unit(u->id, "%s: can't show %s: %s",
+ log_unit_error(u->id, "%s: can't show %s: %s",
u->id, *p, strerror(-r));
else {
- log_error_unit(u->id, "%s: man %s command failed with code %d",
+ log_unit_error(u->id, "%s: man %s command failed with code %d",
u->id, *p + 4, k);
k = -ENOEXEC;
}
@@ -178,13 +178,13 @@ static int verify_unit(Unit *u, bool check_man) {
if (log_get_max_level() >= LOG_DEBUG)
unit_dump(u, stdout, "\t");
- log_debug_unit(u->id, "Creating %s/start job", u->id);
+ log_unit_debug(u->id, "Creating %s/start job", u->id);
r = manager_add_job(u->manager, JOB_START, u, JOB_REPLACE, false, &err, &j);
if (sd_bus_error_is_set(&err))
- log_error_unit(u->id, "Error: %s: %s",
+ log_unit_error(u->id, "Error: %s: %s",
err.name, err.message);
if (r < 0)
- log_error_unit(u->id, "Failed to create %s/start: %s",
+ log_unit_error(u->id, "Failed to create %s/start: %s",
u->id, strerror(-r));
k = verify_socket(u);
diff --git a/src/core/automount.c b/src/core/automount.c
index f72aca2..f874951 100644
--- a/src/core/automount.c
+++ b/src/core/automount.c
@@ -151,7 +151,7 @@ static int automount_verify(Automount *a) {
return 0;
if (path_equal(a->where, "/")) {
- log_error_unit(UNIT(a)->id, "Cannot have an automount unit for the root directory. Refusing.");
+ log_unit_error(UNIT(a)->id, "Cannot have an automount unit for the root directory. Refusing.");
return -EINVAL;
}
@@ -162,7 +162,7 @@ static int automount_verify(Automount *a) {
b = unit_has_name(UNIT(a), e);
if (!b) {
- log_error_unit(UNIT(a)->id, "%s's Where setting doesn't match unit name. Refusing.", UNIT(a)->id);
+ log_unit_error(UNIT(a)->id, "%s's Where setting doesn't match unit name. Refusing.", UNIT(a)->id);
return -EINVAL;
}
@@ -226,7 +226,7 @@ static void automount_set_state(Automount *a, AutomountState state) {
unmount_autofs(a);
if (state != old_state)
- log_debug_unit(UNIT(a)->id,
+ log_unit_debug(UNIT(a)->id,
"%s changed %s -> %s",
UNIT(a)->id,
automount_state_to_string(old_state),
@@ -422,9 +422,9 @@ int automount_send_ready(Automount *a, int status) {
return ioctl_fd;
if (status)
- log_debug_unit(UNIT(a)->id, "Sending failure: %s", strerror(-status));
+ log_unit_debug(UNIT(a)->id, "Sending failure: %s", strerror(-status));
else
- log_debug_unit(UNIT(a)->id, "Sending success.");
+ log_unit_debug(UNIT(a)->id, "Sending success.");
r = 0;
@@ -536,7 +536,7 @@ fail:
if (mounted)
repeat_unmount(a->where);
- log_error_unit(UNIT(a)->id,
+ log_unit_error(UNIT(a)->id,
"Failed to initialize automounter: %s", strerror(-r));
automount_enter_dead(a, AUTOMOUNT_FAILURE_RESOURCES);
}
@@ -551,7 +551,7 @@ static void automount_enter_runnning(Automount *a) {
/* We don't take mount requests anymore if we are supposed to
* shut down anyway */
if (unit_stop_pending(UNIT(a))) {
- log_debug_unit(UNIT(a)->id,
+ log_unit_debug(UNIT(a)->id,
"Suppressing automount request on %s since unit stop is scheduled.", UNIT(a)->id);
automount_send_ready(a, -EHOSTDOWN);
return;
@@ -561,19 +561,19 @@ static void automount_enter_runnning(Automount *a) {
/* Before we do anything, let's see if somebody is playing games with us? */
if (lstat(a->where, &st) < 0) {
- log_warning_unit(UNIT(a)->id,
+ log_unit_warning(UNIT(a)->id,
"%s failed to stat automount point: %m", UNIT(a)->id);
goto fail;
}
if (!S_ISDIR(st.st_mode) || st.st_dev != a->dev_id)
- log_info_unit(UNIT(a)->id,
+ log_unit_info(UNIT(a)->id,
"%s's automount point already active?", UNIT(a)->id);
else {
r = manager_add_job(UNIT(a)->manager, JOB_START, UNIT_TRIGGER(UNIT(a)),
JOB_REPLACE, true, &error, NULL);
if (r < 0) {
- log_warning_unit(UNIT(a)->id,
+ log_unit_warning(UNIT(a)->id,
"%s failed to queue mount startup job: %s",
UNIT(a)->id, bus_error_message(&error, r));
goto fail;
@@ -594,7 +594,7 @@ static int automount_start(Unit *u) {
assert(a->state == AUTOMOUNT_DEAD || a->state == AUTOMOUNT_FAILED);
if (path_is_mount_point(a->where, false)) {
- log_error_unit(u->id,
+ log_unit_error(u->id,
"Path %s is already a mount point, refusing start for %s",
a->where, u->id);
return -EEXIST;
@@ -659,7 +659,7 @@ static int automount_deserialize_item(Unit *u, const char *key, const char *valu
state = automount_state_from_string(value);
if (state < 0)
- log_debug_unit(u->id, "Failed to parse state value %s", value);
+ log_unit_debug(u->id, "Failed to parse state value %s", value);
else
a->deserialized_state = state;
} else if (streq(key, "result")) {
@@ -667,7 +667,7 @@ static int automount_deserialize_item(Unit *u, const char *key, const char *valu
f = automount_result_from_string(value);
if (f < 0)
- log_debug_unit(u->id, "Failed to parse result value %s", value);
+ log_unit_debug(u->id, "Failed to parse result value %s", value);
else if (f != AUTOMOUNT_SUCCESS)
a->result = f;
@@ -675,14 +675,14 @@ static int automount_deserialize_item(Unit *u, const char *key, const char *valu
unsigned d;
if (safe_atou(value, &d) < 0)
- log_debug_unit(u->id, "Failed to parse dev-id value %s", value);
+ log_unit_debug(u->id, "Failed to parse dev-id value %s", value);
else
a->dev_id = (unsigned) d;
} else if (streq(key, "token")) {
unsigned token;
if (safe_atou(value, &token) < 0)
- log_debug_unit(u->id, "Failed to parse token value %s", value);
+ log_unit_debug(u->id, "Failed to parse token value %s", value);
else {
if (!a->tokens)
if (!(a->tokens = set_new(NULL)))
@@ -696,13 +696,13 @@ static int automount_deserialize_item(Unit *u, const char *key, const char *valu
int fd;
if (safe_atoi(value, &fd) < 0 || fd < 0 || !fdset_contains(fds, fd))
- log_debug_unit(u->id, "Failed to parse pipe-fd value %s", value);
+ log_unit_debug(u->id, "Failed to parse pipe-fd value %s", value);
else {
safe_close(a->pipe_fd);
a->pipe_fd = fdset_remove(fds, fd);
}
} else
- log_debug_unit(u->id, "Unknown serialization key '%s'", key);
+ log_unit_debug(u->id, "Unknown serialization key '%s'", key);
return 0;
}
@@ -738,13 +738,13 @@ static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, vo
assert(fd == a->pipe_fd);
if (events != EPOLLIN) {
- log_error_unit(UNIT(a)->id, "Got invalid poll event on pipe.");
+ log_unit_error(UNIT(a)->id, "Got invalid poll event on pipe.");
goto fail;
}
l = loop_read(a->pipe_fd, &packet, sizeof(packet), true);
if (l != sizeof(packet)) {
- log_error_unit(UNIT(a)->id, "Invalid read from pipe: %s", l < 0 ? strerror(-l) : "short read");
+ log_unit_error(UNIT(a)->id, "Invalid read from pipe: %s", l < 0 ? strerror(-l) : "short read");
goto fail;
}
@@ -756,21 +756,21 @@ static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, vo
_cleanup_free_ char *p = NULL;
get_process_comm(packet.v5_packet.pid, &p);
- log_info_unit(UNIT(a)->id,
+ log_unit_info(UNIT(a)->id,
"Got automount request for %s, triggered by "PID_FMT" (%s)",
a->where, packet.v5_packet.pid, strna(p));
} else
- log_debug_unit(UNIT(a)->id, "Got direct mount request on %s", a->where);
+ log_unit_debug(UNIT(a)->id, "Got direct mount request on %s", a->where);
r = set_ensure_allocated(&a->tokens, NULL);
if (r < 0) {
- log_error_unit(UNIT(a)->id, "Failed to allocate token set.");
+ log_unit_error(UNIT(a)->id, "Failed to allocate token set.");
goto fail;
}
r = set_put(a->tokens, UINT_TO_PTR(packet.v5_packet.wait_queue_token));
if (r < 0) {
- log_error_unit(UNIT(a)->id, "Failed to remember token: %s", strerror(-r));
+ log_unit_error(UNIT(a)->id, "Failed to remember token: %s", strerror(-r));
goto fail;
}
@@ -778,7 +778,7 @@ static int automount_dispatch_io(sd_event_source *s, int fd, uint32_t events, vo
break;
default:
- log_error_unit(UNIT(a)->id, "Received unknown automount request %i", packet.hdr.type);
+ log_unit_error(UNIT(a)->id, "Received unknown automount request %i", packet.hdr.type);
break;
}
diff --git a/src/core/busname.c b/src/core/busname.c
index 8926c6b..2ad6c6e 100644
--- a/src/core/busname.c
+++ b/src/core/busname.c
@@ -200,13 +200,13 @@ static int busname_verify(BusName *n) {
return 0;
if (!service_name_is_valid(n->name)) {
- log_error_unit(UNIT(n)->id, "%s's Name= setting is not a valid service name Refusing.", UNIT(n)->id);
+ log_unit_error(UNIT(n)->id, "%s's Name= setting is not a valid service name Refusing.", UNIT(n)->id);
return -EINVAL;
}
e = strappenda(n->name, ".busname");
if (!unit_has_name(UNIT(n), e)) {
- log_error_unit(UNIT(n)->id, "%s's Name= setting doesn't match unit name. Refusing.", UNIT(n)->id);
+ log_unit_error(UNIT(n)->id, "%s's Name= setting doesn't match unit name. Refusing.", UNIT(n)->id);
return -EINVAL;
}
@@ -268,7 +268,7 @@ static void busname_unwatch_fd(BusName *n) {
r = sd_event_source_set_enabled(n->starter_event_source, SD_EVENT_OFF);
if (r < 0)
- log_debug_unit(UNIT(n)->id, "Failed to disable event source.");
+ log_unit_debug(UNIT(n)->id, "Failed to disable event source.");
}
static int busname_watch_fd(BusName *n) {
@@ -284,7 +284,7 @@ static int busname_watch_fd(BusName *n) {
else
r = sd_event_add_io(UNIT(n)->manager->event, &n->starter_event_source, n->starter_fd, EPOLLIN, busname_dispatch_io, n);
if (r < 0) {
- log_warning_unit(UNIT(n)->id, "Failed to watch starter fd: %s", strerror(-r));
+ log_unit_warning(UNIT(n)->id, "Failed to watch starter fd: %s", strerror(-r));
busname_unwatch_fd(n);
return r;
}
@@ -304,7 +304,7 @@ static int busname_open_fd(BusName *n) {
mode = UNIT(n)->manager->running_as == SYSTEMD_SYSTEM ? "system" : "user";
n->starter_fd = bus_kernel_open_bus_fd(mode, &path);
if (n->starter_fd < 0) {
- log_warning_unit(UNIT(n)->id, "Failed to open %s: %s", path ?: "kdbus", strerror(-n->starter_fd));
+ log_unit_warning(UNIT(n)->id, "Failed to open %s: %s", path ?: "kdbus", strerror(-n->starter_fd));
return n->starter_fd;
}
@@ -330,7 +330,7 @@ static void busname_set_state(BusName *n, BusNameState state) {
busname_close_fd(n);
if (state != old_state)
- log_debug_unit(UNIT(n)->id, "%s changed %s -> %s",
+ log_unit_debug(UNIT(n)->id, "%s changed %s -> %s",
UNIT(n)->id, busname_state_to_string(old_state), busname_state_to_string(state));
unit_notify(UNIT(n), state_translation_table[old_state], state_translation_table[state], true);
@@ -453,14 +453,14 @@ static void busname_enter_signal(BusName *n, BusNameState state, BusNameResult f
n->control_pid,
false);
if (r < 0) {
- log_warning_unit(UNIT(n)->id, "%s failed to kill control process: %s", UNIT(n)->id, strerror(-r));
+ log_unit_warning(UNIT(n)->id, "%s failed to kill control process: %s", UNIT(n)->id, strerror(-r));
goto fail;
}
if (r > 0) {
r = busname_arm_timer(n);
if (r < 0) {
- log_warning_unit(UNIT(n)->id, "%s failed to arm timer: %s", UNIT(n)->id, strerror(-r));
+ log_unit_warning(UNIT(n)->id, "%s failed to arm timer: %s", UNIT(n)->id, strerror(-r));
goto fail;
}
@@ -484,7 +484,7 @@ static void busname_enter_listening(BusName *n) {
if (n->activating) {
r = busname_watch_fd(n);
if (r < 0) {
- log_warning_unit(UNIT(n)->id, "%s failed to watch names: %s", UNIT(n)->id, strerror(-r));
+ log_unit_warning(UNIT(n)->id, "%s failed to watch names: %s", UNIT(n)->id, strerror(-r));
goto fail;
}
@@ -515,7 +515,7 @@ static void busname_enter_making(BusName *n) {
r = busname_make_starter(n, &n->control_pid);
if (r < 0) {
- log_warning_unit(UNIT(n)->id, "%s failed to fork 'making' task: %s", UNIT(n)->id, strerror(-r));
+ log_unit_warning(UNIT(n)->id, "%s failed to fork 'making' task: %s", UNIT(n)->id, strerror(-r));
goto fail;
}
@@ -526,7 +526,7 @@ static void busname_enter_making(BusName *n) {
r = bus_kernel_make_starter(n->starter_fd, n->name, n->activating, n->accept_fd, NULL, n->policy_world);
if (r < 0) {
- log_warning_unit(UNIT(n)->id, "%s failed to make starter: %s", UNIT(n)->id, strerror(-r));
+ log_unit_warning(UNIT(n)->id, "%s failed to make starter: %s", UNIT(n)->id, strerror(-r));
goto fail;
}
@@ -555,7 +555,7 @@ static void busname_enter_running(BusName *n) {
* shut down anyway */
if (unit_stop_pending(UNIT(n))) {
- log_debug_unit(UNIT(n)->id, "Suppressing activation request on %s since unit stop is scheduled.", UNIT(n)->id);
+ log_unit_debug(UNIT(n)->id, "Suppressing activation request on %s since unit stop is scheduled.", UNIT(n)->id);
/* Flush all queued activation reqeuest by closing and reopening the connection */
bus_kernel_drop_one(n->starter_fd);
@@ -582,7 +582,7 @@ static void busname_enter_running(BusName *n) {
return;
fail:
- log_warning_unit(UNIT(n)->id, "%s failed to queue service startup job: %s", UNIT(n)->id, bus_error_message(&error, r));
+ log_unit_warning(UNIT(n)->id, "%s failed to queue service startup job: %s", UNIT(n)->id, bus_error_message(&error, r));
busname_enter_dead(n, BUSNAME_FAILURE_RESOURCES);
}
@@ -606,7 +606,7 @@ static int busname_start(Unit *u) {
service = SERVICE(UNIT_DEREF(n->service));
if (UNIT(service)->load_state != UNIT_LOADED) {
- log_error_unit(u->id, "Bus service %s not loaded, refusing.", UNIT(service)->id);
+ log_unit_error(u->id, "Bus service %s not loaded, refusing.", UNIT(service)->id);
return -ENOENT;
}
}
@@ -680,7 +680,7 @@ static int busname_deserialize_item(Unit *u, const char *key, const char *value,
state = busname_state_from_string(value);
if (state < 0)
- log_debug_unit(u->id, "Failed to parse state value %s", value);
+ log_unit_debug(u->id, "Failed to parse state value %s", value);
else
n->deserialized_state = state;
@@ -689,7 +689,7 @@ static int busname_deserialize_item(Unit *u, const char *key, const char *value,
f = busname_result_from_string(value);
if (f < 0)
- log_debug_unit(u->id, "Failed to parse result value %s", value);
+ log_unit_debug(u->id, "Failed to parse result value %s", value);
else if (f != BUSNAME_SUCCESS)
n->result = f;
@@ -697,20 +697,20 @@ static int busname_deserialize_item(Unit *u, const char *key, const char *value,
pid_t pid;
if (parse_pid(value, &pid) < 0)
- log_debug_unit(u->id, "Failed to parse control-pid value %s", value);
+ log_unit_debug(u->id, "Failed to parse control-pid value %s", value);
else
n->control_pid = pid;
} else if (streq(key, "starter-fd")) {
int fd;
if (safe_atoi(value, &fd) < 0 || fd < 0 || !fdset_contains(fds, fd))
- log_debug_unit(u->id, "Failed to parse starter fd value %s", value);
+ log_unit_debug(u->id, "Failed to parse starter fd value %s", value);
else {
safe_close(n->starter_fd);
n->starter_fd = fdset_remove(fds, fd);
}
} else
- log_debug_unit(u->id, "Unknown serialization key '%s'", key);
+ log_unit_debug(u->id, "Unknown serialization key '%s'", key);
return 0;
}
@@ -757,7 +757,7 @@ static int busname_peek_message(BusName *n) {
if (errno == EINTR || errno == EAGAIN)
return 0;
- log_error_unit(UNIT(n)->id, "%s: Failed to query activation message: %m", UNIT(n)->id);
+ log_unit_error(UNIT(n)->id, "%s: Failed to query activation message: %m", UNIT(n)->id);
return -errno;
}
@@ -774,7 +774,7 @@ static int busname_peek_message(BusName *n) {
p = mmap(NULL, sz, PROT_READ, MAP_SHARED, n->starter_fd, start);
if (p == MAP_FAILED) {
- log_error_unit(UNIT(n)->id, "%s: Failed to map activation message: %m", UNIT(n)->id);
+ log_unit_error(UNIT(n)->id, "%s: Failed to map activation message: %m", UNIT(n)->id);
r = -errno;
goto finish;
}
@@ -794,7 +794,7 @@ static int busname_peek_message(BusName *n) {
}
if (pid > 0)
- log_debug_unit(UNIT(n)->id, "%s: Activation triggered by process " PID_FMT " (%s)", UNIT(n)->id, pid, strna(comm));
+ log_unit_debug(UNIT(n)->id, "%s: Activation triggered by process " PID_FMT " (%s)", UNIT(n)->id, pid, strna(comm));
r = 0;
@@ -804,7 +804,7 @@ finish:
cmd_free.offset = cmd_recv.offset;
if (ioctl(n->starter_fd, KDBUS_CMD_FREE, &cmd_free) < 0)
- log_warning_unit(UNIT(n)->id, "Failed to free peeked message, ignoring: %m");
+ log_unit_warning(UNIT(n)->id, "Failed to free peeked message, ignoring: %m");
return r;
}
@@ -818,10 +818,10 @@ static int busname_dispatch_io(sd_event_source *source, int fd, uint32_t revents
if (n->state != BUSNAME_LISTENING)
return 0;
- log_debug_unit(UNIT(n)->id, "Activation request on %s", UNIT(n)->id);
+ log_unit_debug(UNIT(n)->id, "Activation request on %s", UNIT(n)->id);
if (revents != EPOLLIN) {
- log_error_unit(UNIT(n)->id, "%s: Got unexpected poll event (0x%x) on starter fd.",
+ log_unit_error(UNIT(n)->id, "%s: Got unexpected poll event (0x%x) on starter fd.",
UNIT(n)->id, revents);
goto fail;
}
@@ -858,8 +858,9 @@ static void busname_sigchld_event(Unit *u, pid_t pid, int code, int status) {
else
assert_not_reached("Unknown sigchld code");
- log_full_unit(f == BUSNAME_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
- u->id, "%s control process exited, code=%s status=%i",
+ log_unit_full(u->id,
+ f == BUSNAME_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
+ "%s control process exited, code=%s status=%i",
u->id, sigchld_code_to_string(code), status);
if (f != BUSNAME_SUCCESS)
@@ -896,17 +897,17 @@ static int busname_dispatch_timer(sd_event_source *source, usec_t usec, void *us
switch (n->state) {
case BUSNAME_MAKING:
- log_warning_unit(UNIT(n)->id, "%s making timed out. Terminating.", UNIT(n)->id);
+ log_unit_warning(UNIT(n)->id, "%s making timed out. Terminating.", UNIT(n)->id);
busname_enter_signal(n, BUSNAME_SIGTERM, BUSNAME_FAILURE_TIMEOUT);
break;
case BUSNAME_SIGTERM:
- log_warning_unit(UNIT(n)->id, "%s stopping timed out. Killing.", UNIT(n)->id);
+ log_unit_warning(UNIT(n)->id, "%s stopping timed out. Killing.", UNIT(n)->id);
busname_enter_signal(n, BUSNAME_SIGKILL, BUSNAME_FAILURE_TIMEOUT);
break;
case BUSNAME_SIGKILL:
- log_warning_unit(UNIT(n)->id, "%s still around after SIGKILL. Ignoring.", UNIT(n)->id);
+ log_unit_warning(UNIT(n)->id, "%s still around after SIGKILL. Ignoring.", UNIT(n)->id);
busname_enter_dead(n, BUSNAME_FAILURE_TIMEOUT);
break;
diff --git a/src/core/device.c b/src/core/device.c
index 11c4261..068578d 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -98,7 +98,7 @@ static void device_set_state(Device *d, DeviceState state) {
d->state = state;
if (state != old_state)
- log_debug_unit(UNIT(d)->id,
+ log_unit_debug(UNIT(d)->id,
"%s changed %s -> %s", UNIT(d)->id,
device_state_to_string(old_state),
device_state_to_string(state));
@@ -249,7 +249,7 @@ static int device_add_udev_wants(Unit *u, struct udev_device *dev) {
return r;
}
if (!isempty(state))
- log_warning_unit(u->id, "Property %s on %s has trailing garbage, ignoring.",
+ log_unit_warning(u->id, "Property %s on %s has trailing garbage, ignoring.",
property, strna(udev_device_get_syspath(dev)));
return 0;
diff --git a/src/core/execute.c b/src/core/execute.c
index e6c1999..dd182f5 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -426,7 +426,7 @@ static int setup_output(const ExecContext *context, int fileno, int socket_fd, c
case EXEC_OUTPUT_JOURNAL_AND_CONSOLE:
r = connect_logger_as(context, o, ident, unit_id, fileno);
if (r < 0) {
- log_struct_unit(LOG_CRIT, unit_id,
+ log_unit_struct(LOG_CRIT, unit_id,
"MESSAGE=Failed to connect std%s of %s to the journal socket: %s",
fileno == STDOUT_FILENO ? "out" : "err",
unit_id, strerror(-r),
@@ -1549,7 +1549,7 @@ static int exec_child(ExecCommand *command,
context->mount_flags);
if (err == -EPERM)
- log_warning_unit(params->unit_id, "Failed to set up file system namespace due to lack of privileges. Execution sandbox will not be in effect: %s", strerror(-err));
+ log_unit_warning(params->unit_id, "Failed to set up file system namespace due to lack of privileges. Execution sandbox will not be in effect: %s", strerror(-err));
else if (err < 0) {
*error = EXIT_NAMESPACE;
return err;
@@ -1751,7 +1751,7 @@ static int exec_child(ExecCommand *command,
line = exec_command_line(final_argv);
if (line) {
log_open();
- log_struct_unit(LOG_DEBUG,
+ log_unit_struct(LOG_DEBUG,
params->unit_id,
"EXECUTABLE=%s", command->path,
"MESSAGE=Executing: %s", line,
@@ -1799,7 +1799,7 @@ int exec_spawn(ExecCommand *command,
err = exec_context_load_environment(context, params->unit_id, &files_env);
if (err < 0) {
- log_struct_unit(LOG_ERR,
+ log_unit_struct(LOG_ERR,
params->unit_id,
"MESSAGE=Failed to load environment files: %s", strerror(-err),
"ERRNO=%d", -err,
@@ -1813,7 +1813,7 @@ int exec_spawn(ExecCommand *command,
if (!line)
return log_oom();
- log_struct_unit(LOG_DEBUG,
+ log_unit_struct(LOG_DEBUG,
params->unit_id,
"EXECUTABLE=%s", command->path,
"MESSAGE=About to execute: %s", line,
@@ -1851,7 +1851,7 @@ int exec_spawn(ExecCommand *command,
_exit(r);
}
- log_struct_unit(LOG_DEBUG,
+ log_unit_struct(LOG_DEBUG,
params->unit_id,
"MESSAGE=Forked %s as "PID_FMT,
command->path, pid,
@@ -2771,7 +2771,7 @@ int exec_runtime_deserialize_item(ExecRuntime **rt, Unit *u, const char *key, co
return r;
if (safe_atoi(value, &fd) < 0 || !fdset_contains(fds, fd))
- log_debug_unit(u->id, "Failed to parse netns socket value %s", value);
+ log_unit_debug(u->id, "Failed to parse netns socket value %s", value);
else {
safe_close((*rt)->netns_storage_socket[0]);
(*rt)->netns_storage_socket[0] = fdset_remove(fds, fd);
@@ -2784,7 +2784,7 @@ int exec_runtime_deserialize_item(ExecRuntime **rt, Unit *u, const char *key, co
return r;
if (safe_atoi(value, &fd) < 0 || !fdset_contains(fds, fd))
- log_debug_unit(u->id, "Failed to parse netns socket value %s", value);
+ log_unit_debug(u->id, "Failed to parse netns socket value %s", value);
else {
safe_close((*rt)->netns_storage_socket[1]);
(*rt)->netns_storage_socket[1] = fdset_remove(fds, fd);
diff --git a/src/core/job.c b/src/core/job.c
index 9adc3fd..80fdbde 100644
--- a/src/core/job.c
+++ b/src/core/job.c
@@ -168,7 +168,7 @@ Job* job_install(Job *j) {
if (uj->state == JOB_WAITING ||
(job_type_allows_late_merge(j->type) && job_type_is_superset(uj->type, j->type))) {
job_merge_into_installed(uj, j);
- log_debug_unit(uj->unit->id,
+ log_unit_debug(uj->unit->id,
"Merged into installed job %s/%s as %u",
uj->unit->id, job_type_to_string(uj->type), (unsigned) uj->id);
return uj;
@@ -178,7 +178,7 @@ Job* job_install(Job *j) {
/* XXX It should be safer to queue j to run after uj finishes, but it is
* not currently possible to have more than one installed job per unit. */
job_merge_into_installed(uj, j);
- log_debug_unit(uj->unit->id,
+ log_unit_debug(uj->unit->id,
"Merged into running job, re-running: %s/%s as %u",
uj->unit->id, job_type_to_string(uj->type), (unsigned) uj->id);
uj->state = JOB_WAITING;
@@ -192,7 +192,7 @@ Job* job_install(Job *j) {
*pj = j;
j->installed = true;
j->manager->n_installed_jobs ++;
- log_debug_unit(j->unit->id,
+ log_unit_debug(j->unit->id,
"Installed new job %s/%s as %u",
j->unit->id, job_type_to_string(j->type), (unsigned) j->id);
return j;
@@ -211,14 +211,14 @@ int job_install_deserialized(Job *j) {
pj = (j->type == JOB_NOP) ? &j->unit->nop_job : &j->unit->job;
if (*pj) {
- log_debug_unit(j->unit->id,
+ log_unit_debug(j->unit->id,
"Unit %s already has a job installed. Not installing deserialized job.",
j->unit->id);
return -EEXIST;
}
*pj = j;
j->installed = true;
- log_debug_unit(j->unit->id,
+ log_unit_debug(j->unit->id,
"Reinstalled deserialized job %s/%s as %u",
j->unit->id, job_type_to_string(j->type), (unsigned) j->id);
return 0;
@@ -457,7 +457,7 @@ static bool job_is_runnable(Job *j) {
}
static void job_change_type(Job *j, JobType newtype) {
- log_debug_unit(j->unit->id,
+ log_unit_debug(j->unit->id,
"Converting job %s/%s -> %s/%s",
j->unit->id, job_type_to_string(j->type),
j->unit->id, job_type_to_string(newtype));
@@ -730,7 +730,7 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) {
sd_id128_t mid;
mid = result == JOB_DONE ? SD_MESSAGE_UNIT_STARTED : SD_MESSAGE_UNIT_FAILED;
- log_struct_unit(result == JOB_DONE ? LOG_INFO : LOG_ERR,
+ log_unit_struct(result == JOB_DONE ? LOG_INFO : LOG_ERR,
u->id,
MESSAGE_ID(mid),
"RESULT=%s", job_result_to_string(result),
@@ -738,7 +738,7 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) {
NULL);
} else if (t == JOB_STOP)
- log_struct_unit(result == JOB_DONE ? LOG_INFO : LOG_ERR,
+ log_unit_struct(result == JOB_DONE ? LOG_INFO : LOG_ERR,
u->id,
MESSAGE_ID(SD_MESSAGE_UNIT_STOPPED),
"RESULT=%s", job_result_to_string(result),
@@ -746,7 +746,7 @@ static void job_log_status_message(Unit *u, JobType t, JobResult result) {
NULL);
else if (t == JOB_RELOAD)
- log_struct_unit(result == JOB_DONE ? LOG_INFO : LOG_ERR,
+ log_unit_struct(result == JOB_DONE ? LOG_INFO : LOG_ERR,
u->id,
MESSAGE_ID(SD_MESSAGE_UNIT_RELOADED),
"RESULT=%s", job_result_to_string(result),
@@ -772,7 +772,7 @@ int job_finish_and_invalidate(Job *j, JobResult result, bool recursive) {
if (j->state == JOB_RUNNING)
j->manager->n_running_jobs--;
- log_debug_unit(u->id, "Job %s/%s finished, result=%s",
+ log_unit_debug(u->id, "Job %s/%s finished, result=%s",
u->id, job_type_to_string(t), job_result_to_string(result));
job_print_status_message(u, t, result);
@@ -837,7 +837,7 @@ int job_finish_and_invalidate(Job *j, JobResult result, bool recursive) {
* this context. And JOB_FAILURE is already handled by the
* unit itself. */
if (result == JOB_TIMEOUT || result == JOB_DEPENDENCY) {
- log_struct_unit(LOG_NOTICE,
+ log_unit_struct(LOG_NOTICE,
u->id,
"JOB_TYPE=%s", job_type_to_string(t),
"JOB_RESULT=%s", job_result_to_string(result),
@@ -873,7 +873,7 @@ static int job_dispatch_timer(sd_event_source *s, uint64_t monotonic, void *user
assert(j);
assert(s == j->timer_event_source);
- log_warning_unit(j->unit->id, "Job %s/%s timed out.", j->unit->id, job_type_to_string(j->type));
+ log_unit_warning(j->unit->id, "Job %s/%s timed out.", j->unit->id, job_type_to_string(j->type));
u = j->unit;
job_finish_and_invalidate(j, JOB_TIMEOUT, true);
diff --git a/src/core/kmod-setup.c b/src/core/kmod-setup.c
index 50af793..019858f 100644
--- a/src/core/kmod-setup.c
+++ b/src/core/kmod-setup.c
@@ -44,7 +44,7 @@ static void systemd_kmod_log(
/* library logging is enabled at debug only */
DISABLE_WARNING_FORMAT_NONLITERAL;
- log_metav(LOG_DEBUG, 0, file, line, fn, format, args);
+ log_internalv(LOG_DEBUG, 0, file, line, fn, format, args);
REENABLE_WARNING;
}
diff --git a/src/core/main.c b/src/core/main.c
index 486602e..78054af 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -468,7 +468,7 @@ static int config_parse_cpu_affinity2(
if (c) {
if (sched_setaffinity(0, CPU_ALLOC_SIZE(ncpus), c) < 0)
- log_warning_unit(unit, "Failed to set CPU affinity: %m");
+ log_unit_warning(unit, "Failed to set CPU affinity: %m");
CPU_FREE(c);
}
diff --git a/src/core/manager.c b/src/core/manager.c
index d5d6486..7af502a 100644
--- a/src/core/manager.c
+++ b/src/core/manager.c
@@ -854,7 +854,7 @@ static unsigned manager_dispatch_gc_queue(Manager *m) {
if (u->gc_marker == gc_marker + GC_OFFSET_BAD ||
u->gc_marker == gc_marker + GC_OFFSET_UNSURE) {
- log_debug_unit(u->id, "Collecting %s", u->id);
+ log_unit_debug(u->id, "Collecting %s", u->id);
u->gc_marker = gc_marker + GC_OFFSET_BAD;
unit_add_to_cleanup_queue(u);
}
@@ -1173,7 +1173,7 @@ int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, bool ove
if (mode == JOB_ISOLATE && !unit->allow_isolate)
return sd_bus_error_setf(e, BUS_ERROR_NO_ISOLATION, "Operation refused, unit may not be isolated.");
- log_debug_unit(unit->id,
+ log_unit_debug(unit->id,
"Trying to enqueue job %s/%s/%s", unit->id,
job_type_to_string(type), job_mode_to_string(mode));
@@ -1199,7 +1199,7 @@ int manager_add_job(Manager *m, JobType type, Unit *unit, JobMode mode, bool ove
if (r < 0)
goto tr_abort;
- log_debug_unit(unit->id,
+ log_unit_debug(unit->id,
"Enqueued job %s/%s as %u", unit->id,
job_type_to_string(type), (unsigned) tr->anchor_job->id);
@@ -1469,7 +1469,7 @@ static void manager_invoke_notify_message(Manager *m, Unit *u, pid_t pid, char *
return;
}
- log_debug_unit(u->id, "Got notification message for unit %s", u->id);
+ log_unit_debug(u->id, "Got notification message for unit %s", u->id);
if (UNIT_VTABLE(u)->notify_message)
UNIT_VTABLE(u)->notify_message(u, pid, tags);
@@ -1565,7 +1565,7 @@ static void invoke_sigchld_event(Manager *m, Unit *u, siginfo_t *si) {
assert(u);
assert(si);
- log_debug_unit(u->id, "Child "PID_FMT" belongs to %s", si->si_pid, u->id);
+ log_unit_debug(u->id, "Child "PID_FMT" belongs to %s", si->si_pid, u->id);
unit_unwatch_pid(u, si->si_pid);
UNIT_VTABLE(u)->sigchld_event(u, si->si_pid, si->si_code, si->si_status);
@@ -1637,11 +1637,11 @@ static int manager_start_target(Manager *m, const char *name, JobMode mode) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
int r;
- log_debug_unit(name, "Activating special unit %s", name);
+ log_unit_debug(name, "Activating special unit %s", name);
r = manager_add_job_by_name(m, JOB_START, name, mode, true, &error, NULL);
if (r < 0)
- log_error_unit(name, "Failed to enqueue %s job: %s", name, bus_error_message(&error, r));
+ log_unit_error(name, "Failed to enqueue %s job: %s", name, bus_error_message(&error, r));
return r;
}
diff --git a/src/core/mount.c b/src/core/mount.c
index b571db9..36375f6 100644
--- a/src/core/mount.c
+++ b/src/core/mount.c
@@ -437,22 +437,22 @@ static int mount_verify(Mount *m) {
b = unit_has_name(UNIT(m), e);
if (!b) {
- log_error_unit(UNIT(m)->id, "%s's Where= setting doesn't match unit name. Refusing.", UNIT(m)->id);
+ log_unit_error(UNIT(m)->id, "%s's Where= setting doesn't match unit name. Refusing.", UNIT(m)->id);
return -EINVAL;
}
if (mount_point_is_api(m->where) || mount_point_ignore(m->where)) {
- log_error_unit(UNIT(m)->id, "Cannot create mount unit for API file system %s. Refusing.", m->where);
+ log_unit_error(UNIT(m)->id, "Cannot create mount unit for API file system %s. Refusing.", m->where);
return -EINVAL;
}
if (UNIT(m)->fragment_path && !m->parameters_fragment.what) {
- log_error_unit(UNIT(m)->id, "%s's What setting is missing. Refusing.", UNIT(m)->id);
+ log_unit_error(UNIT(m)->id, "%s's What setting is missing. Refusing.", UNIT(m)->id);
return -EBADMSG;
}
if (m->exec_context.pam_name && m->kill_context.kill_mode != KILL_CONTROL_GROUP) {
- log_error_unit(UNIT(m)->id, "%s has PAM enabled. Kill mode must be set to control-group'. Refusing.",UNIT(m)->id);
+ log_unit_error(UNIT(m)->id, "%s has PAM enabled. Kill mode must be set to control-group'. Refusing.",UNIT(m)->id);
return -EINVAL;
}
@@ -597,7 +597,7 @@ static void mount_set_state(Mount *m, MountState state) {
}
if (state != old_state)
- log_debug_unit(UNIT(m)->id,
+ log_unit_debug(UNIT(m)->id,
"%s changed %s -> %s",
UNIT(m)->id,
mount_state_to_string(old_state),
@@ -804,7 +804,7 @@ static void mount_enter_signal(Mount *m, MountState state, MountResult f) {
return;
fail:
- log_warning_unit(UNIT(m)->id,
+ log_unit_warning(UNIT(m)->id,
"%s failed to kill processes: %s", UNIT(m)->id, strerror(-r));
if (state == MOUNT_REMOUNTING_SIGTERM || state == MOUNT_REMOUNTING_SIGKILL)
@@ -823,7 +823,7 @@ void warn_if_dir_nonempty(const char *unit, const char* where) {
if (r > 0)
return;
else if (r == 0)
- log_struct_unit(LOG_NOTICE,
+ log_unit_struct(LOG_NOTICE,
unit,
"MESSAGE=%s: Directory %s to mount over is not empty, mounting anyway.",
unit, where,
@@ -831,7 +831,7 @@ void warn_if_dir_nonempty(const char *unit, const char* where) {
MESSAGE_ID(SD_MESSAGE_OVERMOUNTING),
NULL);
else
- log_warning_unit(unit,
+ log_unit_warning(unit,
"MESSAGE=Failed to check directory %s: %s",
where, strerror(-r));
}
@@ -840,7 +840,7 @@ static int fail_if_symlink(const char *unit, const char* where) {
assert(where);
if (is_symlink(where) > 0) {
- log_struct_unit(LOG_WARNING,
+ log_unit_struct(LOG_WARNING,
unit,
"MESSAGE=%s: Mount on symlink %s not allowed.",
unit, where,
@@ -879,7 +879,7 @@ static void mount_enter_unmounting(Mount *m) {
return;
fail:
- log_warning_unit(UNIT(m)->id,
+ log_unit_warning(UNIT(m)->id,
"%s failed to run 'umount' task: %s",
UNIT(m)->id, strerror(-r));
mount_enter_mounted(m, MOUNT_FAILURE_RESOURCES);
@@ -934,7 +934,7 @@ static void mount_enter_mounting(Mount *m) {
return;
fail:
- log_warning_unit(UNIT(m)->id,
+ log_unit_warning(UNIT(m)->id,
"%s failed to run 'mount' task: %s",
UNIT(m)->id, strerror(-r));
mount_enter_dead(m, MOUNT_FAILURE_RESOURCES);
@@ -982,7 +982,7 @@ static void mount_enter_remounting(Mount *m) {
return;
fail:
- log_warning_unit(UNIT(m)->id,
+ log_unit_warning(UNIT(m)->id,
"%s failed to run 'remount' task: %s",
UNIT(m)->id, strerror(-r));
m->reload_result = MOUNT_FAILURE_RESOURCES;
@@ -1086,7 +1086,7 @@ static int mount_deserialize_item(Unit *u, const char *key, const char *value, F
MountState state;
if ((state = mount_state_from_string(value)) < 0)
- log_debug_unit(u->id, "Failed to parse state value %s", value);
+ log_unit_debug(u->id, "Failed to parse state value %s", value);
else
m->deserialized_state = state;
} else if (streq(key, "result")) {
@@ -1094,7 +1094,7 @@ static int mount_deserialize_item(Unit *u, const char *key, const char *value, F
f = mount_result_from_string(value);
if (f < 0)
- log_debug_unit(UNIT(m)->id,
+ log_unit_debug(UNIT(m)->id,
"Failed to parse result value %s", value);
else if (f != MOUNT_SUCCESS)
m->result = f;
@@ -1104,7 +1104,7 @@ static int mount_deserialize_item(Unit *u, const char *key, const char *value, F
f = mount_result_from_string(value);
if (f < 0)
- log_debug_unit(UNIT(m)->id,
+ log_unit_debug(UNIT(m)->id,
"Failed to parse reload result value %s", value);
else if (f != MOUNT_SUCCESS)
m->reload_result = f;
@@ -1113,7 +1113,7 @@ static int mount_deserialize_item(Unit *u, const char *key, const char *value, F
pid_t pid;
if (parse_pid(value, &pid) < 0)
- log_debug_unit(UNIT(m)->id,
+ log_unit_debug(UNIT(m)->id,
"Failed to parse control-pid value %s", value);
else
m->control_pid = pid;
@@ -1121,14 +1121,14 @@ static int mount_deserialize_item(Unit *u, const char *key, const char *value, F
MountExecCommand id;
if ((id = mount_exec_command_from_string(value)) < 0)
- log_debug_unit(UNIT(m)->id,
+ log_unit_debug(UNIT(m)->id,
"Failed to parse exec-command value %s", value);
else {
m->control_command_id = id;
m->control_command = m->exec_command + id;
}
} else
- log_debug_unit(UNIT(m)->id,
+ log_unit_debug(UNIT(m)->id,
"Unknown serialization key '%s'", key);
return 0;
@@ -1187,7 +1187,8 @@ static void mount_sigchld_event(Unit *u, pid_t pid, int code, int status) {
m->control_command_id = _MOUNT_EXEC_COMMAND_INVALID;
}
- log_full_unit(f == MOUNT_SUCCESS ? LOG_DEBUG : LOG_NOTICE, u->id,
+ log_unit_full(u->id,
+ f == MOUNT_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
"%s mount process exited, code=%s status=%i",
u->id, sigchld_code_to_string(code), status);
@@ -1255,31 +1256,31 @@ static int mount_dispatch_timer(sd_event_source *source, usec_t usec, void *user
case MOUNT_MOUNTING:
case MOUNT_MOUNTING_DONE:
- log_warning_unit(UNIT(m)->id,
+ log_unit_warning(UNIT(m)->id,
"%s mounting timed out. Stopping.", UNIT(m)->id);
mount_enter_signal(m, MOUNT_MOUNTING_SIGTERM, MOUNT_FAILURE_TIMEOUT);
break;
case MOUNT_REMOUNTING:
- log_warning_unit(UNIT(m)->id,
+ log_unit_warning(UNIT(m)->id,
"%s remounting timed out. Stopping.", UNIT(m)->id);
m->reload_result = MOUNT_FAILURE_TIMEOUT;
mount_enter_mounted(m, MOUNT_SUCCESS);
break;
case MOUNT_UNMOUNTING:
- log_warning_unit(UNIT(m)->id,
+ log_unit_warning(UNIT(m)->id,
"%s unmounting timed out. Stopping.", UNIT(m)->id);
mount_enter_signal(m, MOUNT_UNMOUNTING_SIGTERM, MOUNT_FAILURE_TIMEOUT);
break;
case MOUNT_MOUNTING_SIGTERM:
if (m->kill_context.send_sigkill) {
- log_warning_unit(UNIT(m)->id,
+ log_unit_warning(UNIT(m)->id,
"%s mounting timed out. Killing.", UNIT(m)->id);
mount_enter_signal(m, MOUNT_MOUNTING_SIGKILL, MOUNT_FAILURE_TIMEOUT);
} else {
- log_warning_unit(UNIT(m)->id,
+ log_unit_warning(UNIT(m)->id,
"%s mounting timed out. Skipping SIGKILL. Ignoring.",
UNIT(m)->id);
@@ -1292,11 +1293,11 @@ static int mount_dispatch_timer(sd_event_source *source, usec_t usec, void *user
case MOUNT_REMOUNTING_SIGTERM:
if (m->kill_context.send_sigkill) {
- log_warning_unit(UNIT(m)->id,
+ log_unit_warning(UNIT(m)->id,
"%s remounting timed out. Killing.", UNIT(m)->id);
mount_enter_signal(m, MOUNT_REMOUNTING_SIGKILL, MOUNT_FAILURE_TIMEOUT);
} else {
- log_warning_unit(UNIT(m)->id,
+ log_unit_warning(UNIT(m)->id,
"%s remounting timed out. Skipping SIGKILL. Ignoring.",
UNIT(m)->id);
@@ -1309,11 +1310,11 @@ static int mount_dispatch_timer(sd_event_source *source, usec_t usec, void *user
case MOUNT_UNMOUNTING_SIGTERM:
if (m->kill_context.send_sigkill) {
- log_warning_unit(UNIT(m)->id,
+ log_unit_warning(UNIT(m)->id,
"%s unmounting timed out. Killing.", UNIT(m)->id);
mount_enter_signal(m, MOUNT_UNMOUNTING_SIGKILL, MOUNT_FAILURE_TIMEOUT);
} else {
- log_warning_unit(UNIT(m)->id,
+ log_unit_warning(UNIT(m)->id,
"%s unmounting timed out. Skipping SIGKILL. Ignoring.",
UNIT(m)->id);
@@ -1327,7 +1328,7 @@ static int mount_dispatch_timer(sd_event_source *source, usec_t usec, void *user
case MOUNT_MOUNTING_SIGKILL:
case MOUNT_REMOUNTING_SIGKILL:
case MOUNT_UNMOUNTING_SIGKILL:
- log_warning_unit(UNIT(m)->id,
+ log_unit_warning(UNIT(m)->id,
"%s mount process still around after SIGKILL. Ignoring.",
UNIT(m)->id);
diff --git a/src/core/path.c b/src/core/path.c
index f54c77f..d399238 100644
--- a/src/core/path.c
+++ b/src/core/path.c
@@ -320,7 +320,7 @@ static int path_verify(Path *p) {
return 0;
if (!p->specs) {
- log_error_unit(UNIT(p)->id,
+ log_unit_error(UNIT(p)->id,
"%s lacks path setting. Refusing.", UNIT(p)->id);
return -EINVAL;
}
@@ -724,7 +724,7 @@ static void path_trigger_notify(Unit *u, Unit *other) {
if (p->state == PATH_RUNNING &&
UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(other))) {
- log_debug_unit(UNIT(p)->id,
+ log_unit_debug(UNIT(p)->id,
"%s got notified about unit deactivation.",
UNIT(p)->id);
diff --git a/src/core/scope.c b/src/core/scope.c
index 0f7c1f9..a2b9265 100644
--- a/src/core/scope.c
+++ b/src/core/scope.c
@@ -133,7 +133,7 @@ static int scope_verify(Scope *s) {
return 0;
if (set_isempty(UNIT(s)->pids) && UNIT(s)->manager->n_reloading <= 0) {
- log_error_unit(UNIT(s)->id, "Scope %s has no PIDs. Refusing.", UNIT(s)->id);
+ log_unit_error(UNIT(s)->id, "Scope %s has no PIDs. Refusing.", UNIT(s)->id);
return -EINVAL;
}
@@ -264,7 +264,7 @@ static void scope_enter_signal(Scope *s, ScopeState state, ScopeResult f) {
return;
fail:
- log_warning_unit(UNIT(s)->id,
+ log_unit_warning(UNIT(s)->id,
"%s failed to kill processes: %s", UNIT(s)->id, strerror(-r));
scope_enter_dead(s, SCOPE_FAILURE_RESOURCES);
@@ -405,7 +405,7 @@ static void scope_notify_cgroup_empty_event(Unit *u) {
Scope *s = SCOPE(u);
assert(u);
- log_debug_unit(u->id, "%s: cgroup is empty", u->id);
+ log_unit_debug(u->id, "%s: cgroup is empty", u->id);
if (IN_SET(s->state, SCOPE_RUNNING, SCOPE_ABANDONED, SCOPE_STOP_SIGTERM, SCOPE_STOP_SIGKILL))
scope_enter_dead(s, SCOPE_SUCCESS);
@@ -437,17 +437,17 @@ static int scope_dispatch_timer(sd_event_source *source, usec_t usec, void *user
case SCOPE_STOP_SIGTERM:
if (s->kill_context.send_sigkill) {
- log_warning_unit(UNIT(s)->id, "%s stopping timed out. Killing.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s stopping timed out. Killing.", UNIT(s)->id);
scope_enter_signal(s, SCOPE_STOP_SIGKILL, SCOPE_FAILURE_TIMEOUT);
} else {
- log_warning_unit(UNIT(s)->id, "%s stopping timed out. Skipping SIGKILL.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s stopping timed out. Skipping SIGKILL.", UNIT(s)->id);
scope_enter_dead(s, SCOPE_FAILURE_TIMEOUT);
}
break;
case SCOPE_STOP_SIGKILL:
- log_warning_unit(UNIT(s)->id, "%s still around after SIGKILL. Ignoring.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s still around after SIGKILL. Ignoring.", UNIT(s)->id);
scope_enter_dead(s, SCOPE_FAILURE_TIMEOUT);
break;
diff --git a/src/core/selinux-access.c b/src/core/selinux-access.c
index b3835d5..a2cc850 100644
--- a/src/core/selinux-access.c
+++ b/src/core/selinux-access.c
@@ -112,7 +112,7 @@ _printf_(2, 3) static int log_callback(int type, const char *fmt, ...) {
#endif
va_start(ap, fmt);
- log_metav(LOG_USER | LOG_INFO, 0, __FILE__, __LINE__, __FUNCTION__, fmt, ap);
+ log_internalv(LOG_USER | LOG_INFO, 0, __FILE__, __LINE__, __FUNCTION__, fmt, ap);
va_end(ap);
return 0;
diff --git a/src/core/service.c b/src/core/service.c
index 6a27e8f..72e8f71 100644
--- a/src/core/service.c
+++ b/src/core/service.c
@@ -137,7 +137,7 @@ static void service_unwatch_pid_file(Service *s) {
if (!s->pid_file_pathspec)
return;
- log_debug_unit(UNIT(s)->id, "Stopping watch for %s's PID file %s", UNIT(s)->id, s->pid_file_pathspec->path);
+ log_unit_debug(UNIT(s)->id, "Stopping watch for %s's PID file %s", UNIT(s)->id, s->pid_file_pathspec->path);
path_spec_unwatch(s->pid_file_pathspec);
path_spec_done(s->pid_file_pathspec);
free(s->pid_file_pathspec);
@@ -167,7 +167,7 @@ static int service_set_main_pid(Service *s, pid_t pid) {
s->main_pid_known = true;
if (get_parent_of_pid(pid, &ppid) >= 0 && ppid != getpid()) {
- log_warning_unit(UNIT(s)->id, "%s: Supervising process "PID_FMT" which is not our child. We'll most likely not notice when it exits.", UNIT(s)->id, pid);
+ log_unit_warning(UNIT(s)->id, "%s: Supervising process "PID_FMT" which is not our child. We'll most likely not notice when it exits.", UNIT(s)->id, pid);
s->main_pid_alien = true;
} else
s->main_pid_alien = false;
@@ -209,7 +209,7 @@ static void service_start_watchdog(Service *s) {
if (s->watchdog_event_source) {
r = sd_event_source_set_time(s->watchdog_event_source, s->watchdog_timestamp.monotonic + s->watchdog_usec);
if (r < 0) {
- log_warning_unit(UNIT(s)->id, "%s failed to reset watchdog timer: %s", UNIT(s)->id, strerror(-r));
+ log_unit_warning(UNIT(s)->id, "%s failed to reset watchdog timer: %s", UNIT(s)->id, strerror(-r));
return;
}
@@ -222,7 +222,7 @@ static void service_start_watchdog(Service *s) {
s->watchdog_timestamp.monotonic + s->watchdog_usec, 0,
service_dispatch_watchdog, s);
if (r < 0) {
- log_warning_unit(UNIT(s)->id, "%s failed to add watchdog timer: %s", UNIT(s)->id, strerror(-r));
+ log_unit_warning(UNIT(s)->id, "%s failed to add watchdog timer: %s", UNIT(s)->id, strerror(-r));
return;
}
@@ -232,7 +232,7 @@ static void service_start_watchdog(Service *s) {
}
if (r < 0)
- log_warning_unit(UNIT(s)->id, "%s failed to install watchdog timer: %s", UNIT(s)->id, strerror(-r));
+ log_unit_warning(UNIT(s)->id, "%s failed to install watchdog timer: %s", UNIT(s)->id, strerror(-r));
}
static void service_reset_watchdog(Service *s) {
@@ -316,45 +316,45 @@ static int service_verify(Service *s) {
return 0;
if (!s->exec_command[SERVICE_EXEC_START] && !s->exec_command[SERVICE_EXEC_STOP]) {
- log_error_unit(UNIT(s)->id, "%s lacks both ExecStart= and ExecStop= setting. Refusing.", UNIT(s)->id);
+ log_unit_error(UNIT(s)->id, "%s lacks both ExecStart= and ExecStop= setting. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->type != SERVICE_ONESHOT && !s->exec_command[SERVICE_EXEC_START]) {
- log_error_unit(UNIT(s)->id, "%s has no ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.", UNIT(s)->id);
+ log_unit_error(UNIT(s)->id, "%s has no ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (!s->remain_after_exit && !s->exec_command[SERVICE_EXEC_START]) {
- log_error_unit(UNIT(s)->id, "%s has no ExecStart= setting, which is only allowed for RemainAfterExit=yes services. Refusing.", UNIT(s)->id);
+ log_unit_error(UNIT(s)->id, "%s has no ExecStart= setting, which is only allowed for RemainAfterExit=yes services. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->type != SERVICE_ONESHOT && s->exec_command[SERVICE_EXEC_START]->command_next) {
- log_error_unit(UNIT(s)->id, "%s has more than one ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.", UNIT(s)->id);
+ log_unit_error(UNIT(s)->id, "%s has more than one ExecStart= setting, which is only allowed for Type=oneshot services. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->type == SERVICE_ONESHOT && s->restart != SERVICE_RESTART_NO) {
- log_error_unit(UNIT(s)->id, "%s has Restart= setting other than no, which isn't allowed for Type=oneshot services. Refusing.", UNIT(s)->id);
+ log_unit_error(UNIT(s)->id, "%s has Restart= setting other than no, which isn't allowed for Type=oneshot services. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->type == SERVICE_ONESHOT && !exit_status_set_is_empty(&s->restart_force_status)) {
- log_error_unit(UNIT(s)->id, "%s has RestartForceStatus= set, which isn't allowed for Type=oneshot services. Refusing.", UNIT(s)->id);
+ log_unit_error(UNIT(s)->id, "%s has RestartForceStatus= set, which isn't allowed for Type=oneshot services. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->type == SERVICE_DBUS && !s->bus_name) {
- log_error_unit(UNIT(s)->id, "%s is of type D-Bus but no D-Bus service name has been specified. Refusing.", UNIT(s)->id);
+ log_unit_error(UNIT(s)->id, "%s is of type D-Bus but no D-Bus service name has been specified. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->bus_name && s->type != SERVICE_DBUS)
- log_warning_unit(UNIT(s)->id, "%s has a D-Bus service name specified, but is not of type dbus. Ignoring.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s has a D-Bus service name specified, but is not of type dbus. Ignoring.", UNIT(s)->id);
if (s->exec_context.pam_name && !(s->kill_context.kill_mode == KILL_CONTROL_GROUP || s->kill_context.kill_mode == KILL_MIXED)) {
- log_error_unit(UNIT(s)->id, "%s has PAM enabled. Kill mode must be set to 'control-group' or 'mixed'. Refusing.", UNIT(s)->id);
+ log_unit_error(UNIT(s)->id, "%s has PAM enabled. Kill mode must be set to 'control-group' or 'mixed'. Refusing.", UNIT(s)->id);
return -EINVAL;
}
@@ -571,20 +571,20 @@ static int service_load_pid_file(Service *s, bool may_warn) {
r = read_one_line_file(s->pid_file, &k);
if (r < 0) {
if (may_warn)
- log_info_unit(UNIT(s)->id, "PID file %s not readable (yet?) after %s.", s->pid_file, service_state_to_string(s->state));
+ log_unit_info(UNIT(s)->id, "PID file %s not readable (yet?) after %s.", s->pid_file, service_state_to_string(s->state));
return r;
}
r = parse_pid(k, &pid);
if (r < 0) {
if (may_warn)
- log_info_unit(UNIT(s)->id, "Failed to read PID from file %s: %s", s->pid_file, strerror(-r));
+ log_unit_info(UNIT(s)->id, "Failed to read PID from file %s: %s", s->pid_file, strerror(-r));
return r;
}
if (!pid_is_alive(pid)) {
if (may_warn)
- log_info_unit(UNIT(s)->id, "PID "PID_FMT" read from file %s does not exist or is a zombie.", pid, s->pid_file);
+ log_unit_info(UNIT(s)->id, "PID "PID_FMT" read from file %s does not exist or is a zombie.", pid, s->pid_file);
return -ESRCH;
}
@@ -592,12 +592,12 @@ static int service_load_pid_file(Service *s, bool may_warn) {
if (pid == s->main_pid)
return 0;
- log_debug_unit(UNIT(s)->id, "Main PID changing: "PID_FMT" -> "PID_FMT, s->main_pid, pid);
+ log_unit_debug(UNIT(s)->id, "Main PID changing: "PID_FMT" -> "PID_FMT, s->main_pid, pid);
service_unwatch_main_pid(s);
s->main_pid_known = false;
} else
- log_debug_unit(UNIT(s)->id, "Main PID loaded: "PID_FMT, pid);
+ log_unit_debug(UNIT(s)->id, "Main PID loaded: "PID_FMT, pid);
r = service_set_main_pid(s, pid);
if (r < 0)
@@ -606,7 +606,7 @@ static int service_load_pid_file(Service *s, bool may_warn) {
r = unit_watch_pid(UNIT(s), pid);
if (r < 0) {
/* FIXME: we need to do something here */
- log_warning_unit(UNIT(s)->id, "Failed to watch PID "PID_FMT" from service %s", pid, UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "Failed to watch PID "PID_FMT" from service %s", pid, UNIT(s)->id);
return r;
}
@@ -633,7 +633,7 @@ static int service_search_main_pid(Service *s) {
if (pid <= 0)
return -ENOENT;
- log_debug_unit(UNIT(s)->id, "Main PID guessed: "PID_FMT, pid);
+ log_unit_debug(UNIT(s)->id, "Main PID guessed: "PID_FMT, pid);
r = service_set_main_pid(s, pid);
if (r < 0)
return r;
@@ -641,7 +641,7 @@ static int service_search_main_pid(Service *s) {
r = unit_watch_pid(UNIT(s), pid);
if (r < 0) {
/* FIXME: we need to do something here */
- log_warning_unit(UNIT(s)->id, "Failed to watch PID "PID_FMT" from service %s", pid, UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "Failed to watch PID "PID_FMT" from service %s", pid, UNIT(s)->id);
return r;
}
@@ -733,7 +733,7 @@ static void service_set_state(Service *s, ServiceState state) {
}
if (old_state != state)
- log_debug_unit(UNIT(s)->id, "%s changed %s -> %s", UNIT(s)->id, service_state_to_string(old_state), service_state_to_string(state));
+ log_unit_debug(UNIT(s)->id, "%s changed %s -> %s", UNIT(s)->id, service_state_to_string(old_state), service_state_to_string(state));
unit_notify(UNIT(s), table[old_state], table[state], s->reload_result == SERVICE_SUCCESS);
s->reload_result = SERVICE_SUCCESS;
@@ -1088,7 +1088,7 @@ static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart)
service_set_state(s, s->result != SERVICE_SUCCESS ? SERVICE_FAILED : SERVICE_DEAD);
if (s->result != SERVICE_SUCCESS) {
- log_warning_unit(UNIT(s)->id, "%s failed.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s failed.", UNIT(s)->id);
failure_action(UNIT(s)->manager, s->failure_action, s->reboot_arg);
}
@@ -1130,7 +1130,7 @@ static void service_enter_dead(Service *s, ServiceResult f, bool allow_restart)
return;
fail:
- log_warning_unit(UNIT(s)->id, "%s failed to run install restart timer: %s", UNIT(s)->id, strerror(-r));
+ log_unit_warning(UNIT(s)->id, "%s failed to run install restart timer: %s", UNIT(s)->id, strerror(-r));
service_enter_dead(s, SERVICE_FAILURE_RESOURCES, false);
}
@@ -1167,7 +1167,7 @@ static void service_enter_stop_post(Service *s, ServiceResult f) {
return;
fail:
- log_warning_unit(UNIT(s)->id, "%s failed to run 'stop-post' task: %s", UNIT(s)->id, strerror(-r));
+ log_unit_warning(UNIT(s)->id, "%s failed to run 'stop-post' task: %s", UNIT(s)->id, strerror(-r));
service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_RESOURCES);
}
@@ -1213,7 +1213,7 @@ static void service_enter_signal(Service *s, ServiceState state, ServiceResult f
return;
fail:
- log_warning_unit(UNIT(s)->id, "%s failed to kill processes: %s", UNIT(s)->id, strerror(-r));
+ log_unit_warning(UNIT(s)->id, "%s failed to kill processes: %s", UNIT(s)->id, strerror(-r));
if (state == SERVICE_STOP_SIGTERM || state == SERVICE_STOP_SIGKILL ||
state == SERVICE_STOP_SIGABRT)
@@ -1268,7 +1268,7 @@ static void service_enter_stop(Service *s, ServiceResult f) {
return;
fail:
- log_warning_unit(UNIT(s)->id, "%s failed to run 'stop' task: %s", UNIT(s)->id, strerror(-r));
+ log_unit_warning(UNIT(s)->id, "%s failed to run 'stop' task: %s", UNIT(s)->id, strerror(-r));
service_enter_signal(s, SERVICE_STOP_SIGTERM, SERVICE_FAILURE_RESOURCES);
}
@@ -1330,7 +1330,7 @@ static void service_enter_start_post(Service *s) {
return;
fail:
- log_warning_unit(UNIT(s)->id, "%s failed to run 'start-post' task: %s", UNIT(s)->id, strerror(-r));
+ log_unit_warning(UNIT(s)->id, "%s failed to run 'start-post' task: %s", UNIT(s)->id, strerror(-r));
service_enter_stop(s, SERVICE_FAILURE_RESOURCES);
}
@@ -1423,7 +1423,7 @@ static void service_enter_start(Service *s) {
return;
fail:
- log_warning_unit(UNIT(s)->id, "%s failed to run 'start' task: %s", UNIT(s)->id, strerror(-r));
+ log_unit_warning(UNIT(s)->id, "%s failed to run 'start' task: %s", UNIT(s)->id, strerror(-r));
service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_RESOURCES);
}
@@ -1461,7 +1461,7 @@ static void service_enter_start_pre(Service *s) {
return;
fail:
- log_warning_unit(UNIT(s)->id, "%s failed to run 'start-pre' task: %s", UNIT(s)->id, strerror(-r));
+ log_unit_warning(UNIT(s)->id, "%s failed to run 'start-pre' task: %s", UNIT(s)->id, strerror(-r));
service_enter_dead(s, SERVICE_FAILURE_RESOURCES, true);
}
@@ -1473,7 +1473,7 @@ static void service_enter_restart(Service *s) {
if (UNIT(s)->job && UNIT(s)->job->type == JOB_STOP) {
/* Don't restart things if we are going down anyway */
- log_info_unit(UNIT(s)->id, "Stop job pending for unit, delaying automatic restart.");
+ log_unit_info(UNIT(s)->id, "Stop job pending for unit, delaying automatic restart.");
r = service_arm_timer(s, s->restart_usec);
if (r < 0)
@@ -1494,11 +1494,11 @@ static void service_enter_restart(Service *s) {
* it will be canceled as part of the service_stop() call that
* is executed as part of JOB_RESTART. */
- log_debug_unit(UNIT(s)->id, "%s scheduled restart job.", UNIT(s)->id);
+ log_unit_debug(UNIT(s)->id, "%s scheduled restart job.", UNIT(s)->id);
return;
fail:
- log_warning_unit(UNIT(s)->id, "%s failed to schedule restart job: %s", UNIT(s)->id, bus_error_message(&error, -r));
+ log_unit_warning(UNIT(s)->id, "%s failed to schedule restart job: %s", UNIT(s)->id, bus_error_message(&error, -r));
service_enter_dead(s, SERVICE_FAILURE_RESOURCES, false);
}
@@ -1541,7 +1541,7 @@ static void service_enter_reload(Service *s) {
return;
fail:
- log_warning_unit(UNIT(s)->id, "%s failed to run 'reload' task: %s", UNIT(s)->id, strerror(-r));
+ log_unit_warning(UNIT(s)->id, "%s failed to run 'reload' task: %s", UNIT(s)->id, strerror(-r));
s->reload_result = SERVICE_FAILURE_RESOURCES;
service_enter_running(s, SERVICE_SUCCESS);
}
@@ -1574,7 +1574,7 @@ static void service_run_next_control(Service *s) {
return;
fail:
- log_warning_unit(UNIT(s)->id, "%s failed to run next control task: %s", UNIT(s)->id, strerror(-r));
+ log_unit_warning(UNIT(s)->id, "%s failed to run next control task: %s", UNIT(s)->id, strerror(-r));
if (s->state == SERVICE_START_PRE)
service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_RESOURCES);
@@ -1618,7 +1618,7 @@ static void service_run_next_main(Service *s) {
return;
fail:
- log_warning_unit(UNIT(s)->id, "%s failed to run next main task: %s", UNIT(s)->id, strerror(-r));
+ log_unit_warning(UNIT(s)->id, "%s failed to run next main task: %s", UNIT(s)->id, strerror(-r));
service_enter_stop(s, SERVICE_FAILURE_RESOURCES);
}
@@ -1628,7 +1628,7 @@ static int service_start_limit_test(Service *s) {
if (ratelimit_test(&s->start_limit))
return 0;
- log_warning_unit(UNIT(s)->id, "start request repeated too quickly for %s", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "start request repeated too quickly for %s", UNIT(s)->id);
return failure_action(UNIT(s)->manager, s->start_limit_action, s->reboot_arg);
}
@@ -1836,7 +1836,7 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value,
state = service_state_from_string(value);
if (state < 0)
- log_debug_unit(u->id, "Failed to parse state value %s", value);
+ log_unit_debug(u->id, "Failed to parse state value %s", value);
else
s->deserialized_state = state;
} else if (streq(key, "result")) {
@@ -1844,7 +1844,7 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value,
f = service_result_from_string(value);
if (f < 0)
- log_debug_unit(u->id, "Failed to parse result value %s", value);
+ log_unit_debug(u->id, "Failed to parse result value %s", value);
else if (f != SERVICE_SUCCESS)
s->result = f;
@@ -1853,7 +1853,7 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value,
f = service_result_from_string(value);
if (f < 0)
- log_debug_unit(u->id, "Failed to parse reload result value %s", value);
+ log_unit_debug(u->id, "Failed to parse reload result value %s", value);
else if (f != SERVICE_SUCCESS)
s->reload_result = f;
@@ -1861,14 +1861,14 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value,
pid_t pid;
if (parse_pid(value, &pid) < 0)
- log_debug_unit(u->id, "Failed to parse control-pid value %s", value);
+ log_unit_debug(u->id, "Failed to parse control-pid value %s", value);
else
s->control_pid = pid;
} else if (streq(key, "main-pid")) {
pid_t pid;
if (parse_pid(value, &pid) < 0)
- log_debug_unit(u->id, "Failed to parse main-pid value %s", value);
+ log_unit_debug(u->id, "Failed to parse main-pid value %s", value);
else {
service_set_main_pid(s, pid);
unit_watch_pid(UNIT(s), pid);
@@ -1878,7 +1878,7 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value,
b = parse_boolean(value);
if (b < 0)
- log_debug_unit(u->id, "Failed to parse main-pid-known value %s", value);
+ log_unit_debug(u->id, "Failed to parse main-pid-known value %s", value);
else
s->main_pid_known = b;
} else if (streq(key, "status-text")) {
@@ -1897,7 +1897,7 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value,
id = service_exec_command_from_string(value);
if (id < 0)
- log_debug_unit(u->id, "Failed to parse exec-command value %s", value);
+ log_unit_debug(u->id, "Failed to parse exec-command value %s", value);
else {
s->control_command_id = id;
s->control_command = s->exec_command[id];
@@ -1906,7 +1906,7 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value,
int fd;
if (safe_atoi(value, &fd) < 0 || fd < 0 || !fdset_contains(fds, fd))
- log_debug_unit(u->id, "Failed to parse socket-fd value %s", value);
+ log_unit_debug(u->id, "Failed to parse socket-fd value %s", value);
else {
asynchronous_close(s->socket_fd);
s->socket_fd = fdset_remove(fds, fd);
@@ -1915,7 +1915,7 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value,
int fd;
if (safe_atoi(value, &fd) < 0 || fd < 0 || !fdset_contains(fds, fd))
- log_debug_unit(u->id, "Failed to parse endpoint-fd value %s", value);
+ log_unit_debug(u->id, "Failed to parse endpoint-fd value %s", value);
else {
safe_close(s->bus_endpoint_fd);
s->bus_endpoint_fd = fdset_remove(fds, fd);
@@ -1924,21 +1924,21 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value,
pid_t pid;
if (parse_pid(value, &pid) < 0)
- log_debug_unit(u->id, "Failed to parse main-exec-status-pid value %s", value);
+ log_unit_debug(u->id, "Failed to parse main-exec-status-pid value %s", value);
else
s->main_exec_status.pid = pid;
} else if (streq(key, "main-exec-status-code")) {
int i;
if (safe_atoi(value, &i) < 0)
- log_debug_unit(u->id, "Failed to parse main-exec-status-code value %s", value);
+ log_unit_debug(u->id, "Failed to parse main-exec-status-code value %s", value);
else
s->main_exec_status.code = i;
} else if (streq(key, "main-exec-status-status")) {
int i;
if (safe_atoi(value, &i) < 0)
- log_debug_unit(u->id, "Failed to parse main-exec-status-status value %s", value);
+ log_unit_debug(u->id, "Failed to parse main-exec-status-status value %s", value);
else
s->main_exec_status.status = i;
} else if (streq(key, "main-exec-status-start"))
@@ -1952,11 +1952,11 @@ static int service_deserialize_item(Unit *u, const char *key, const char *value,
b = parse_boolean(value);
if (b < 0)
- log_debug_unit(u->id, "Failed to parse forbid-restart value %s", value);
+ log_unit_debug(u->id, "Failed to parse forbid-restart value %s", value);
else
s->forbid_restart = b;
} else
- log_debug_unit(u->id, "Unknown serialization key '%s'", key);
+ log_unit_debug(u->id, "Unknown serialization key '%s'", key);
return 0;
}
@@ -2019,19 +2019,19 @@ static int service_retry_pid_file(Service *s) {
static int service_watch_pid_file(Service *s) {
int r;
- log_debug_unit(UNIT(s)->id, "Setting watch for %s's PID file %s", UNIT(s)->id, s->pid_file_pathspec->path);
+ log_unit_debug(UNIT(s)->id, "Setting watch for %s's PID file %s", UNIT(s)->id, s->pid_file_pathspec->path);
r = path_spec_watch(s->pid_file_pathspec, service_dispatch_io);
if (r < 0)
goto fail;
/* the pidfile might have appeared just before we set the watch */
- log_debug_unit(UNIT(s)->id, "Trying to read %s's PID file %s in case it changed", UNIT(s)->id, s->pid_file_pathspec->path);
+ log_unit_debug(UNIT(s)->id, "Trying to read %s's PID file %s in case it changed", UNIT(s)->id, s->pid_file_pathspec->path);
service_retry_pid_file(s);
return 0;
fail:
- log_error_unit(UNIT(s)->id, "Failed to set a watch for %s's PID file %s: %s", UNIT(s)->id, s->pid_file_pathspec->path, strerror(-r));
+ log_unit_error(UNIT(s)->id, "Failed to set a watch for %s's PID file %s: %s", UNIT(s)->id, s->pid_file_pathspec->path, strerror(-r));
service_unwatch_pid_file(s);
return r;
}
@@ -2079,7 +2079,7 @@ static int service_dispatch_io(sd_event_source *source, int fd, uint32_t events,
assert(s->pid_file_pathspec);
assert(path_spec_owns_inotify_fd(s->pid_file_pathspec, fd));
- log_debug_unit(UNIT(s)->id, "inotify event for %s", UNIT(s)->id);
+ log_unit_debug(UNIT(s)->id, "inotify event for %s", UNIT(s)->id);
if (path_spec_fd_event(p, events) < 0)
goto fail;
@@ -2103,7 +2103,7 @@ static void service_notify_cgroup_empty_event(Unit *u) {
assert(u);
- log_debug_unit(u->id, "%s: cgroup is empty", u->id);
+ log_unit_debug(u->id, "%s: cgroup is empty", u->id);
switch (s->state) {
@@ -2118,7 +2118,7 @@ static void service_notify_cgroup_empty_event(Unit *u) {
/* If we were hoping for the daemon to write its PID file,
* we can give up now. */
if (s->pid_file_pathspec) {
- log_warning_unit(u->id, "%s never wrote its PID file. Failing.", UNIT(s)->id);
+ log_unit_warning(u->id, "%s never wrote its PID file. Failing.", UNIT(s)->id);
service_unwatch_pid_file(s);
if (s->state == SERVICE_START)
@@ -2205,7 +2205,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
f = SERVICE_SUCCESS;
}
- log_struct_unit(f == SERVICE_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
+ log_unit_struct(f == SERVICE_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
u->id,
"MESSAGE=%s: main process exited, code=%s, status=%i/%s",
u->id, sigchld_code_to_string(code), status,
@@ -2226,7 +2226,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
/* There is another command to *
* execute, so let's do that. */
- log_debug_unit(u->id, "%s running next main command for state %s", u->id, service_state_to_string(s->state));
+ log_unit_debug(u->id, "%s running next main command for state %s", u->id, service_state_to_string(s->state));
service_run_next_main(s);
} else {
@@ -2293,7 +2293,8 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
f = SERVICE_SUCCESS;
}
- log_full_unit(f == SERVICE_SUCCESS ? LOG_DEBUG : LOG_NOTICE, u->id,
+ log_unit_full(u->id,
+ f == SERVICE_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
"%s: control process exited, code=%s status=%i",
u->id, sigchld_code_to_string(code), status);
@@ -2312,7 +2313,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
/* There is another command to *
* execute, so let's do that. */
- log_debug_unit(u->id, "%s running next control command for state %s", u->id, service_state_to_string(s->state));
+ log_unit_debug(u->id, "%s running next control command for state %s", u->id, service_state_to_string(s->state));
service_run_next_control(s);
} else {
@@ -2322,7 +2323,7 @@ static void service_sigchld_event(Unit *u, pid_t pid, int code, int status) {
s->control_command = NULL;
s->control_command_id = _SERVICE_EXEC_COMMAND_INVALID;
- log_debug_unit(u->id, "%s got final SIGCHLD for state %s", u->id, service_state_to_string(s->state));
+ log_unit_debug(u->id, "%s got final SIGCHLD for state %s", u->id, service_state_to_string(s->state));
switch (s->state) {
@@ -2451,38 +2452,38 @@ static int service_dispatch_timer(sd_event_source *source, usec_t usec, void *us
case SERVICE_START_PRE:
case SERVICE_START:
- log_warning_unit(UNIT(s)->id, "%s %s operation timed out. Terminating.", UNIT(s)->id, s->state == SERVICE_START ? "start" : "start-pre");
+ log_unit_warning(UNIT(s)->id, "%s %s operation timed out. Terminating.", UNIT(s)->id, s->state == SERVICE_START ? "start" : "start-pre");
service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_TIMEOUT);
break;
case SERVICE_START_POST:
- log_warning_unit(UNIT(s)->id, "%s start-post operation timed out. Stopping.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s start-post operation timed out. Stopping.", UNIT(s)->id);
service_enter_stop(s, SERVICE_FAILURE_TIMEOUT);
break;
case SERVICE_RELOAD:
- log_warning_unit(UNIT(s)->id, "%s reload operation timed out. Stopping.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s reload operation timed out. Stopping.", UNIT(s)->id);
s->reload_result = SERVICE_FAILURE_TIMEOUT;
service_enter_running(s, SERVICE_SUCCESS);
break;
case SERVICE_STOP:
- log_warning_unit(UNIT(s)->id, "%s stopping timed out. Terminating.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s stopping timed out. Terminating.", UNIT(s)->id);
service_enter_signal(s, SERVICE_STOP_SIGTERM, SERVICE_FAILURE_TIMEOUT);
break;
case SERVICE_STOP_SIGABRT:
- log_warning_unit(UNIT(s)->id,
+ log_unit_warning(UNIT(s)->id,
"%s stop-sigabrt timed out. Terminating.", UNIT(s)->id);
service_enter_signal(s, SERVICE_STOP_SIGTERM, s->result);
break;
case SERVICE_STOP_SIGTERM:
if (s->kill_context.send_sigkill) {
- log_warning_unit(UNIT(s)->id, "%s stop-sigterm timed out. Killing.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s stop-sigterm timed out. Killing.", UNIT(s)->id);
service_enter_signal(s, SERVICE_STOP_SIGKILL, SERVICE_FAILURE_TIMEOUT);
} else {
- log_warning_unit(UNIT(s)->id, "%s stop-sigterm timed out. Skipping SIGKILL.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s stop-sigterm timed out. Skipping SIGKILL.", UNIT(s)->id);
service_enter_stop_post(s, SERVICE_FAILURE_TIMEOUT);
}
@@ -2493,33 +2494,33 @@ static int service_dispatch_timer(sd_event_source *source, usec_t usec, void *us
* Must be something we cannot kill, so let's just be
* weirded out and continue */
- log_warning_unit(UNIT(s)->id, "%s still around after SIGKILL. Ignoring.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s still around after SIGKILL. Ignoring.", UNIT(s)->id);
service_enter_stop_post(s, SERVICE_FAILURE_TIMEOUT);
break;
case SERVICE_STOP_POST:
- log_warning_unit(UNIT(s)->id, "%s stop-post timed out. Terminating.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s stop-post timed out. Terminating.", UNIT(s)->id);
service_enter_signal(s, SERVICE_FINAL_SIGTERM, SERVICE_FAILURE_TIMEOUT);
break;
case SERVICE_FINAL_SIGTERM:
if (s->kill_context.send_sigkill) {
- log_warning_unit(UNIT(s)->id, "%s stop-final-sigterm timed out. Killing.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s stop-final-sigterm timed out. Killing.", UNIT(s)->id);
service_enter_signal(s, SERVICE_FINAL_SIGKILL, SERVICE_FAILURE_TIMEOUT);
} else {
- log_warning_unit(UNIT(s)->id, "%s stop-final-sigterm timed out. Skipping SIGKILL. Entering failed mode.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s stop-final-sigterm timed out. Skipping SIGKILL. Entering failed mode.", UNIT(s)->id);
service_enter_dead(s, SERVICE_FAILURE_TIMEOUT, false);
}
break;
case SERVICE_FINAL_SIGKILL:
- log_warning_unit(UNIT(s)->id, "%s still around after final SIGKILL. Entering failed mode.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s still around after final SIGKILL. Entering failed mode.", UNIT(s)->id);
service_enter_dead(s, SERVICE_FAILURE_TIMEOUT, true);
break;
case SERVICE_AUTO_RESTART:
- log_info_unit(UNIT(s)->id,
+ log_unit_info(UNIT(s)->id,
s->restart_usec > 0 ?
"%s holdoff time over, scheduling restart." :
"%s has no holdoff time, scheduling restart.",
@@ -2541,7 +2542,7 @@ static int service_dispatch_watchdog(sd_event_source *source, usec_t usec, void
assert(s);
assert(source == s->watchdog_event_source);
- log_error_unit(UNIT(s)->id, "%s watchdog timeout (limit %s)!", UNIT(s)->id,
+ log_unit_error(UNIT(s)->id, "%s watchdog timeout (limit %s)!", UNIT(s)->id,
format_timespan(t, sizeof(t), s->watchdog_usec, 1));
service_enter_signal(s, SERVICE_STOP_SIGABRT, SERVICE_FAILURE_WATCHDOG);
@@ -2558,19 +2559,19 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
assert(u);
cc = strv_join(tags, ", ");
- log_debug_unit(u->id, "%s: Got notification message from PID "PID_FMT" (%s)",
+ log_unit_debug(u->id, "%s: Got notification message from PID "PID_FMT" (%s)",
u->id, pid, isempty(cc) ? "n/a" : cc);
if (s->notify_access == NOTIFY_NONE) {
- log_warning_unit(u->id, "%s: Got notification message from PID "PID_FMT", but reception is disabled.", u->id, pid);
+ log_unit_warning(u->id, "%s: Got notification message from PID "PID_FMT", but reception is disabled.", u->id, pid);
return;
}
if (s->notify_access == NOTIFY_MAIN && pid != s->main_pid) {
if (s->main_pid != 0)
- log_warning_unit(u->id, "%s: Got notification message from PID "PID_FMT", but reception only permitted for main PID "PID_FMT, u->id, pid, s->main_pid);
+ log_unit_warning(u->id, "%s: Got notification message from PID "PID_FMT", but reception only permitted for main PID "PID_FMT, u->id, pid, s->main_pid);
else
- log_debug_unit(u->id, "%s: Got notification message from PID "PID_FMT", but reception only permitted for main PID which is currently not known", u->id, pid);
+ log_unit_debug(u->id, "%s: Got notification message from PID "PID_FMT", but reception only permitted for main PID which is currently not known", u->id, pid);
return;
}
@@ -2578,9 +2579,9 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
e = strv_find_startswith(tags, "MAINPID=");
if (e && IN_SET(s->state, SERVICE_START, SERVICE_START_POST, SERVICE_RUNNING, SERVICE_RELOAD)) {
if (parse_pid(e, &pid) < 0)
- log_warning_unit(u->id, "Failed to parse MAINPID= field in notification message: %s", e);
+ log_unit_warning(u->id, "Failed to parse MAINPID= field in notification message: %s", e);
else {
- log_debug_unit(u->id, "%s: got MAINPID=%s", u->id, e);
+ log_unit_debug(u->id, "%s: got MAINPID=%s", u->id, e);
service_set_main_pid(s, pid);
unit_watch_pid(UNIT(s), pid);
@@ -2591,7 +2592,7 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
/* Interpret RELOADING= */
if (strv_find(tags, "RELOADING=1")) {
- log_debug_unit(u->id, "%s: got RELOADING=1", u->id);
+ log_unit_debug(u->id, "%s: got RELOADING=1", u->id);
s->notify_state = NOTIFY_RELOADING;
if (s->state == SERVICE_RUNNING)
@@ -2603,7 +2604,7 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
/* Interpret READY= */
if (strv_find(tags, "READY=1")) {
- log_debug_unit(u->id, "%s: got READY=1", u->id);
+ log_unit_debug(u->id, "%s: got READY=1", u->id);
s->notify_state = NOTIFY_READY;
/* Type=notify services inform us about completed
@@ -2622,7 +2623,7 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
/* Interpret STOPPING= */
if (strv_find(tags, "STOPPING=1")) {
- log_debug_unit(u->id, "%s: got STOPPING=1", u->id);
+ log_unit_debug(u->id, "%s: got STOPPING=1", u->id);
s->notify_state = NOTIFY_STOPPING;
if (s->state == SERVICE_RUNNING)
@@ -2638,9 +2639,9 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
if (!isempty(e)) {
if (!utf8_is_valid(e))
- log_warning_unit(u->id, "Status message in notification is not UTF-8 clean.");
+ log_unit_warning(u->id, "Status message in notification is not UTF-8 clean.");
else {
- log_debug_unit(u->id, "%s: got STATUS=%s", u->id, e);
+ log_unit_debug(u->id, "%s: got STATUS=%s", u->id, e);
t = strdup(e);
if (!t)
@@ -2664,9 +2665,9 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
int status_errno;
if (safe_atoi(e, &status_errno) < 0 || status_errno < 0)
- log_warning_unit(u->id, "Failed to parse ERRNO= field in notification message: %s", e);
+ log_unit_warning(u->id, "Failed to parse ERRNO= field in notification message: %s", e);
else {
- log_debug_unit(u->id, "%s: got ERRNO=%s", u->id, e);
+ log_unit_debug(u->id, "%s: got ERRNO=%s", u->id, e);
if (s->status_errno != status_errno) {
s->status_errno = status_errno;
@@ -2677,7 +2678,7 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags) {
/* Interpret WATCHDOG= */
if (strv_find(tags, "WATCHDOG=1")) {
- log_debug_unit(u->id, "%s: got WATCHDOG=1", u->id);
+ log_unit_debug(u->id, "%s: got WATCHDOG=1", u->id);
service_reset_watchdog(s);
}
@@ -2716,11 +2717,11 @@ static void service_bus_name_owner_change(
assert(old_owner || new_owner);
if (old_owner && new_owner)
- log_debug_unit(u->id, "%s's D-Bus name %s changed owner from %s to %s", u->id, name, old_owner, new_owner);
+ log_unit_debug(u->id, "%s's D-Bus name %s changed owner from %s to %s", u->id, name, old_owner, new_owner);
else if (old_owner)
- log_debug_unit(u->id, "%s's D-Bus name %s no longer registered by %s", u->id, name, old_owner);
+ log_unit_debug(u->id, "%s's D-Bus name %s no longer registered by %s", u->id, name, old_owner);
else
- log_debug_unit(u->id, "%s's D-Bus name %s now registered by %s", u->id, name, new_owner);
+ log_unit_debug(u->id, "%s's D-Bus name %s now registered by %s", u->id, name, new_owner);
s->bus_name_good = !!new_owner;
@@ -2749,7 +2750,7 @@ static void service_bus_name_owner_change(
if (r >= 0)
r = sd_bus_creds_get_pid(creds, &pid);
if (r >= 0) {
- log_debug_unit(u->id, "%s's D-Bus name %s is now owned by process %u", u->id, name, (unsigned) pid);
+ log_unit_debug(u->id, "%s's D-Bus name %s is now owned by process %u", u->id, name, (unsigned) pid);
service_set_main_pid(s, pid);
unit_watch_pid(UNIT(s), pid);
diff --git a/src/core/slice.c b/src/core/slice.c
index 057feef..a31e629 100644
--- a/src/core/slice.c
+++ b/src/core/slice.c
@@ -113,7 +113,7 @@ static int slice_verify(Slice *s) {
a = (char*) SPECIAL_ROOT_SLICE;
if (!unit_has_name(UNIT_DEREF(UNIT(s)->slice), a)) {
- log_error_unit(UNIT(s)->id,
+ log_unit_error(UNIT(s)->id,
"%s located outside its parent slice. Refusing.", UNIT(s)->id);
return -EINVAL;
}
diff --git a/src/core/snapshot.c b/src/core/snapshot.c
index c2678cb..900d0d7 100644
--- a/src/core/snapshot.c
+++ b/src/core/snapshot.c
@@ -51,7 +51,7 @@ static void snapshot_set_state(Snapshot *s, SnapshotState state) {
s->state = state;
if (state != old_state)
- log_debug_unit(UNIT(s)->id,
+ log_unit_debug(UNIT(s)->id,
"%s changed %s -> %s",
UNIT(s)->id,
snapshot_state_to_string(old_state),
@@ -155,7 +155,7 @@ static int snapshot_deserialize_item(Unit *u, const char *key, const char *value
state = snapshot_state_from_string(value);
if (state < 0)
- log_debug_unit(u->id, "Failed to parse state value %s", value);
+ log_unit_debug(u->id, "Failed to parse state value %s", value);
else
s->deserialized_state = state;
@@ -163,7 +163,7 @@ static int snapshot_deserialize_item(Unit *u, const char *key, const char *value
r = parse_boolean(value);
if (r < 0)
- log_debug_unit(u->id, "Failed to parse cleanup value %s", value);
+ log_unit_debug(u->id, "Failed to parse cleanup value %s", value);
else
s->cleanup = r;
@@ -173,7 +173,7 @@ static int snapshot_deserialize_item(Unit *u, const char *key, const char *value
if (r < 0)
return r;
} else
- log_debug_unit(u->id, "Unknown serialization key '%s'", key);
+ log_unit_debug(u->id, "Unknown serialization key '%s'", key);
return 0;
}
@@ -258,7 +258,7 @@ int snapshot_create(Manager *m, const char *name, bool cleanup, sd_bus_error *e,
SNAPSHOT(u)->cleanup = cleanup;
*_s = SNAPSHOT(u);
- log_info_unit(u->id, "Created snapshot %s.", u->id);
+ log_unit_info(u->id, "Created snapshot %s.", u->id);
return 0;
@@ -272,7 +272,7 @@ fail:
void snapshot_remove(Snapshot *s) {
assert(s);
- log_info_unit(UNIT(s)->id, "Removing snapshot %s.", UNIT(s)->id);
+ log_unit_info(UNIT(s)->id, "Removing snapshot %s.", UNIT(s)->id);
unit_add_to_cleanup_queue(UNIT(s));
}
diff --git a/src/core/socket.c b/src/core/socket.c
index 39652ef..96fe2d4 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -391,33 +391,33 @@ static int socket_verify(Socket *s) {
return 0;
if (!s->ports) {
- log_error_unit(UNIT(s)->id, "%s lacks Listen setting. Refusing.", UNIT(s)->id);
+ log_unit_error(UNIT(s)->id, "%s lacks Listen setting. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->accept && have_non_accept_socket(s)) {
- log_error_unit(UNIT(s)->id, "%s configured for accepting sockets, but sockets are non-accepting. Refusing.",
+ log_unit_error(UNIT(s)->id, "%s configured for accepting sockets, but sockets are non-accepting. Refusing.",
UNIT(s)->id);
return -EINVAL;
}
if (s->accept && s->max_connections <= 0) {
- log_error_unit(UNIT(s)->id, "%s's MaxConnection setting too small. Refusing.", UNIT(s)->id);
+ log_unit_error(UNIT(s)->id, "%s's MaxConnection setting too small. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->accept && UNIT_DEREF(s->service)) {
- log_error_unit(UNIT(s)->id, "Explicit service configuration for accepting sockets not supported on %s. Refusing.", UNIT(s)->id);
+ log_unit_error(UNIT(s)->id, "Explicit service configuration for accepting sockets not supported on %s. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (s->exec_context.pam_name && s->kill_context.kill_mode != KILL_CONTROL_GROUP) {
- log_error_unit(UNIT(s)->id, "%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", UNIT(s)->id);
+ log_unit_error(UNIT(s)->id, "%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing.", UNIT(s)->id);
return -EINVAL;
}
if (!strv_isempty(s->symlinks) && !socket_find_symlink_target(s)) {
- log_error_unit(UNIT(s)->id, "%s has symlinks set but none or more than one node in the file system. Refusing.", UNIT(s)->id);
+ log_unit_error(UNIT(s)->id, "%s has symlinks set but none or more than one node in the file system. Refusing.", UNIT(s)->id);
return -EINVAL;
}
@@ -815,60 +815,60 @@ static void socket_apply_socket_options(Socket *s, int fd) {
if (s->keep_alive) {
int b = s->keep_alive;
if (setsockopt(fd, SOL_SOCKET, SO_KEEPALIVE, &b, sizeof(b)) < 0)
- log_warning_unit(UNIT(s)->id, "SO_KEEPALIVE failed: %m");
+ log_unit_warning(UNIT(s)->id, "SO_KEEPALIVE failed: %m");
}
if (s->keep_alive_time) {
int value = s->keep_alive_time / USEC_PER_SEC;
if (setsockopt(fd, SOL_TCP, TCP_KEEPIDLE, &value, sizeof(value)) < 0)
- log_warning_unit(UNIT(s)->id, "TCP_KEEPIDLE failed: %m");
+ log_unit_warning(UNIT(s)->id, "TCP_KEEPIDLE failed: %m");
}
if (s->keep_alive_interval) {
int value = s->keep_alive_interval / USEC_PER_SEC;
if (setsockopt(fd, SOL_TCP, TCP_KEEPINTVL, &value, sizeof(value)) < 0)
- log_warning_unit(UNIT(s)->id, "TCP_KEEPINTVL failed: %m");
+ log_unit_warning(UNIT(s)->id, "TCP_KEEPINTVL failed: %m");
}
if (s->keep_alive_cnt) {
int value = s->keep_alive_cnt;
if (setsockopt(fd, SOL_SOCKET, TCP_KEEPCNT, &value, sizeof(value)) < 0)
- log_warning_unit(UNIT(s)->id, "TCP_KEEPCNT failed: %m");
+ log_unit_warning(UNIT(s)->id, "TCP_KEEPCNT failed: %m");
}
if (s->defer_accept) {
int value = s->defer_accept / USEC_PER_SEC;
if (setsockopt(fd, SOL_TCP, TCP_DEFER_ACCEPT, &value, sizeof(value)) < 0)
- log_warning_unit(UNIT(s)->id, "TCP_DEFER_ACCEPT failed: %m");
+ log_unit_warning(UNIT(s)->id, "TCP_DEFER_ACCEPT failed: %m");
}
if (s->no_delay) {
int b = s->no_delay;
if (setsockopt(fd, SOL_TCP, TCP_NODELAY, &b, sizeof(b)) < 0)
- log_warning_unit(UNIT(s)->id, "TCP_NODELAY failed: %m");
+ log_unit_warning(UNIT(s)->id, "TCP_NODELAY failed: %m");
}
if (s->broadcast) {
int one = 1;
if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &one, sizeof(one)) < 0)
- log_warning_unit(UNIT(s)->id, "SO_BROADCAST failed: %m");
+ log_unit_warning(UNIT(s)->id, "SO_BROADCAST failed: %m");
}
if (s->pass_cred) {
int one = 1;
if (setsockopt(fd, SOL_SOCKET, SO_PASSCRED, &one, sizeof(one)) < 0)
- log_warning_unit(UNIT(s)->id, "SO_PASSCRED failed: %m");
+ log_unit_warning(UNIT(s)->id, "SO_PASSCRED failed: %m");
}
if (s->pass_sec) {
int one = 1;
if (setsockopt(fd, SOL_SOCKET, SO_PASSSEC, &one, sizeof(one)) < 0)
- log_warning_unit(UNIT(s)->id, "SO_PASSSEC failed: %m");
+ log_unit_warning(UNIT(s)->id, "SO_PASSSEC failed: %m");
}
if (s->priority >= 0)
if (setsockopt(fd, SOL_SOCKET, SO_PRIORITY, &s->priority, sizeof(s->priority)) < 0)
- log_warning_unit(UNIT(s)->id, "SO_PRIORITY failed: %m");
+ log_unit_warning(UNIT(s)->id, "SO_PRIORITY failed: %m");
if (s->receive_buffer > 0) {
int value = (int) s->receive_buffer;
@@ -877,23 +877,23 @@ static void socket_apply_socket_options(Socket *s, int fd) {
if (setsockopt(fd, SOL_SOCKET, SO_RCVBUFFORCE, &value, sizeof(value)) < 0)
if (setsockopt(fd, SOL_SOCKET, SO_RCVBUF, &value, sizeof(value)) < 0)
- log_warning_unit(UNIT(s)->id, "SO_RCVBUF failed: %m");
+ log_unit_warning(UNIT(s)->id, "SO_RCVBUF failed: %m");
}
if (s->send_buffer > 0) {
int value = (int) s->send_buffer;
if (setsockopt(fd, SOL_SOCKET, SO_SNDBUFFORCE, &value, sizeof(value)) < 0)
if (setsockopt(fd, SOL_SOCKET, SO_SNDBUF, &value, sizeof(value)) < 0)
- log_warning_unit(UNIT(s)->id, "SO_SNDBUF failed: %m");
+ log_unit_warning(UNIT(s)->id, "SO_SNDBUF failed: %m");
}
if (s->mark >= 0)
if (setsockopt(fd, SOL_SOCKET, SO_MARK, &s->mark, sizeof(s->mark)) < 0)
- log_warning_unit(UNIT(s)->id, "SO_MARK failed: %m");
+ log_unit_warning(UNIT(s)->id, "SO_MARK failed: %m");
if (s->ip_tos >= 0)
if (setsockopt(fd, IPPROTO_IP, IP_TOS, &s->ip_tos, sizeof(s->ip_tos)) < 0)
- log_warning_unit(UNIT(s)->id, "IP_TOS failed: %m");
+ log_unit_warning(UNIT(s)->id, "IP_TOS failed: %m");
if (s->ip_ttl >= 0) {
int x;
@@ -908,30 +908,30 @@ static void socket_apply_socket_options(Socket *s, int fd) {
}
if (r < 0 && x < 0)
- log_warning_unit(UNIT(s)->id,
+ log_unit_warning(UNIT(s)->id,
"IP_TTL/IPV6_UNICAST_HOPS failed: %m");
}
if (s->tcp_congestion)
if (setsockopt(fd, SOL_TCP, TCP_CONGESTION, s->tcp_congestion, strlen(s->tcp_congestion)+1) < 0)
- log_warning_unit(UNIT(s)->id, "TCP_CONGESTION failed: %m");
+ log_unit_warning(UNIT(s)->id, "TCP_CONGESTION failed: %m");
if (s->reuse_port) {
int b = s->reuse_port;
if (setsockopt(fd, SOL_SOCKET, SO_REUSEPORT, &b, sizeof(b)) < 0)
- log_warning_unit(UNIT(s)->id, "SO_REUSEPORT failed: %m");
+ log_unit_warning(UNIT(s)->id, "SO_REUSEPORT failed: %m");
}
if (s->smack_ip_in) {
r = mac_smack_apply_ip_in_fd(fd, s->smack_ip_in);
if (r < 0)
- log_error_unit(UNIT(s)->id, "mac_smack_apply_ip_in_fd: %s", strerror(-r));
+ log_unit_error(UNIT(s)->id, "mac_smack_apply_ip_in_fd: %s", strerror(-r));
}
if (s->smack_ip_out) {
r = mac_smack_apply_ip_out_fd(fd, s->smack_ip_out);
if (r < 0)
- log_error_unit(UNIT(s)->id, "mac_smack_apply_ip_out_fd: %s", strerror(-r));
+ log_unit_error(UNIT(s)->id, "mac_smack_apply_ip_out_fd: %s", strerror(-r));
}
}
@@ -943,12 +943,12 @@ static void socket_apply_fifo_options(Socket *s, int fd) {
if (s->pipe_size > 0)
if (fcntl(fd, F_SETPIPE_SZ, s->pipe_size) < 0)
- log_warning_unit(UNIT(s)->id, "F_SETPIPE_SZ: %m");
+ log_unit_warning(UNIT(s)->id, "F_SETPIPE_SZ: %m");
if (s->smack) {
r = mac_smack_apply_fd(fd, s->smack);
if (r < 0)
- log_error_unit(UNIT(s)->id, "mac_smack_apply_fd: %s", strerror(-r));
+ log_unit_error(UNIT(s)->id, "mac_smack_apply_fd: %s", strerror(-r));
}
}
@@ -1249,7 +1249,7 @@ static void socket_unwatch_fds(Socket *s) {
r = sd_event_source_set_enabled(p->event_source, SD_EVENT_OFF);
if (r < 0)
- log_debug_unit(UNIT(s)->id, "Failed to disable event source.");
+ log_unit_debug(UNIT(s)->id, "Failed to disable event source.");
}
}
@@ -1269,7 +1269,7 @@ static int socket_watch_fds(Socket *s) {
r = sd_event_add_io(UNIT(s)->manager->event, &p->event_source, p->fd, EPOLLIN, socket_dispatch_io, p);
if (r < 0) {
- log_warning_unit(UNIT(s)->id, "Failed to watch listening fds: %s", strerror(-r));
+ log_unit_warning(UNIT(s)->id, "Failed to watch listening fds: %s", strerror(-r));
goto fail;
}
}
@@ -1319,7 +1319,7 @@ static void socket_set_state(Socket *s, SocketState state) {
socket_close_fds(s);
if (state != old_state)
- log_debug_unit(UNIT(s)->id, "%s changed %s -> %s",
+ log_unit_debug(UNIT(s)->id, "%s changed %s -> %s",
UNIT(s)->id, socket_state_to_string(old_state), socket_state_to_string(state));
unit_notify(UNIT(s), state_translation_table[old_state], state_translation_table[state], true);
@@ -1562,7 +1562,7 @@ static void socket_enter_stop_post(Socket *s, SocketResult f) {
return;
fail:
- log_warning_unit(UNIT(s)->id,
+ log_unit_warning(UNIT(s)->id,
"%s failed to run 'stop-post' task: %s",
UNIT(s)->id, strerror(-r));
socket_enter_signal(s, SOCKET_FINAL_SIGTERM, SOCKET_FAILURE_RESOURCES);
@@ -1605,7 +1605,7 @@ static void socket_enter_signal(Socket *s, SocketState state, SocketResult f) {
return;
fail:
- log_warning_unit(UNIT(s)->id, "%s failed to kill processes: %s", UNIT(s)->id, strerror(-r));
+ log_unit_warning(UNIT(s)->id, "%s failed to kill processes: %s", UNIT(s)->id, strerror(-r));
if (state == SOCKET_STOP_PRE_SIGTERM || state == SOCKET_STOP_PRE_SIGKILL)
socket_enter_stop_post(s, SOCKET_FAILURE_RESOURCES);
@@ -1636,7 +1636,7 @@ static void socket_enter_stop_pre(Socket *s, SocketResult f) {
return;
fail:
- log_warning_unit(UNIT(s)->id, "%s failed to run 'stop-pre' task: %s", UNIT(s)->id, strerror(-r));
+ log_unit_warning(UNIT(s)->id, "%s failed to run 'stop-pre' task: %s", UNIT(s)->id, strerror(-r));
socket_enter_stop_post(s, SOCKET_FAILURE_RESOURCES);
}
@@ -1646,7 +1646,7 @@ static void socket_enter_listening(Socket *s) {
r = socket_watch_fds(s);
if (r < 0) {
- log_warning_unit(UNIT(s)->id, "%s failed to watch sockets: %s", UNIT(s)->id, strerror(-r));
+ log_unit_warning(UNIT(s)->id, "%s failed to watch sockets: %s", UNIT(s)->id, strerror(-r));
goto fail;
}
@@ -1668,7 +1668,7 @@ static void socket_enter_start_post(Socket *s) {
if (s->control_command) {
r = socket_spawn(s, s->control_command, &s->control_pid);
if (r < 0) {
- log_warning_unit(UNIT(s)->id, "%s failed to run 'start-post' task: %s", UNIT(s)->id, strerror(-r));
+ log_unit_warning(UNIT(s)->id, "%s failed to run 'start-post' task: %s", UNIT(s)->id, strerror(-r));
goto fail;
}
@@ -1689,7 +1689,7 @@ static void socket_enter_start_chown(Socket *s) {
r = socket_open_fds(s);
if (r < 0) {
- log_warning_unit(UNIT(s)->id, "%s failed to listen on sockets: %s", UNIT(s)->id, strerror(-r));
+ log_unit_warning(UNIT(s)->id, "%s failed to listen on sockets: %s", UNIT(s)->id, strerror(-r));
goto fail;
}
@@ -1701,7 +1701,7 @@ static void socket_enter_start_chown(Socket *s) {
r = socket_chown(s, &s->control_pid);
if (r < 0) {
- log_warning_unit(UNIT(s)->id, "%s failed to fork 'start-chown' task: %s", UNIT(s)->id, strerror(-r));
+ log_unit_warning(UNIT(s)->id, "%s failed to fork 'start-chown' task: %s", UNIT(s)->id, strerror(-r));
goto fail;
}
@@ -1726,7 +1726,7 @@ static void socket_enter_start_pre(Socket *s) {
if (s->control_command) {
r = socket_spawn(s, s->control_command, &s->control_pid);
if (r < 0) {
- log_warning_unit(UNIT(s)->id, "%s failed to run 'start-pre' task: %s", UNIT(s)->id, strerror(-r));
+ log_unit_warning(UNIT(s)->id, "%s failed to run 'start-pre' task: %s", UNIT(s)->id, strerror(-r));
goto fail;
}
@@ -1750,7 +1750,7 @@ static void socket_enter_running(Socket *s, int cfd) {
* shut down anyway */
if (unit_stop_pending(UNIT(s))) {
- log_debug_unit(UNIT(s)->id, "Suppressing connection request on %s since unit stop is scheduled.", UNIT(s)->id);
+ log_unit_debug(UNIT(s)->id, "Suppressing connection request on %s since unit stop is scheduled.", UNIT(s)->id);
if (cfd >= 0)
safe_close(cfd);
@@ -1760,14 +1760,14 @@ static void socket_enter_running(Socket *s, int cfd) {
r = socket_open_fds(s);
if (r < 0) {
- log_warning_unit(UNIT(s)->id, "%s failed to listen on sockets: %s", UNIT(s)->id, strerror(-r));
+ log_unit_warning(UNIT(s)->id, "%s failed to listen on sockets: %s", UNIT(s)->id, strerror(-r));
socket_enter_stop_pre(s, SOCKET_FAILURE_RESOURCES);
return;
}
r = socket_watch_fds(s);
if (r < 0) {
- log_warning_unit(UNIT(s)->id, "%s failed to watch sockets: %s", UNIT(s)->id, strerror(-r));
+ log_unit_warning(UNIT(s)->id, "%s failed to watch sockets: %s", UNIT(s)->id, strerror(-r));
socket_enter_stop_pre(s, SOCKET_FAILURE_RESOURCES);
}
}
@@ -1790,7 +1790,7 @@ static void socket_enter_running(Socket *s, int cfd) {
if (!pending) {
if (!UNIT_ISSET(s->service)) {
- log_error_unit(UNIT(s)->id, "%s: service to activate vanished, refusing activation.", UNIT(s)->id);
+ log_unit_error(UNIT(s)->id, "%s: service to activate vanished, refusing activation.", UNIT(s)->id);
r = -ENOENT;
goto fail;
}
@@ -1806,7 +1806,7 @@ static void socket_enter_running(Socket *s, int cfd) {
Service *service;
if (s->n_connections >= s->max_connections) {
- log_warning_unit(UNIT(s)->id, "%s: Too many incoming connections (%u)", UNIT(s)->id, s->n_connections);
+ log_unit_warning(UNIT(s)->id, "%s: Too many incoming connections (%u)", UNIT(s)->id, s->n_connections);
safe_close(cfd);
return;
}
@@ -1868,7 +1868,7 @@ static void socket_enter_running(Socket *s, int cfd) {
return;
fail:
- log_warning_unit(UNIT(s)->id, "%s failed to queue service startup job (Maybe the service file is missing or not a %s unit?): %s",
+ log_unit_warning(UNIT(s)->id, "%s failed to queue service startup job (Maybe the service file is missing or not a %s unit?): %s",
UNIT(s)->id, cfd >= 0 ? "template" : "non-template",
bus_error_message(&error, r));
@@ -1894,7 +1894,7 @@ static void socket_run_next(Socket *s) {
return;
fail:
- log_warning_unit(UNIT(s)->id, "%s failed to run next task: %s", UNIT(s)->id, strerror(-r));
+ log_unit_warning(UNIT(s)->id, "%s failed to run next task: %s", UNIT(s)->id, strerror(-r));
if (s->state == SOCKET_START_POST)
socket_enter_stop_pre(s, SOCKET_FAILURE_RESOURCES);
@@ -1934,7 +1934,7 @@ static int socket_start(Unit *u) {
service = SERVICE(UNIT_DEREF(s->service));
if (UNIT(service)->load_state != UNIT_LOADED) {
- log_error_unit(u->id, "Socket service %s not loaded, refusing.", UNIT(service)->id);
+ log_unit_error(u->id, "Socket service %s not loaded, refusing.", UNIT(service)->id);
return -ENOENT;
}
@@ -1943,7 +1943,7 @@ static int socket_start(Unit *u) {
if (service->state != SERVICE_DEAD &&
service->state != SERVICE_FAILED &&
service->state != SERVICE_AUTO_RESTART) {
- log_error_unit(u->id, "Socket service %s already active, refusing.", UNIT(service)->id);
+ log_unit_error(u->id, "Socket service %s already active, refusing.", UNIT(service)->id);
return -EBUSY;
}
}
@@ -2053,7 +2053,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
state = socket_state_from_string(value);
if (state < 0)
- log_debug_unit(u->id, "Failed to parse state value %s", value);
+ log_unit_debug(u->id, "Failed to parse state value %s", value);
else
s->deserialized_state = state;
} else if (streq(key, "result")) {
@@ -2061,7 +2061,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
f = socket_result_from_string(value);
if (f < 0)
- log_debug_unit(u->id, "Failed to parse result value %s", value);
+ log_unit_debug(u->id, "Failed to parse result value %s", value);
else if (f != SOCKET_SUCCESS)
s->result = f;
@@ -2069,14 +2069,14 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
unsigned k;
if (safe_atou(value, &k) < 0)
- log_debug_unit(u->id, "Failed to parse n-accepted value %s", value);
+ log_unit_debug(u->id, "Failed to parse n-accepted value %s", value);
else
s->n_accepted += k;
} else if (streq(key, "control-pid")) {
pid_t pid;
if (parse_pid(value, &pid) < 0)
- log_debug_unit(u->id, "Failed to parse control-pid value %s", value);
+ log_unit_debug(u->id, "Failed to parse control-pid value %s", value);
else
s->control_pid = pid;
} else if (streq(key, "control-command")) {
@@ -2084,7 +2084,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
id = socket_exec_command_from_string(value);
if (id < 0)
- log_debug_unit(u->id, "Failed to parse exec-command value %s", value);
+ log_unit_debug(u->id, "Failed to parse exec-command value %s", value);
else {
s->control_command_id = id;
s->control_command = s->exec_command[id];
@@ -2094,7 +2094,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
SocketPort *p;
if (sscanf(value, "%i %n", &fd, &skip) < 1 || fd < 0 || !fdset_contains(fds, fd))
- log_debug_unit(u->id, "Failed to parse fifo value %s", value);
+ log_unit_debug(u->id, "Failed to parse fifo value %s", value);
else {
LIST_FOREACH(port, p, s->ports)
@@ -2113,7 +2113,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
SocketPort *p;
if (sscanf(value, "%i %n", &fd, &skip) < 1 || fd < 0 || !fdset_contains(fds, fd))
- log_debug_unit(u->id, "Failed to parse special value %s", value);
+ log_unit_debug(u->id, "Failed to parse special value %s", value);
else {
LIST_FOREACH(port, p, s->ports)
@@ -2132,7 +2132,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
SocketPort *p;
if (sscanf(value, "%i %n", &fd, &skip) < 1 || fd < 0 || !fdset_contains(fds, fd))
- log_debug_unit(u->id, "Failed to parse mqueue value %s", value);
+ log_unit_debug(u->id, "Failed to parse mqueue value %s", value);
else {
LIST_FOREACH(port, p, s->ports)
@@ -2151,7 +2151,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
SocketPort *p;
if (sscanf(value, "%i %i %n", &fd, &type, &skip) < 2 || fd < 0 || type < 0 || !fdset_contains(fds, fd))
- log_debug_unit(u->id, "Failed to parse socket value %s", value);
+ log_unit_debug(u->id, "Failed to parse socket value %s", value);
else {
LIST_FOREACH(port, p, s->ports)
@@ -2169,7 +2169,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
SocketPort *p;
if (sscanf(value, "%i %n", &fd, &skip) < 1 || fd < 0 || !fdset_contains(fds, fd))
- log_debug_unit(u->id, "Failed to parse socket value %s", value);
+ log_unit_debug(u->id, "Failed to parse socket value %s", value);
else {
LIST_FOREACH(port, p, s->ports)
@@ -2182,7 +2182,7 @@ static int socket_deserialize_item(Unit *u, const char *key, const char *value,
}
}
} else
- log_debug_unit(UNIT(s)->id, "Unknown serialization key '%s'", key);
+ log_unit_debug(UNIT(s)->id, "Unknown serialization key '%s'", key);
return 0;
}
@@ -2286,15 +2286,15 @@ static int socket_dispatch_io(sd_event_source *source, int fd, uint32_t revents,
if (p->socket->state != SOCKET_LISTENING)
return 0;
- log_debug_unit(UNIT(p->socket)->id, "Incoming traffic on %s", UNIT(p->socket)->id);
+ log_unit_debug(UNIT(p->socket)->id, "Incoming traffic on %s", UNIT(p->socket)->id);
if (revents != EPOLLIN) {
if (revents & EPOLLHUP)
- log_error_unit(UNIT(p->socket)->id, "%s: Got POLLHUP on a listening socket. The service probably invoked shutdown() on it, and should better not do that.",
+ log_unit_error(UNIT(p->socket)->id, "%s: Got POLLHUP on a listening socket. The service probably invoked shutdown() on it, and should better not do that.",
UNIT(p->socket)->id);
else
- log_error_unit(UNIT(p->socket)->id, "%s: Got unexpected poll event (0x%x) on socket.",
+ log_unit_error(UNIT(p->socket)->id, "%s: Got unexpected poll event (0x%x) on socket.",
UNIT(p->socket)->id, revents);
goto fail;
@@ -2312,7 +2312,7 @@ static int socket_dispatch_io(sd_event_source *source, int fd, uint32_t revents,
if (errno == EINTR)
continue;
- log_error_unit(UNIT(p->socket)->id,
+ log_unit_error(UNIT(p->socket)->id,
"Failed to accept socket: %m");
goto fail;
}
@@ -2361,8 +2361,8 @@ static void socket_sigchld_event(Unit *u, pid_t pid, int code, int status) {
f = SOCKET_SUCCESS;
}
- log_full_unit(f == SOCKET_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
- u->id,
+ log_unit_full(u->id,
+ f == SOCKET_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
"%s control process exited, code=%s status=%i",
u->id, sigchld_code_to_string(code), status);
@@ -2373,7 +2373,7 @@ static void socket_sigchld_event(Unit *u, pid_t pid, int code, int status) {
s->control_command->command_next &&
f == SOCKET_SUCCESS) {
- log_debug_unit(u->id,
+ log_unit_debug(u->id,
"%s running next command for state %s",
u->id, socket_state_to_string(s->state));
socket_run_next(s);
@@ -2384,7 +2384,7 @@ static void socket_sigchld_event(Unit *u, pid_t pid, int code, int status) {
/* No further commands for this step, so let's figure
* out what to do next */
- log_debug_unit(u->id,
+ log_unit_debug(u->id,
"%s got final SIGCHLD for state %s",
u->id, socket_state_to_string(s->state));
@@ -2441,53 +2441,53 @@ static int socket_dispatch_timer(sd_event_source *source, usec_t usec, void *use
switch (s->state) {
case SOCKET_START_PRE:
- log_warning_unit(UNIT(s)->id, "%s starting timed out. Terminating.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s starting timed out. Terminating.", UNIT(s)->id);
socket_enter_signal(s, SOCKET_FINAL_SIGTERM, SOCKET_FAILURE_TIMEOUT);
break;
case SOCKET_START_CHOWN:
case SOCKET_START_POST:
- log_warning_unit(UNIT(s)->id, "%s starting timed out. Stopping.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s starting timed out. Stopping.", UNIT(s)->id);
socket_enter_stop_pre(s, SOCKET_FAILURE_TIMEOUT);
break;
case SOCKET_STOP_PRE:
- log_warning_unit(UNIT(s)->id, "%s stopping timed out. Terminating.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s stopping timed out. Terminating.", UNIT(s)->id);
socket_enter_signal(s, SOCKET_STOP_PRE_SIGTERM, SOCKET_FAILURE_TIMEOUT);
break;
case SOCKET_STOP_PRE_SIGTERM:
if (s->kill_context.send_sigkill) {
- log_warning_unit(UNIT(s)->id, "%s stopping timed out. Killing.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s stopping timed out. Killing.", UNIT(s)->id);
socket_enter_signal(s, SOCKET_STOP_PRE_SIGKILL, SOCKET_FAILURE_TIMEOUT);
} else {
- log_warning_unit(UNIT(s)->id, "%s stopping timed out. Skipping SIGKILL. Ignoring.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s stopping timed out. Skipping SIGKILL. Ignoring.", UNIT(s)->id);
socket_enter_stop_post(s, SOCKET_FAILURE_TIMEOUT);
}
break;
case SOCKET_STOP_PRE_SIGKILL:
- log_warning_unit(UNIT(s)->id, "%s still around after SIGKILL. Ignoring.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s still around after SIGKILL. Ignoring.", UNIT(s)->id);
socket_enter_stop_post(s, SOCKET_FAILURE_TIMEOUT);
break;
case SOCKET_STOP_POST:
- log_warning_unit(UNIT(s)->id, "%s stopping timed out (2). Terminating.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s stopping timed out (2). Terminating.", UNIT(s)->id);
socket_enter_signal(s, SOCKET_FINAL_SIGTERM, SOCKET_FAILURE_TIMEOUT);
break;
case SOCKET_FINAL_SIGTERM:
if (s->kill_context.send_sigkill) {
- log_warning_unit(UNIT(s)->id, "%s stopping timed out (2). Killing.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s stopping timed out (2). Killing.", UNIT(s)->id);
socket_enter_signal(s, SOCKET_FINAL_SIGKILL, SOCKET_FAILURE_TIMEOUT);
} else {
- log_warning_unit(UNIT(s)->id, "%s stopping timed out (2). Skipping SIGKILL. Ignoring.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s stopping timed out (2). Skipping SIGKILL. Ignoring.", UNIT(s)->id);
socket_enter_dead(s, SOCKET_FAILURE_TIMEOUT);
}
break;
case SOCKET_FINAL_SIGKILL:
- log_warning_unit(UNIT(s)->id, "%s still around after SIGKILL (2). Entering failed mode.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s still around after SIGKILL (2). Entering failed mode.", UNIT(s)->id);
socket_enter_dead(s, SOCKET_FAILURE_TIMEOUT);
break;
@@ -2556,7 +2556,7 @@ static void socket_notify_service_dead(Socket *s, bool failed_permanent) {
* services. */
if (s->state == SOCKET_RUNNING) {
- log_debug_unit(UNIT(s)->id, "%s got notified about service death (failed permanently: %s)", UNIT(s)->id, yes_no(failed_permanent));
+ log_unit_debug(UNIT(s)->id, "%s got notified about service death (failed permanently: %s)", UNIT(s)->id, yes_no(failed_permanent));
if (failed_permanent)
socket_enter_stop_pre(s, SOCKET_FAILURE_SERVICE_FAILED_PERMANENT);
else
@@ -2575,7 +2575,7 @@ void socket_connection_unref(Socket *s) {
assert(s->n_connections > 0);
s->n_connections--;
- log_debug_unit(UNIT(s)->id, "%s: One connection closed, %u left.", UNIT(s)->id, s->n_connections);
+ log_unit_debug(UNIT(s)->id, "%s: One connection closed, %u left.", UNIT(s)->id, s->n_connections);
}
static void socket_trigger_notify(Unit *u, Unit *other) {
diff --git a/src/core/swap.c b/src/core/swap.c
index e509a63..fd16104 100644
--- a/src/core/swap.c
+++ b/src/core/swap.c
@@ -233,12 +233,12 @@ static int swap_verify(Swap *s) {
b = unit_has_name(UNIT(s), e);
if (!b) {
- log_error_unit(UNIT(s)->id, "%s: Value of \"What\" and unit name do not match, not loading.", UNIT(s)->id);
+ log_unit_error(UNIT(s)->id, "%s: Value of \"What\" and unit name do not match, not loading.", UNIT(s)->id);
return -EINVAL;
}
if (s->exec_context.pam_name && s->kill_context.kill_mode != KILL_CONTROL_GROUP) {
- log_error_unit(UNIT(s)->id, "%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing to load.", UNIT(s)->id);
+ log_unit_error(UNIT(s)->id, "%s has PAM enabled. Kill mode must be set to 'control-group'. Refusing to load.", UNIT(s)->id);
return -EINVAL;
}
@@ -410,7 +410,7 @@ static int swap_add_one(
return 0;
fail:
- log_warning_unit(e, "Failed to load swap unit: %s", strerror(-r));
+ log_unit_warning(e, "Failed to load swap unit: %s", strerror(-r));
if (delete && u)
unit_free(u);
@@ -492,7 +492,7 @@ static void swap_set_state(Swap *s, SwapState state) {
}
if (state != old_state)
- log_debug_unit(UNIT(s)->id,
+ log_unit_debug(UNIT(s)->id,
"%s changed %s -> %s",
UNIT(s)->id,
swap_state_to_string(old_state),
@@ -698,7 +698,7 @@ static void swap_enter_signal(Swap *s, SwapState state, SwapResult f) {
return;
fail:
- log_warning_unit(UNIT(s)->id,
+ log_unit_warning(UNIT(s)->id,
"%s failed to kill processes: %s", UNIT(s)->id, strerror(-r));
swap_enter_dead(s, SWAP_FAILURE_RESOURCES);
@@ -827,7 +827,7 @@ static void swap_enter_activating(Swap *s) {
return;
fail:
- log_warning_unit(UNIT(s)->id,
+ log_unit_warning(UNIT(s)->id,
"%s failed to run 'swapon' task: %s",
UNIT(s)->id, strerror(-r));
swap_enter_dead(s, SWAP_FAILURE_RESOURCES);
@@ -859,7 +859,7 @@ static void swap_enter_deactivating(Swap *s) {
return;
fail:
- log_warning_unit(UNIT(s)->id,
+ log_unit_warning(UNIT(s)->id,
"%s failed to run 'swapoff' task: %s",
UNIT(s)->id, strerror(-r));
swap_enter_active(s, SWAP_FAILURE_RESOURCES);
@@ -946,7 +946,7 @@ static int swap_deserialize_item(Unit *u, const char *key, const char *value, FD
state = swap_state_from_string(value);
if (state < 0)
- log_debug_unit(u->id, "Failed to parse state value %s", value);
+ log_unit_debug(u->id, "Failed to parse state value %s", value);
else
s->deserialized_state = state;
} else if (streq(key, "result")) {
@@ -954,14 +954,14 @@ static int swap_deserialize_item(Unit *u, const char *key, const char *value, FD
f = swap_result_from_string(value);
if (f < 0)
- log_debug_unit(u->id, "Failed to parse result value %s", value);
+ log_unit_debug(u->id, "Failed to parse result value %s", value);
else if (f != SWAP_SUCCESS)
s->result = f;
} else if (streq(key, "control-pid")) {
pid_t pid;
if (parse_pid(value, &pid) < 0)
- log_debug_unit(u->id, "Failed to parse control-pid value %s", value);
+ log_unit_debug(u->id, "Failed to parse control-pid value %s", value);
else
s->control_pid = pid;
@@ -970,13 +970,13 @@ static int swap_deserialize_item(Unit *u, const char *key, const char *value, FD
id = swap_exec_command_from_string(value);
if (id < 0)
- log_debug_unit(u->id, "Failed to parse exec-command value %s", value);
+ log_unit_debug(u->id, "Failed to parse exec-command value %s", value);
else {
s->control_command_id = id;
s->control_command = s->exec_command + id;
}
} else
- log_debug_unit(u->id, "Unknown serialization key '%s'", key);
+ log_unit_debug(u->id, "Unknown serialization key '%s'", key);
return 0;
}
@@ -1034,8 +1034,8 @@ static void swap_sigchld_event(Unit *u, pid_t pid, int code, int status) {
s->control_command_id = _SWAP_EXEC_COMMAND_INVALID;
}
- log_full_unit(f == SWAP_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
- u->id,
+ log_unit_full(u->id,
+ f == SWAP_SUCCESS ? LOG_DEBUG : LOG_NOTICE,
"%s swap process exited, code=%s status=%i",
u->id, sigchld_code_to_string(code), status);
@@ -1077,38 +1077,38 @@ static int swap_dispatch_timer(sd_event_source *source, usec_t usec, void *userd
case SWAP_ACTIVATING:
case SWAP_ACTIVATING_DONE:
- log_warning_unit(UNIT(s)->id, "%s activation timed out. Stopping.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s activation timed out. Stopping.", UNIT(s)->id);
swap_enter_signal(s, SWAP_ACTIVATING_SIGTERM, SWAP_FAILURE_TIMEOUT);
break;
case SWAP_DEACTIVATING:
- log_warning_unit(UNIT(s)->id, "%s deactivation timed out. Stopping.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s deactivation timed out. Stopping.", UNIT(s)->id);
swap_enter_signal(s, SWAP_DEACTIVATING_SIGTERM, SWAP_FAILURE_TIMEOUT);
break;
case SWAP_ACTIVATING_SIGTERM:
if (s->kill_context.send_sigkill) {
- log_warning_unit(UNIT(s)->id, "%s activation timed out. Killing.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s activation timed out. Killing.", UNIT(s)->id);
swap_enter_signal(s, SWAP_ACTIVATING_SIGKILL, SWAP_FAILURE_TIMEOUT);
} else {
- log_warning_unit(UNIT(s)->id, "%s activation timed out. Skipping SIGKILL. Ignoring.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s activation timed out. Skipping SIGKILL. Ignoring.", UNIT(s)->id);
swap_enter_dead(s, SWAP_FAILURE_TIMEOUT);
}
break;
case SWAP_DEACTIVATING_SIGTERM:
if (s->kill_context.send_sigkill) {
- log_warning_unit(UNIT(s)->id, "%s deactivation timed out. Killing.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s deactivation timed out. Killing.", UNIT(s)->id);
swap_enter_signal(s, SWAP_DEACTIVATING_SIGKILL, SWAP_FAILURE_TIMEOUT);
} else {
- log_warning_unit(UNIT(s)->id, "%s deactivation timed out. Skipping SIGKILL. Ignoring.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s deactivation timed out. Skipping SIGKILL. Ignoring.", UNIT(s)->id);
swap_enter_dead(s, SWAP_FAILURE_TIMEOUT);
}
break;
case SWAP_ACTIVATING_SIGKILL:
case SWAP_DEACTIVATING_SIGKILL:
- log_warning_unit(UNIT(s)->id, "%s swap process still around after SIGKILL. Ignoring.", UNIT(s)->id);
+ log_unit_warning(UNIT(s)->id, "%s swap process still around after SIGKILL. Ignoring.", UNIT(s)->id);
swap_enter_dead(s, SWAP_FAILURE_TIMEOUT);
break;
diff --git a/src/core/timer.c b/src/core/timer.c
index 5c4e9f9..1380443 100644
--- a/src/core/timer.c
+++ b/src/core/timer.c
@@ -86,7 +86,7 @@ static int timer_verify(Timer *t) {
return 0;
if (!t->values) {
- log_error_unit(UNIT(t)->id, "%s lacks value setting. Refusing.", UNIT(t)->id);
+ log_unit_error(UNIT(t)->id, "%s lacks value setting. Refusing.", UNIT(t)->id);
return -EINVAL;
}
@@ -260,7 +260,7 @@ static void timer_set_state(Timer *t, TimerState state) {
}
if (state != old_state)
- log_debug_unit(UNIT(t)->id,
+ log_unit_debug(UNIT(t)->id,
"%s changed %s -> %s", UNIT(t)->id,
timer_state_to_string(old_state),
timer_state_to_string(state));
@@ -419,7 +419,7 @@ static void timer_enter_waiting(Timer *t, bool initial) {
}
if (!found_monotonic && !found_realtime) {
- log_debug_unit(UNIT(t)->id, "%s: Timer is elapsed.", UNIT(t)->id);
+ log_unit_debug(UNIT(t)->id, "%s: Timer is elapsed.", UNIT(t)->id);
timer_set_state(t, TIMER_ELAPSED);
return;
}
@@ -427,7 +427,7 @@ static void timer_enter_waiting(Timer *t, bool initial) {
if (found_monotonic) {
char buf[FORMAT_TIMESPAN_MAX];
- log_debug_unit(UNIT(t)->id, "%s: Monotonic timer elapses in %s.",
+ log_unit_debug(UNIT(t)->id, "%s: Monotonic timer elapses in %s.",
UNIT(t)->id,
format_timespan(buf, sizeof(buf), t->next_elapse_monotonic_or_boottime > ts_monotonic ? t->next_elapse_monotonic_or_boottime - ts_monotonic : 0, 0));
@@ -456,7 +456,7 @@ static void timer_enter_waiting(Timer *t, bool initial) {
if (found_realtime) {
char buf[FORMAT_TIMESTAMP_MAX];
- log_debug_unit(UNIT(t)->id, "%s: Realtime timer elapses at %s.", UNIT(t)->id, format_timestamp(buf, sizeof(buf), t->next_elapse_realtime));
+ log_unit_debug(UNIT(t)->id, "%s: Realtime timer elapses at %s.", UNIT(t)->id, format_timestamp(buf, sizeof(buf), t->next_elapse_realtime));
if (t->realtime_event_source) {
r = sd_event_source_set_time(t->realtime_event_source, t->next_elapse_realtime);
@@ -485,7 +485,7 @@ static void timer_enter_waiting(Timer *t, bool initial) {
return;
fail:
- log_warning_unit(UNIT(t)->id, "%s failed to enter waiting state: %s", UNIT(t)->id, strerror(-r));
+ log_unit_warning(UNIT(t)->id, "%s failed to enter waiting state: %s", UNIT(t)->id, strerror(-r));
timer_enter_dead(t, TIMER_FAILURE_RESOURCES);
}
@@ -513,7 +513,7 @@ static void timer_enter_running(Timer *t) {
return;
fail:
- log_warning_unit(UNIT(t)->id,
+ log_unit_warning(UNIT(t)->id,
"%s failed to queue unit startup job: %s",
UNIT(t)->id, bus_error_message(&error, r));
timer_enter_dead(t, TIMER_FAILURE_RESOURCES);
@@ -596,7 +596,7 @@ static int timer_deserialize_item(Unit *u, const char *key, const char *value, F
state = timer_state_from_string(value);
if (state < 0)
- log_debug_unit(u->id, "Failed to parse state value %s", value);
+ log_unit_debug(u->id, "Failed to parse state value %s", value);
else
t->deserialized_state = state;
} else if (streq(key, "result")) {
@@ -604,23 +604,23 @@ static int timer_deserialize_item(Unit *u, const char *key, const char *value, F
f = timer_result_from_string(value);
if (f < 0)
- log_debug_unit(u->id, "Failed to parse result value %s", value);
+ log_unit_debug(u->id, "Failed to parse result value %s", value);
else if (f != TIMER_SUCCESS)
t->result = f;
} else if (streq(key, "last-trigger-realtime")) {
r = safe_atou64(value, &t->last_trigger.realtime);
if (r < 0)
- log_debug_unit(u->id, "Failed to parse last-trigger-realtime value %s", value);
+ log_unit_debug(u->id, "Failed to parse last-trigger-realtime value %s", value);
} else if (streq(key, "last-trigger-monotonic")) {
r = safe_atou64(value, &t->last_trigger.monotonic);
if (r < 0)
- log_debug_unit(u->id, "Failed to parse last-trigger-monotonic value %s", value);
+ log_unit_debug(u->id, "Failed to parse last-trigger-monotonic value %s", value);
} else
- log_debug_unit(u->id, "Unknown serialization key '%s'", key);
+ log_unit_debug(u->id, "Unknown serialization key '%s'", key);
return 0;
}
@@ -645,7 +645,7 @@ static int timer_dispatch(sd_event_source *s, uint64_t usec, void *userdata) {
if (t->state != TIMER_WAITING)
return 0;
- log_debug_unit(UNIT(t)->id, "Timer elapsed on %s", UNIT(t)->id);
+ log_unit_debug(UNIT(t)->id, "Timer elapsed on %s", UNIT(t)->id);
timer_enter_running(t);
return 0;
}
@@ -678,7 +678,7 @@ static void timer_trigger_notify(Unit *u, Unit *other) {
case TIMER_RUNNING:
if (UNIT_IS_INACTIVE_OR_FAILED(unit_active_state(other))) {
- log_debug_unit(UNIT(t)->id, "%s got notified about unit deactivation.", UNIT(t)->id);
+ log_unit_debug(UNIT(t)->id, "%s got notified about unit deactivation.", UNIT(t)->id);
timer_enter_waiting(t, false);
}
break;
@@ -711,7 +711,7 @@ static void timer_time_change(Unit *u) {
if (t->state != TIMER_WAITING)
return;
- log_debug_unit(u->id, "%s: time change, recalculating next elapse.", u->id);
+ log_unit_debug(u->id, "%s: time change, recalculating next elapse.", u->id);
timer_enter_waiting(t, false);
}
diff --git a/src/core/transaction.c b/src/core/transaction.c
index 6ad11b2..652ac71 100644
--- a/src/core/transaction.c
+++ b/src/core/transaction.c
@@ -189,11 +189,11 @@ static int delete_one_unmergeable_job(Transaction *tr, Job *j) {
* another unit in which case we
* rather remove the start. */
- log_debug_unit(j->unit->id,
+ log_unit_debug(j->unit->id,
"Looking at job %s/%s conflicted_by=%s",
j->unit->id, job_type_to_string(j->type),
yes_no(j->type == JOB_STOP && job_is_conflicted_by(j)));
- log_debug_unit(k->unit->id,
+ log_unit_debug(k->unit->id,
"Looking at job %s/%s conflicted_by=%s",
k->unit->id, job_type_to_string(k->type),
yes_no(k->type == JOB_STOP && job_is_conflicted_by(k)));
@@ -222,7 +222,7 @@ static int delete_one_unmergeable_job(Transaction *tr, Job *j) {
return -ENOEXEC;
/* Ok, we can drop one, so let's do so. */
- log_debug_unit(d->unit->id,
+ log_unit_debug(d->unit->id,
"Fixing conflicting jobs %s/%s,%s/%s by deleting job %s/%s",
j->unit->id, job_type_to_string(j->type),
k->unit->id, job_type_to_string(k->type),
@@ -368,7 +368,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
* job to remove. We use the marker to find our way
* back, since smart how we are we stored our way back
* in there. */
- log_warning_unit(j->unit->id,
+ log_unit_warning(j->unit->id,
"Found ordering cycle on %s/%s",
j->unit->id, job_type_to_string(j->type));
@@ -376,7 +376,7 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
for (k = from; k; k = ((k->generation == generation && k->marker != k) ? k->marker : NULL)) {
/* logging for j not k here here to provide consistent narrative */
- log_warning_unit(j->unit->id,
+ log_unit_warning(j->unit->id,
"Found dependency on %s/%s",
k->unit->id, job_type_to_string(k->type));
@@ -396,10 +396,10 @@ static int transaction_verify_order_one(Transaction *tr, Job *j, Job *from, unsi
if (delete) {
/* logging for j not k here here to provide consistent narrative */
- log_warning_unit(j->unit->id,
+ log_unit_warning(j->unit->id,
"Breaking ordering cycle by deleting job %s/%s",
delete->unit->id, job_type_to_string(delete->type));
- log_error_unit(delete->unit->id,
+ log_unit_error(delete->unit->id,
"Job %s/%s deleted to break ordering cycle starting with %s/%s",
delete->unit->id, job_type_to_string(delete->type),
j->unit->id, job_type_to_string(j->type));
@@ -552,17 +552,17 @@ rescan:
continue;
if (stops_running_service)
- log_debug_unit(j->unit->id,
+ log_unit_debug(j->unit->id,
"%s/%s would stop a running service.",
j->unit->id, job_type_to_string(j->type));
if (changes_existing_job)
- log_debug_unit(j->unit->id,
+ log_unit_debug(j->unit->id,
"%s/%s would change existing job.",
j->unit->id, job_type_to_string(j->type));
/* Ok, let's get rid of this */
- log_debug_unit(j->unit->id,
+ log_unit_debug(j->unit->id,
"Deleting %s/%s to minimize impact.",
j->unit->id, job_type_to_string(j->type));
@@ -819,7 +819,7 @@ static void transaction_unlink_job(Transaction *tr, Job *j, bool delete_dependen
job_dependency_free(j->object_list);
if (other && delete_dependencies) {
- log_debug_unit(other->unit->id,
+ log_unit_debug(other->unit->id,
"Deleting job %s/%s as dependency of job %s/%s",
other->unit->id, job_type_to_string(other->type),
j->unit->id, job_type_to_string(j->type));
@@ -915,7 +915,7 @@ int transaction_add_job_and_dependencies(
SET_FOREACH(dep, following, i) {
r = transaction_add_job_and_dependencies(tr, type, dep, ret, false, override, false, false, ignore_order, e);
if (r < 0) {
- log_warning_unit(dep->id,
+ log_unit_warning(dep->id,
"Cannot add dependency job for unit %s, ignoring: %s",
dep->id, bus_error_message(e, r));
@@ -954,7 +954,8 @@ int transaction_add_job_and_dependencies(
SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUIRES_OVERRIDABLE], i) {
r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, !override, override, false, false, ignore_order, e);
if (r < 0) {
- log_full_unit(r == -EADDRNOTAVAIL ? LOG_DEBUG : LOG_WARNING, dep->id,
+ log_unit_full(dep->id,
+ r == -EADDRNOTAVAIL ? LOG_DEBUG : LOG_WARNING,
"Cannot add dependency job for unit %s, ignoring: %s",
dep->id, bus_error_message(e, r));
@@ -966,7 +967,8 @@ int transaction_add_job_and_dependencies(
SET_FOREACH(dep, ret->unit->dependencies[UNIT_WANTS], i) {
r = transaction_add_job_and_dependencies(tr, JOB_START, dep, ret, false, false, false, false, ignore_order, e);
if (r < 0) {
- log_full_unit(r == -EADDRNOTAVAIL ? LOG_DEBUG : LOG_WARNING, dep->id,
+ log_unit_full(dep->id,
+ r == -EADDRNOTAVAIL ? LOG_DEBUG : LOG_WARNING,
"Cannot add dependency job for unit %s, ignoring: %s",
dep->id, bus_error_message(e, r));
@@ -989,7 +991,8 @@ int transaction_add_job_and_dependencies(
SET_FOREACH(dep, ret->unit->dependencies[UNIT_REQUISITE_OVERRIDABLE], i) {
r = transaction_add_job_and_dependencies(tr, JOB_VERIFY_ACTIVE, dep, ret, !override, override, false, false, ignore_order, e);
if (r < 0) {
- log_full_unit(r == -EADDRNOTAVAIL ? LOG_DEBUG : LOG_WARNING, dep->id,
+ log_unit_full(dep->id,
+ r == -EADDRNOTAVAIL ? LOG_DEBUG : LOG_WARNING,
"Cannot add dependency job for unit %s, ignoring: %s",
dep->id, bus_error_message(e, r));
@@ -1012,7 +1015,7 @@ int transaction_add_job_and_dependencies(
SET_FOREACH(dep, ret->unit->dependencies[UNIT_CONFLICTED_BY], i) {
r = transaction_add_job_and_dependencies(tr, JOB_STOP, dep, ret, false, override, false, false, ignore_order, e);
if (r < 0) {
- log_warning_unit(dep->id,
+ log_unit_warning(dep->id,
"Cannot add dependency job for unit %s, ignoring: %s",
dep->id, bus_error_message(e, r));
@@ -1065,7 +1068,7 @@ int transaction_add_job_and_dependencies(
SET_FOREACH(dep, ret->unit->dependencies[UNIT_PROPAGATES_RELOAD_TO], i) {
r = transaction_add_job_and_dependencies(tr, JOB_RELOAD, dep, ret, false, override, false, false, ignore_order, e);
if (r < 0) {
- log_warning_unit(dep->id,
+ log_unit_warning(dep->id,
"Cannot add dependency reload job for unit %s, ignoring: %s",
dep->id, bus_error_message(e, r));
@@ -1112,7 +1115,7 @@ int transaction_add_isolate_jobs(Transaction *tr, Manager *m) {
r = transaction_add_job_and_dependencies(tr, JOB_STOP, u, tr->anchor_job, true, false, false, false, false, NULL);
if (r < 0)
- log_warning_unit(u->id,
+ log_unit_warning(u->id,
"Cannot add isolate job for unit %s, ignoring: %s",
u->id, strerror(-r));
}
diff --git a/src/core/unit.c b/src/core/unit.c
index 948f8e2..2e8df7d 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -1218,7 +1218,7 @@ int unit_load(Unit *u) {
goto fail;
if (u->on_failure_job_mode == JOB_ISOLATE && set_size(u->dependencies[UNIT_ON_FAILURE]) > 1) {
- log_error_unit(u->id, "More than one OnFailure= dependencies specified for %s but OnFailureJobMode=isolate set. Refusing.", u->id);
+ log_unit_error(u->id, "More than one OnFailure= dependencies specified for %s but OnFailureJobMode=isolate set. Refusing.", u->id);
r = -EINVAL;
goto fail;
}
@@ -1239,7 +1239,7 @@ fail:
unit_add_to_dbus_queue(u);
unit_add_to_gc_queue(u);
- log_debug_unit(u->id, "Failed to load configuration for %s: %s",
+ log_unit_debug(u->id, "Failed to load configuration for %s: %s",
u->id, strerror(-r));
return r;
@@ -1264,7 +1264,7 @@ static bool unit_condition_test_list(Unit *u, Condition *first, const char *(*to
r = condition_test(c);
if (r < 0)
- log_warning_unit(u->id,
+ log_unit_warning(u->id,
"Couldn't determine result for %s=%s%s%s for %s, assuming failed: %s",
to_string(c->type),
c->trigger ? "|" : "",
@@ -1273,7 +1273,7 @@ static bool unit_condition_test_list(Unit *u, Condition *first, const char *(*to
u->id,
strerror(-r));
else
- log_debug_unit(u->id,
+ log_unit_debug(u->id,
"%s=%s%s%s %s for %s.",
to_string(c->type),
c->trigger ? "|" : "",
@@ -1394,7 +1394,7 @@ static void unit_status_log_starting_stopping_reloading(Unit *u, JobType t) {
t == JOB_STOP ? SD_MESSAGE_UNIT_STOPPING :
SD_MESSAGE_UNIT_RELOADING;
- log_struct_unit(LOG_INFO,
+ log_unit_struct(LOG_INFO,
u->id,
MESSAGE_ID(mid),
"MESSAGE=%s", buf,
@@ -1431,21 +1431,21 @@ int unit_start(Unit *u) {
* but we don't want to recheck the condition in that case. */
if (state != UNIT_ACTIVATING &&
!unit_condition_test(u)) {
- log_debug_unit(u->id, "Starting of %s requested but condition failed. Not starting unit.", u->id);
+ log_unit_debug(u->id, "Starting of %s requested but condition failed. Not starting unit.", u->id);
return -EALREADY;
}
/* If the asserts failed, fail the entire job */
if (state != UNIT_ACTIVATING &&
!unit_assert_test(u)) {
- log_debug_unit(u->id, "Starting of %s requested but asserts failed.", u->id);
+ log_unit_debug(u->id, "Starting of %s requested but asserts failed.", u->id);
return -EPROTO;
}
/* Forward to the main object, if we aren't it. */
following = unit_following(u);
if (following) {
- log_debug_unit(u->id, "Redirecting start request from %s to %s.", u->id, following->id);
+ log_unit_debug(u->id, "Redirecting start request from %s to %s.", u->id, following->id);
return unit_start(following);
}
@@ -1496,7 +1496,7 @@ int unit_stop(Unit *u) {
return -EALREADY;
if ((following = unit_following(u))) {
- log_debug_unit(u->id, "Redirecting stop request from %s to %s.",
+ log_unit_debug(u->id, "Redirecting stop request from %s to %s.",
u->id, following->id);
return unit_stop(following);
}
@@ -1534,14 +1534,14 @@ int unit_reload(Unit *u) {
return -EALREADY;
if (state != UNIT_ACTIVE) {
- log_warning_unit(u->id, "Unit %s cannot be reloaded because it is inactive.",
+ log_unit_warning(u->id, "Unit %s cannot be reloaded because it is inactive.",
u->id);
return -ENOEXEC;
}
following = unit_following(u);
if (following) {
- log_debug_unit(u->id, "Redirecting reload request from %s to %s.",
+ log_unit_debug(u->id, "Redirecting reload request from %s to %s.",
u->id, following->id);
return unit_reload(following);
}
@@ -1595,7 +1595,7 @@ static void unit_check_unneeded(Unit *u) {
if (unit_active_or_pending(other))
return;
- log_info_unit(u->id, "Unit %s is not needed anymore. Stopping.", u->id);
+ log_unit_info(u->id, "Unit %s is not needed anymore. Stopping.", u->id);
/* Ok, nobody needs us anymore. Sniff. Then let's commit suicide */
manager_add_job(u->manager, JOB_STOP, u, JOB_FAIL, true, NULL, NULL);
@@ -1627,7 +1627,7 @@ static void unit_check_binds_to(Unit *u) {
if (!stop)
return;
- log_info_unit(u->id, "Unit %s is bound to inactive service. Stopping, too.", u->id);
+ log_unit_info(u->id, "Unit %s is bound to inactive service. Stopping, too.", u->id);
/* A unit we need to run is gone. Sniff. Let's stop this. */
manager_add_job(u->manager, JOB_STOP, u, JOB_FAIL, true, NULL, NULL);
@@ -1719,14 +1719,14 @@ void unit_start_on_failure(Unit *u) {
if (set_size(u->dependencies[UNIT_ON_FAILURE]) <= 0)
return;
- log_info_unit(u->id, "Triggering OnFailure= dependencies of %s.", u->id);
+ log_unit_info(u->id, "Triggering OnFailure= dependencies of %s.", u->id);
SET_FOREACH(other, u->dependencies[UNIT_ON_FAILURE], i) {
int r;
r = manager_add_job(u->manager, JOB_START, other, u->on_failure_job_mode, true, NULL, NULL);
if (r < 0)
- log_error_unit(u->id, "Failed to enqueue OnFailure= job: %s", strerror(-r));
+ log_unit_error(u->id, "Failed to enqueue OnFailure= job: %s", strerror(-r));
}
}
@@ -1890,7 +1890,7 @@ void unit_notify(Unit *u, UnitActiveState os, UnitActiveState ns, bool reload_su
check_unneeded_dependencies(u);
if (ns != os && ns == UNIT_FAILED) {
- log_notice_unit(u->id, "Unit %s entered failed state.", u->id);
+ log_unit_notice(u->id, "Unit %s entered failed state.", u->id);
unit_start_on_failure(u);
}
}
@@ -2152,10 +2152,10 @@ static int maybe_warn_about_dependency(const char *id, const char *other, UnitDe
case UNIT_TRIGGERS:
case UNIT_TRIGGERED_BY:
if (streq_ptr(id, other))
- log_warning_unit(id, "Dependency %s=%s dropped from unit %s",
+ log_unit_warning(id, "Dependency %s=%s dropped from unit %s",
unit_dependency_to_string(dependency), id, other);
else
- log_warning_unit(id, "Dependency %s=%s dropped from unit %s merged into %s",
+ log_unit_warning(id, "Dependency %s=%s dropped from unit %s merged into %s",
unit_dependency_to_string(dependency), id,
strna(other), id);
return -EINVAL;
@@ -3435,7 +3435,7 @@ int unit_kill_context(
_cleanup_free_ char *comm = NULL;
get_process_comm(main_pid, &comm);
- log_warning_unit(u->id, "Failed to kill main process " PID_FMT " (%s): %s", main_pid, strna(comm), strerror(-r));
+ log_unit_warning(u->id, "Failed to kill main process " PID_FMT " (%s): %s", main_pid, strna(comm), strerror(-r));
} else {
if (!main_pid_alien)
wait_for_exit = true;
@@ -3452,7 +3452,7 @@ int unit_kill_context(
_cleanup_free_ char *comm = NULL;
get_process_comm(control_pid, &comm);
- log_warning_unit(u->id, "Failed to kill control process " PID_FMT " (%s): %s", control_pid, strna(comm), strerror(-r));
+ log_unit_warning(u->id, "Failed to kill control process " PID_FMT " (%s): %s", control_pid, strna(comm), strerror(-r));
} else {
wait_for_exit = true;
@@ -3472,7 +3472,7 @@ int unit_kill_context(
r = cg_kill_recursive(SYSTEMD_CGROUP_CONTROLLER, u->cgroup_path, sig, true, true, false, pid_set);
if (r < 0) {
if (r != -EAGAIN && r != -ESRCH && r != -ENOENT)
- log_warning_unit(u->id, "Failed to kill control group: %s", strerror(-r));
+ log_unit_warning(u->id, "Failed to kill control group: %s", strerror(-r));
} else if (r > 0) {
/* FIXME: For now, we will not wait for the
diff --git a/src/core/unit.h b/src/core/unit.h
index 54ba11a..5c0fba7 100644
--- a/src/core/unit.h
+++ b/src/core/unit.h
@@ -596,13 +596,13 @@ UnitActiveState unit_active_state_from_string(const char *s) _pure_;
/* Macros which append UNIT= or USER_UNIT= to the message */
-#define log_full_unit(level, unit, ...) log_meta_object(level, 0, __FILE__, __LINE__, __func__, getpid() == 1 ? "UNIT=" : "USER_UNIT=", unit, __VA_ARGS__)
-#define log_full_unit_errno(level, error, unit, ...) log_meta_object(level, error, __FILE__, __LINE__, __func__, getpid() == 1 ? "UNIT=" : "USER_UNIT=", unit, __VA_ARGS__)
+#define log_unit_full_errno(unit, level, error, ...) log_object_internal(level, error, __FILE__, __LINE__, __func__, getpid() == 1 ? "UNIT=" : "USER_UNIT=", unit, __VA_ARGS__)
+#define log_unit_full(unit, level, ...) log_unit_full_errno(unit, level, 0, __VA_ARGS__)
-#define log_debug_unit(unit, ...) log_full_unit(LOG_DEBUG, unit, __VA_ARGS__)
-#define log_info_unit(unit, ...) log_full_unit(LOG_INFO, unit, __VA_ARGS__)
-#define log_notice_unit(unit, ...) log_full_unit(LOG_NOTICE, unit, __VA_ARGS__)
-#define log_warning_unit(unit, ...) log_full_unit(LOG_WARNING, unit, __VA_ARGS__)
-#define log_error_unit(unit, ...) log_full_unit(LOG_ERR, unit, __VA_ARGS__)
+#define log_unit_debug(unit, ...) log_unit_full(unit, LOG_DEBUG, __VA_ARGS__)
+#define log_unit_info(unit, ...) log_unit_full(unit, LOG_INFO, __VA_ARGS__)
+#define log_unit_notice(unit, ...) log_unit_full(unit, LOG_NOTICE, __VA_ARGS__)
+#define log_unit_warning(unit, ...) log_unit_full(unit, LOG_WARNING, __VA_ARGS__)
+#define log_unit_error(unit, ...) log_unit_full(unit, LOG_ERR, __VA_ARGS__)
-#define log_struct_unit(level, unit, ...) log_struct(level, getpid() == 1 ? "UNIT=%s" : "USER_UNIT=%s", unit, __VA_ARGS__)
+#define log_unit_struct(level, unit, ...) log_struct(level, getpid() == 1 ? "UNIT=%s" : "USER_UNIT=%s", unit, __VA_ARGS__)
diff --git a/src/journal-remote/microhttpd-util.c b/src/journal-remote/microhttpd-util.c
index bec4134..5dae10b 100644
--- a/src/journal-remote/microhttpd-util.c
+++ b/src/journal-remote/microhttpd-util.c
@@ -41,7 +41,7 @@ void microhttpd_logger(void *arg, const char *fmt, va_list ap) {
f = strappenda("microhttpd: ", fmt);
DISABLE_WARNING_FORMAT_NONLITERAL;
- log_metav(LOG_INFO, 0, NULL, 0, NULL, f, ap);
+ log_internalv(LOG_INFO, 0, NULL, 0, NULL, f, ap);
REENABLE_WARNING;
}
@@ -126,10 +126,10 @@ void log_func_gnutls(int level, const char *message) {
if (0 <= level && level < (int) ELEMENTSOF(gnutls_log_map)) {
if (gnutls_log_map[level].enabled)
- log_meta(gnutls_log_map[level].level, 0, NULL, 0, NULL, "gnutls %d/%s: %s", level, gnutls_log_map[level].names[1], message);
+ log_internal(gnutls_log_map[level].level, 0, NULL, 0, NULL, "gnutls %d/%s: %s", level, gnutls_log_map[level].names[1], message);
} else {
log_debug("Received GNUTLS message with unknown level %d.", level);
- log_meta(LOG_DEBUG, 0, NULL, 0, NULL, "gnutls: %s", message);
+ log_internal(LOG_DEBUG, 0, NULL, 0, NULL, "gnutls: %s", message);
}
}
diff --git a/src/journal/test-journal-interleaving.c b/src/journal/test-journal-interleaving.c
index 8067cd3..23a26c4 100644
--- a/src/journal/test-journal-interleaving.c
+++ b/src/journal/test-journal-interleaving.c
@@ -37,9 +37,9 @@
static bool arg_keep = false;
noreturn static void log_assert_errno(const char *text, int eno, const char *file, int line, const char *func) {
- log_meta(LOG_CRIT, file, line, func,
- "'%s' failed at %s:%u (%s): %s.",
- text, file, line, func, strerror(eno));
+ log_internal(LOG_CRIT, 0, file, line, func,
+ "'%s' failed at %s:%u (%s): %s.",
+ text, file, line, func, strerror(eno));
abort();
}
diff --git a/src/libsystemd-network/dhcp-internal.h b/src/libsystemd-network/dhcp-internal.h
index d76d0c2..7c60ef1 100644
--- a/src/libsystemd-network/dhcp-internal.h
+++ b/src/libsystemd-network/dhcp-internal.h
@@ -71,4 +71,4 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(sd_dhcp_client*, sd_dhcp_client_unref);
#define DHCP_CLIENT_DONT_DESTROY(client) \
_cleanup_dhcp_client_unref_ _unused_ sd_dhcp_client *_dont_destroy_##client = sd_dhcp_client_ref(client)
-#define log_dhcp_client(client, fmt, ...) log_meta(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "DHCP CLIENT (0x%x): " fmt, client->xid, ##__VA_ARGS__)
+#define log_dhcp_client(client, fmt, ...) log_internal(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "DHCP CLIENT (0x%x): " fmt, client->xid, ##__VA_ARGS__)
diff --git a/src/libsystemd-network/dhcp-server-internal.h b/src/libsystemd-network/dhcp-server-internal.h
index 6c2c248..eb7d6d4 100644
--- a/src/libsystemd-network/dhcp-server-internal.h
+++ b/src/libsystemd-network/dhcp-server-internal.h
@@ -79,7 +79,7 @@ typedef struct DHCPRequest {
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_dhcp_server*, sd_dhcp_server_unref);
#define _cleanup_dhcp_server_unref_ _cleanup_(sd_dhcp_server_unrefp)
-#define log_dhcp_server(client, fmt, ...) log_meta(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "DHCP SERVER: " fmt, ##__VA_ARGS__)
+#define log_dhcp_server(client, fmt, ...) log_internal(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "DHCP SERVER: " fmt, ##__VA_ARGS__)
int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message,
size_t length);
diff --git a/src/libsystemd-network/dhcp6-internal.h b/src/libsystemd-network/dhcp6-internal.h
index 3737d49..4f54ad8 100644
--- a/src/libsystemd-network/dhcp6-internal.h
+++ b/src/libsystemd-network/dhcp6-internal.h
@@ -56,7 +56,7 @@ struct DHCP6IA {
typedef struct DHCP6IA DHCP6IA;
-#define log_dhcp6_client(p, fmt, ...) log_meta(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "DHCPv6 CLIENT: " fmt, ##__VA_ARGS__)
+#define log_dhcp6_client(p, fmt, ...) log_internal(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "DHCPv6 CLIENT: " fmt, ##__VA_ARGS__)
int dhcp_network_icmp6_bind_router_solicitation(int index);
int dhcp_network_icmp6_send_router_solicitation(int s, const struct ether_addr *ether_addr);
diff --git a/src/libsystemd-network/ipv4ll-internal.h b/src/libsystemd-network/ipv4ll-internal.h
index 7b5d372..ae0ce43 100644
--- a/src/libsystemd-network/ipv4ll-internal.h
+++ b/src/libsystemd-network/ipv4ll-internal.h
@@ -35,4 +35,4 @@ void arp_packet_probe(struct ether_arp *arp, be32_t pa, const struct ether_addr
void arp_packet_announcement(struct ether_arp *arp, be32_t pa, const struct ether_addr *ha);
int arp_packet_verify_headers(struct ether_arp *arp);
-#define log_ipv4ll(ll, fmt, ...) log_meta(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "IPv4LL: " fmt, ##__VA_ARGS__)
+#define log_ipv4ll(ll, fmt, ...) log_internal(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "IPv4LL: " fmt, ##__VA_ARGS__)
diff --git a/src/libsystemd-network/sd-icmp6-nd.c b/src/libsystemd-network/sd-icmp6-nd.c
index 23f5682..cb06151 100644
--- a/src/libsystemd-network/sd-icmp6-nd.c
+++ b/src/libsystemd-network/sd-icmp6-nd.c
@@ -54,7 +54,7 @@ struct sd_icmp6_nd {
void *userdata;
};
-#define log_icmp6_nd(p, fmt, ...) log_meta(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "ICMPv6 CLIENT: " fmt, ##__VA_ARGS__)
+#define log_icmp6_nd(p, fmt, ...) log_internal(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "ICMPv6 CLIENT: " fmt, ##__VA_ARGS__)
static void icmp6_nd_notify(sd_icmp6_nd *nd, int event)
{
diff --git a/src/libsystemd-terminal/idev-keyboard.c b/src/libsystemd-terminal/idev-keyboard.c
index ad2d74a..b1af960 100644
--- a/src/libsystemd-terminal/idev-keyboard.c
+++ b/src/libsystemd-terminal/idev-keyboard.c
@@ -522,7 +522,7 @@ static void kbdctx_log_fn(struct xkb_context *ctx, enum xkb_log_level lvl, const
sd_lvl = LOG_CRIT;
snprintf(buf, sizeof(buf), "idev-xkb: %s", format);
- log_metav(sd_lvl, __FILE__, __LINE__, __func__, buf, args);
+ log_internalv(sd_lvl, __FILE__, __LINE__, __func__, buf, args);
}
static kbdctx *kbdctx_ref(kbdctx *kc) {
diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c
index da67247..5353814 100644
--- a/src/modules-load/modules-load.c
+++ b/src/modules-load/modules-load.c
@@ -44,7 +44,7 @@ static void systemd_kmod_log(void *data, int priority, const char *file, int lin
const char *fn, const char *format, va_list args) {
DISABLE_WARNING_FORMAT_NONLITERAL;
- log_metav(priority, 0, file, line, fn, format, args);
+ log_internalv(priority, 0, file, line, fn, format, args);
REENABLE_WARNING;
}
diff --git a/src/network/networkd-address.c b/src/network/networkd-address.c
index ce85109..cf49909 100644
--- a/src/network/networkd-address.c
+++ b/src/network/networkd-address.c
@@ -251,11 +251,11 @@ static int address_acquire(Link *link, Address *original, Address **ret) {
* Then let's acquire something more useful from the pool. */
r = manager_address_pool_acquire(link->manager, original->family, original->prefixlen, &in_addr);
if (r < 0) {
- log_error_link(link, "Failed to acquire address from pool: %s", strerror(-r));
+ log_link_error(link, "Failed to acquire address from pool: %s", strerror(-r));
return r;
}
if (r == 0) {
- log_error_link(link, "Couldn't find free address for interface, all taken.");
+ log_link_error(link, "Couldn't find free address for interface, all taken.");
return -EBUSY;
}
diff --git a/src/network/networkd-dhcp4.c b/src/network/networkd-dhcp4.c
index 63bfa86..0a8c8ba 100644
--- a/src/network/networkd-dhcp4.c
+++ b/src/network/networkd-dhcp4.c
@@ -38,7 +38,7 @@ static int dhcp4_route_handler(sd_rtnl *rtnl, sd_rtnl_message *m,
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -EEXIST) {
- log_error_link(link, "could not set DHCPv4 route: %s",
+ log_link_error(link, "could not set DHCPv4 route: %s",
strerror(-r));
link_enter_failed(link);
}
@@ -61,7 +61,7 @@ static int link_set_dhcp_routes(Link *link) {
r = sd_dhcp_lease_get_router(link->dhcp_lease, &gateway);
if (r < 0 && r != -ENOENT) {
- log_warning_link(link,
+ log_link_warning(link,
"DHCP error: could not get gateway: %s",
strerror(-r));
return r;
@@ -73,7 +73,7 @@ static int link_set_dhcp_routes(Link *link) {
r = sd_dhcp_lease_get_address(link->dhcp_lease, &address);
if (r < 0) {
- log_warning_link(link,
+ log_link_warning(link,
"DHCP error: could not get address: %s",
strerror(-r));
return r;
@@ -81,7 +81,7 @@ static int link_set_dhcp_routes(Link *link) {
r = route_new_dynamic(&route, RTPROT_DHCP);
if (r < 0) {
- log_error_link(link,
+ log_link_error(link,
"Could not allocate route: %s",
strerror(-r));
return r;
@@ -89,7 +89,7 @@ static int link_set_dhcp_routes(Link *link) {
r = route_new_dynamic(&route_gw, RTPROT_DHCP);
if (r < 0) {
- log_error_link(link,
+ log_link_error(link,
"Could not allocate route: %s",
strerror(-r));
return r;
@@ -107,7 +107,7 @@ static int link_set_dhcp_routes(Link *link) {
r = route_configure(route_gw, link, &dhcp4_route_handler);
if (r < 0) {
- log_warning_link(link,
+ log_link_warning(link,
"could not set host route: %s",
strerror(-r));
return r;
@@ -122,7 +122,7 @@ static int link_set_dhcp_routes(Link *link) {
r = route_configure(route, link, &dhcp4_route_handler);
if (r < 0) {
- log_warning_link(link,
+ log_link_warning(link,
"could not set routes: %s",
strerror(-r));
link_enter_failed(link);
@@ -136,7 +136,7 @@ static int link_set_dhcp_routes(Link *link) {
if (n == -ENOENT)
return 0;
if (n < 0) {
- log_warning_link(link,
+ log_link_warning(link,
"DHCP error: could not get routes: %s",
strerror(-n));
@@ -148,7 +148,7 @@ static int link_set_dhcp_routes(Link *link) {
r = route_new_dynamic(&route, RTPROT_DHCP);
if (r < 0) {
- log_error_link(link, "Could not allocate route: %s",
+ log_link_error(link, "Could not allocate route: %s",
strerror(-r));
return r;
}
@@ -161,7 +161,7 @@ static int link_set_dhcp_routes(Link *link) {
r = route_configure(route, link, &dhcp4_route_handler);
if (r < 0) {
- log_warning_link(link,
+ log_link_warning(link,
"could not set host route: %s",
strerror(-r));
return r;
@@ -184,7 +184,7 @@ static int dhcp_lease_lost(Link *link) {
assert(link);
assert(link->dhcp_lease);
- log_warning_link(link, "DHCP lease lost");
+ log_link_warning(link, "DHCP lease lost");
if (link->network->dhcp_routes) {
struct sd_dhcp_route *routes;
@@ -258,7 +258,7 @@ static int dhcp_lease_lost(Link *link) {
if (r >= 0 && link->original_mtu != mtu) {
r = link_set_mtu(link, link->original_mtu);
if (r < 0) {
- log_warning_link(link,
+ log_link_warning(link,
"DHCP error: could not reset MTU");
link_enter_failed(link);
return r;
@@ -273,7 +273,7 @@ static int dhcp_lease_lost(Link *link) {
if (r >= 0 && hostname) {
r = link_set_hostname(link, "");
if (r < 0)
- log_error_link(link,
+ log_link_error(link,
"Failed to reset transient hostname");
}
}
@@ -293,7 +293,7 @@ static int dhcp4_address_handler(sd_rtnl *rtnl, sd_rtnl_message *m,
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -EEXIST) {
- log_error_link(link, "could not set DHCPv4 address: %s",
+ log_link_error(link, "could not set DHCPv4 address: %s",
strerror(-r));
link_enter_failed(link);
} else if (r >= 0) {
@@ -354,7 +354,7 @@ static int dhcp_lease_renew(sd_dhcp_client *client, Link *link) {
r = sd_dhcp_client_get_lease(client, &lease);
if (r < 0) {
- log_warning_link(link, "DHCP error: no lease %s",
+ log_link_warning(link, "DHCP error: no lease %s",
strerror(-r));
return r;
}
@@ -365,14 +365,14 @@ static int dhcp_lease_renew(sd_dhcp_client *client, Link *link) {
r = sd_dhcp_lease_get_address(lease, &address);
if (r < 0) {
- log_warning_link(link, "DHCP error: no address: %s",
+ log_link_warning(link, "DHCP error: no address: %s",
strerror(-r));
return r;
}
r = sd_dhcp_lease_get_netmask(lease, &netmask);
if (r < 0) {
- log_warning_link(link, "DHCP error: no netmask: %s",
+ log_link_warning(link, "DHCP error: no netmask: %s",
strerror(-r));
return r;
}
@@ -381,7 +381,7 @@ static int dhcp_lease_renew(sd_dhcp_client *client, Link *link) {
r = sd_dhcp_lease_get_lifetime(link->dhcp_lease,
&lifetime);
if (r < 0) {
- log_warning_link(link,
+ log_link_warning(link,
"DHCP error: no lifetime: %s",
strerror(-r));
return r;
@@ -390,7 +390,7 @@ static int dhcp_lease_renew(sd_dhcp_client *client, Link *link) {
r = dhcp4_update_address(link, &address, &netmask, lifetime);
if (r < 0) {
- log_warning_link(link, "could not update IP address: %s",
+ log_link_warning(link, "could not update IP address: %s",
strerror(-r));
link_enter_failed(link);
return r;
@@ -413,21 +413,21 @@ static int dhcp_lease_acquired(sd_dhcp_client *client, Link *link) {
r = sd_dhcp_client_get_lease(client, &lease);
if (r < 0) {
- log_warning_link(link, "DHCP error: no lease: %s",
+ log_link_warning(link, "DHCP error: no lease: %s",
strerror(-r));
return r;
}
r = sd_dhcp_lease_get_address(lease, &address);
if (r < 0) {
- log_warning_link(link, "DHCP error: no address: %s",
+ log_link_warning(link, "DHCP error: no address: %s",
strerror(-r));
return r;
}
r = sd_dhcp_lease_get_netmask(lease, &netmask);
if (r < 0) {
- log_warning_link(link, "DHCP error: no netmask: %s",
+ log_link_warning(link, "DHCP error: no netmask: %s",
strerror(-r));
return r;
}
@@ -436,13 +436,13 @@ static int dhcp_lease_acquired(sd_dhcp_client *client, Link *link) {
r = sd_dhcp_lease_get_router(lease, &gateway);
if (r < 0 && r != -ENOENT) {
- log_warning_link(link, "DHCP error: could not get gateway: %s",
+ log_link_warning(link, "DHCP error: could not get gateway: %s",
strerror(-r));
return r;
}
if (r >= 0)
- log_struct_link(LOG_INFO, link,
+ log_link_struct(LOG_INFO, link,
"MESSAGE=%-*s: DHCPv4 address %u.%u.%u.%u/%u via %u.%u.%u.%u",
IFNAMSIZ,
link->ifname,
@@ -457,7 +457,7 @@ static int dhcp_lease_acquired(sd_dhcp_client *client, Link *link) {
ADDRESS_FMT_VAL(gateway),
NULL);
else
- log_struct_link(LOG_INFO, link,
+ log_link_struct(LOG_INFO, link,
"MESSAGE=%-*s: DHCPv4 address %u.%u.%u.%u/%u",
IFNAMSIZ,
link->ifname,
@@ -478,7 +478,7 @@ static int dhcp_lease_acquired(sd_dhcp_client *client, Link *link) {
if (r >= 0) {
r = link_set_mtu(link, mtu);
if (r < 0)
- log_error_link(link, "Failed to set MTU "
+ log_link_error(link, "Failed to set MTU "
"to %" PRIu16, mtu);
}
}
@@ -490,7 +490,7 @@ static int dhcp_lease_acquired(sd_dhcp_client *client, Link *link) {
if (r >= 0) {
r = link_set_hostname(link, hostname);
if (r < 0)
- log_error_link(link,
+ log_link_error(link,
"Failed to set transient hostname to '%s'",
hostname);
}
@@ -500,7 +500,7 @@ static int dhcp_lease_acquired(sd_dhcp_client *client, Link *link) {
r = sd_dhcp_lease_get_lifetime(link->dhcp_lease,
&lifetime);
if (r < 0) {
- log_warning_link(link,
+ log_link_warning(link,
"DHCP error: no lifetime: %s",
strerror(-r));
return r;
@@ -509,7 +509,7 @@ static int dhcp_lease_acquired(sd_dhcp_client *client, Link *link) {
r = dhcp4_update_address(link, &address, &netmask, lifetime);
if (r < 0) {
- log_warning_link(link, "could not update IP address: %s",
+ log_link_warning(link, "could not update IP address: %s",
strerror(-r));
link_enter_failed(link);
return r;
@@ -533,7 +533,7 @@ static void dhcp4_handler(sd_dhcp_client *client, int event, void *userdata) {
case DHCP_EVENT_STOP:
case DHCP_EVENT_IP_CHANGE:
if (link->network->dhcp_critical) {
- log_error_link(link,
+ log_link_error(link,
"DHCPv4 connection considered system critical, ignoring request to reconfigure it.");
return;
}
@@ -571,11 +571,11 @@ static void dhcp4_handler(sd_dhcp_client *client, int event, void *userdata) {
break;
default:
if (event < 0)
- log_warning_link(link,
+ log_link_warning(link,
"DHCP error: client failed: %s",
strerror(-event));
else
- log_warning_link(link,
+ log_link_warning(link,
"DHCP unknown event: %d",
event);
break;
diff --git a/src/network/networkd-ipv4ll.c b/src/network/networkd-ipv4ll.c
index fd55f79..beac939 100644
--- a/src/network/networkd-ipv4ll.c
+++ b/src/network/networkd-ipv4ll.c
@@ -40,11 +40,11 @@ static int ipv4ll_address_lost(Link *link) {
if (r < 0)
return 0;
- log_debug_link(link, "IPv4 link-local release %u.%u.%u.%u", ADDRESS_FMT_VAL(addr));
+ log_link_debug(link, "IPv4 link-local release %u.%u.%u.%u", ADDRESS_FMT_VAL(addr));
r = address_new_dynamic(&address);
if (r < 0) {
- log_error_link(link, "Could not allocate address: %s", strerror(-r));
+ log_link_error(link, "Could not allocate address: %s", strerror(-r));
return r;
}
@@ -57,7 +57,7 @@ static int ipv4ll_address_lost(Link *link) {
r = route_new_dynamic(&route, RTPROT_UNSPEC);
if (r < 0) {
- log_error_link(link, "Could not allocate route: %s",
+ log_link_error(link, "Could not allocate route: %s",
strerror(-r));
return r;
}
@@ -82,7 +82,7 @@ static int ipv4ll_route_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdat
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -EEXIST) {
- log_error_link(link, "could not set ipv4ll route: %s", strerror(-r));
+ log_link_error(link, "could not set ipv4ll route: %s", strerror(-r));
link_enter_failed(link);
}
@@ -103,7 +103,7 @@ static int ipv4ll_address_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userd
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -EEXIST) {
- log_error_link(link, "could not set ipv4ll address: %s", strerror(-r));
+ log_link_error(link, "could not set ipv4ll address: %s", strerror(-r));
link_enter_failed(link);
} else if (r >= 0) {
/* calling handler directly so take a ref */
@@ -134,7 +134,7 @@ static int ipv4ll_address_claimed(sd_ipv4ll *ll, Link *link) {
else if (r < 0)
return r;
- log_debug_link(link, "IPv4 link-local claim %u.%u.%u.%u",
+ log_link_debug(link, "IPv4 link-local claim %u.%u.%u.%u",
ADDRESS_FMT_VAL(address));
r = address_new_dynamic(&ll_addr);
@@ -199,9 +199,9 @@ static void ipv4ll_handler(sd_ipv4ll *ll, int event, void *userdata){
break;
default:
if (event < 0)
- log_warning_link(link, "IPv4 link-local error: %s", strerror(-event));
+ log_link_warning(link, "IPv4 link-local error: %s", strerror(-event));
else
- log_warning_link(link, "IPv4 link-local unknown event: %d", event);
+ log_link_warning(link, "IPv4 link-local unknown event: %d", event);
break;
}
}
diff --git a/src/network/networkd-link.c b/src/network/networkd-link.c
index fcfbd3e..b46ac5c 100644
--- a/src/network/networkd-link.c
+++ b/src/network/networkd-link.c
@@ -89,7 +89,7 @@ static int link_update_flags(Link *link, sd_rtnl_message *m) {
r = sd_rtnl_message_link_get_flags(m, &flags);
if (r < 0) {
- log_warning_link(link, "Could not get link flags");
+ log_link_warning(link, "Could not get link flags");
return r;
}
@@ -103,7 +103,7 @@ static int link_update_flags(Link *link, sd_rtnl_message *m) {
return 0;
if (link->flags != flags) {
- log_debug_link(link, "flags change:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
+ log_link_debug(link, "flags change:%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s",
FLAG_STRING("LOOPBACK", IFF_LOOPBACK, link->flags, flags),
FLAG_STRING("MASTER", IFF_MASTER, link->flags, flags),
FLAG_STRING("SLAVE", IFF_SLAVE, link->flags, flags),
@@ -136,12 +136,12 @@ static int link_update_flags(Link *link, sd_rtnl_message *m) {
/* link flags are currently at most 18 bits, let's align to
* printing 20 */
if (unknown_flags_added)
- log_debug_link(link,
+ log_link_debug(link,
"unknown link flags gained: %#.5x (ignoring)",
unknown_flags_added);
if (unknown_flags_removed)
- log_debug_link(link,
+ log_link_debug(link,
"unknown link flags lost: %#.5x (ignoring)",
unknown_flags_removed);
}
@@ -194,7 +194,7 @@ static int link_new(Manager *manager, sd_rtnl_message *message, Link **ret) {
r = sd_rtnl_message_read_ether_addr(message, IFLA_ADDRESS, &link->mac);
if (r < 0)
- log_debug_link(link, "MAC address not found for new device, continuing without");
+ log_link_debug(link, "MAC address not found for new device, continuing without");
r = asprintf(&link->state_file, "/run/systemd/netif/links/%d",
link->ifindex);
@@ -299,7 +299,7 @@ void link_drop(Link *link) {
link->state = LINK_STATE_LINGER;
- log_debug_link(link, "link removed");
+ log_link_debug(link, "link removed");
link_unref(link);
@@ -309,7 +309,7 @@ void link_drop(Link *link) {
static void link_enter_unmanaged(Link *link) {
assert(link);
- log_debug_link(link, "unmanaged");
+ log_link_debug(link, "unmanaged");
link->state = LINK_STATE_UNMANAGED;
@@ -329,7 +329,7 @@ static int link_stop_clients(Link *link) {
if (link->dhcp_client) {
k = sd_dhcp_client_stop(link->dhcp_client);
if (k < 0) {
- log_warning_link(link, "Could not stop DHCPv4 client: %s",
+ log_link_warning(link, "Could not stop DHCPv4 client: %s",
strerror(-r));
r = k;
}
@@ -338,7 +338,7 @@ static int link_stop_clients(Link *link) {
if (link->ipv4ll) {
k = sd_ipv4ll_stop(link->ipv4ll);
if (k < 0) {
- log_warning_link(link, "Could not stop IPv4 link-local: %s",
+ log_link_warning(link, "Could not stop IPv4 link-local: %s",
strerror(-r));
r = k;
}
@@ -349,7 +349,7 @@ static int link_stop_clients(Link *link) {
if (link->dhcp6_client) {
k = sd_dhcp6_client_stop(link->dhcp6_client);
if (k < 0) {
- log_warning_link(link, "Could not stop DHCPv6 client: %s",
+ log_link_warning(link, "Could not stop DHCPv6 client: %s",
strerror(-r));
r = k;
}
@@ -357,7 +357,7 @@ static int link_stop_clients(Link *link) {
k = sd_icmp6_nd_stop(link->icmp6_router_discovery);
if (k < 0) {
- log_warning_link(link,
+ log_link_warning(link,
"Could not stop ICMPv6 router discovery: %s",
strerror(-r));
r = k;
@@ -373,7 +373,7 @@ void link_enter_failed(Link *link) {
if (IN_SET(link->state, LINK_STATE_FAILED, LINK_STATE_LINGER))
return;
- log_warning_link(link, "failed");
+ log_link_warning(link, "failed");
link->state = LINK_STATE_FAILED;
@@ -425,13 +425,13 @@ static int link_enter_configured(Link *link) {
address = link_find_dhcp_server_address(link);
if (!address) {
- log_warning_link(link,
+ log_link_warning(link,
"Failed to find suitable address for DHCPv4 server instance.");
link_enter_failed(link);
return 0;
}
- log_debug_link(link, "offering DHCPv4 leases");
+ log_link_debug(link, "offering DHCPv4 leases");
r = sd_dhcp_server_set_address(link->dhcp_server,
&address->in_addr.in,
@@ -460,7 +460,7 @@ static int link_enter_configured(Link *link) {
r = sd_dhcp_server_start(link->dhcp_server);
if (r < 0) {
- log_warning_link(link, "could not start DHCPv4 server "
+ log_link_warning(link, "could not start DHCPv4 server "
"instance: %s", strerror(-r));
link_enter_failed(link);
@@ -469,7 +469,7 @@ static int link_enter_configured(Link *link) {
}
}
- log_info_link(link, "link configured");
+ log_link_info(link, "link configured");
link->state = LINK_STATE_CONFIGURED;
@@ -515,7 +515,7 @@ static int route_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -EEXIST)
- log_struct_link(LOG_WARNING, link,
+ log_link_struct(LOG_WARNING, link,
"MESSAGE=%-*s: could not set route: %s",
IFNAMSIZ,
link->ifname, strerror(-r),
@@ -523,7 +523,7 @@ static int route_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
NULL);
if (link->link_messages == 0) {
- log_debug_link(link, "routes set");
+ log_link_debug(link, "routes set");
link->static_configured = true;
link_client_handler(link);
}
@@ -544,7 +544,7 @@ static int link_enter_set_routes(Link *link) {
LIST_FOREACH(routes, rt, link->network->static_routes) {
r = route_configure(rt, link, &route_handler);
if (r < 0) {
- log_warning_link(link,
+ log_link_warning(link,
"could not set routes: %s",
strerror(-r));
link_enter_failed(link);
@@ -558,7 +558,7 @@ static int link_enter_set_routes(Link *link) {
link->static_configured = true;
link_client_handler(link);
} else
- log_debug_link(link, "setting routes");
+ log_link_debug(link, "setting routes");
return 0;
}
@@ -576,7 +576,7 @@ int link_route_drop_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -ESRCH)
- log_struct_link(LOG_WARNING, link,
+ log_link_struct(LOG_WARNING, link,
"MESSAGE=%-*s: could not drop route: %s",
IFNAMSIZ,
link->ifname, strerror(-r),
@@ -598,14 +598,14 @@ int link_get_address_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata)
for (; m; m = sd_rtnl_message_next(m)) {
r = sd_rtnl_message_get_errno(m);
if (r < 0) {
- log_debug_link(link, "getting address failed: %s",
+ log_link_debug(link, "getting address failed: %s",
strerror(-r));
continue;
}
r = link_rtnl_process_address(rtnl, m, link->manager);
if (r < 0)
- log_warning_link(link, "could not process address: %s",
+ log_link_warning(link, "could not process address: %s",
strerror(-r));
}
@@ -631,7 +631,7 @@ static int address_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -EEXIST)
- log_struct_link(LOG_WARNING, link,
+ log_link_struct(LOG_WARNING, link,
"MESSAGE=%-*s: could not set address: %s",
IFNAMSIZ,
link->ifname, strerror(-r),
@@ -644,7 +644,7 @@ static int address_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
}
if (link->link_messages == 0) {
- log_debug_link(link, "addresses set");
+ log_link_debug(link, "addresses set");
link_enter_set_routes(link);
}
@@ -664,7 +664,7 @@ static int link_enter_set_addresses(Link *link) {
LIST_FOREACH(addresses, ad, link->network->static_addresses) {
r = address_configure(ad, link, &address_handler);
if (r < 0) {
- log_warning_link(link,
+ log_link_warning(link,
"could not set addresses: %s",
strerror(-r));
link_enter_failed(link);
@@ -677,7 +677,7 @@ static int link_enter_set_addresses(Link *link) {
if (link->link_messages == 0) {
link_enter_set_routes(link);
} else
- log_debug_link(link, "setting addresses");
+ log_link_debug(link, "setting addresses");
return 0;
}
@@ -695,7 +695,7 @@ int link_address_drop_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata)
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -EADDRNOTAVAIL)
- log_struct_link(LOG_WARNING, link,
+ log_link_struct(LOG_WARNING, link,
"MESSAGE=%-*s: could not drop address: %s",
IFNAMSIZ,
link->ifname, strerror(-r),
@@ -717,7 +717,7 @@ static int set_hostname_handler(sd_bus *bus, sd_bus_message *m, void *userdata,
r = sd_bus_message_get_errno(m);
if (r > 0)
- log_warning_link(link, "Could not set hostname: %s",
+ log_link_warning(link, "Could not set hostname: %s",
strerror(r));
return 1;
@@ -731,11 +731,11 @@ int link_set_hostname(Link *link, const char *hostname) {
assert(link->manager);
assert(hostname);
- log_debug_link(link, "Setting transient hostname: '%s'", hostname);
+ log_link_debug(link, "Setting transient hostname: '%s'", hostname);
if (!link->manager->bus) {
/* TODO: replace by assert when we can rely on kdbus */
- log_info_link(link,
+ log_link_info(link,
"Not connected to system bus, ignoring transient hostname.");
return 0;
}
@@ -757,7 +757,7 @@ int link_set_hostname(Link *link, const char *hostname) {
r = sd_bus_call_async(link->manager->bus, NULL, m, set_hostname_handler,
link, 0);
if (r < 0) {
- log_error_link(link, "Could not set transient hostname: %s",
+ log_link_error(link, "Could not set transient hostname: %s",
strerror(-r));
return r;
}
@@ -780,7 +780,7 @@ static int set_mtu_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
r = sd_rtnl_message_get_errno(m);
if (r < 0)
- log_struct_link(LOG_WARNING, link,
+ log_link_struct(LOG_WARNING, link,
"MESSAGE=%-*s: could not set MTU: %s",
IFNAMSIZ, link->ifname, strerror(-r),
"ERRNO=%d", -r,
@@ -797,25 +797,25 @@ int link_set_mtu(Link *link, uint32_t mtu) {
assert(link->manager);
assert(link->manager->rtnl);
- log_debug_link(link, "setting MTU: %" PRIu32, mtu);
+ log_link_debug(link, "setting MTU: %" PRIu32, mtu);
r = sd_rtnl_message_new_link(link->manager->rtnl, &req,
RTM_SETLINK, link->ifindex);
if (r < 0) {
- log_error_link(link, "Could not allocate RTM_SETLINK message");
+ log_link_error(link, "Could not allocate RTM_SETLINK message");
return r;
}
r = sd_rtnl_message_append_u32(req, IFLA_MTU, mtu);
if (r < 0) {
- log_error_link(link, "Could not append MTU: %s", strerror(-r));
+ log_link_error(link, "Could not append MTU: %s", strerror(-r));
return r;
}
r = sd_rtnl_call_async(link->manager->rtnl, req, set_mtu_handler, link,
0, NULL);
if (r < 0) {
- log_error_link(link,
+ log_link_error(link,
"Could not send rtnetlink message: %s",
strerror(-r));
return r;
@@ -841,16 +841,16 @@ static void dhcp6_handler(sd_dhcp6_client *client, int event, void *userdata) {
case DHCP6_EVENT_RESEND_EXPIRE:
case DHCP6_EVENT_RETRANS_MAX:
case DHCP6_EVENT_IP_ACQUIRE:
- log_debug_link(link, "DHCPv6 event %d", event);
+ log_link_debug(link, "DHCPv6 event %d", event);
break;
default:
if (event < 0)
- log_warning_link(link, "DHCPv6 error: %s",
+ log_link_warning(link, "DHCPv6 error: %s",
strerror(-event));
else
- log_warning_link(link, "DHCPv6 unknown event: %d",
+ log_link_warning(link, "DHCPv6 unknown event: %d",
event);
return;
}
@@ -878,10 +878,10 @@ static void icmp6_router_handler(sd_icmp6_nd *nd, int event, void *userdata) {
default:
if (event < 0)
- log_warning_link(link, "ICMPv6 error: %s",
+ log_link_warning(link, "ICMPv6 error: %s",
strerror(-event));
else
- log_warning_link(link, "ICMPv6 unknown event: %d",
+ log_link_warning(link, "ICMPv6 unknown event: %d",
event);
return;
@@ -937,11 +937,11 @@ static int link_acquire_conf(Link *link) {
if (link_ipv4ll_enabled(link)) {
assert(link->ipv4ll);
- log_debug_link(link, "acquiring IPv4 link-local address");
+ log_link_debug(link, "acquiring IPv4 link-local address");
r = sd_ipv4ll_start(link->ipv4ll);
if (r < 0) {
- log_warning_link(link, "could not acquire IPv4 "
+ log_link_warning(link, "could not acquire IPv4 "
"link-local address");
return r;
}
@@ -950,11 +950,11 @@ static int link_acquire_conf(Link *link) {
if (link_dhcp4_enabled(link)) {
assert(link->dhcp_client);
- log_debug_link(link, "acquiring DHCPv4 lease");
+ log_link_debug(link, "acquiring DHCPv4 lease");
r = sd_dhcp_client_start(link->dhcp_client);
if (r < 0) {
- log_warning_link(link, "could not acquire DHCPv4 "
+ log_link_warning(link, "could not acquire DHCPv4 "
"lease");
return r;
}
@@ -963,11 +963,11 @@ static int link_acquire_conf(Link *link) {
if (link_dhcp6_enabled(link)) {
assert(link->icmp6_router_discovery);
- log_debug_link(link, "discovering IPv6 routers");
+ log_link_debug(link, "discovering IPv6 routers");
r = sd_icmp6_router_solicitation_start(link->icmp6_router_discovery);
if (r < 0) {
- log_warning_link(link,
+ log_link_warning(link,
"could not start IPv6 router discovery");
return r;
}
@@ -1003,7 +1003,7 @@ static int link_up_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) {
if (r < 0) {
/* we warn but don't fail the link, as it may
be brought up later */
- log_struct_link(LOG_WARNING, link,
+ log_link_struct(LOG_WARNING, link,
"MESSAGE=%-*s: could not bring up interface: %s",
IFNAMSIZ,
link->ifname, strerror(-r),
@@ -1022,18 +1022,18 @@ static int link_up(Link *link) {
assert(link->manager);
assert(link->manager->rtnl);
- log_debug_link(link, "bringing link up");
+ log_link_debug(link, "bringing link up");
r = sd_rtnl_message_new_link(link->manager->rtnl, &req,
RTM_SETLINK, link->ifindex);
if (r < 0) {
- log_error_link(link, "Could not allocate RTM_SETLINK message");
+ log_link_error(link, "Could not allocate RTM_SETLINK message");
return r;
}
r = sd_rtnl_message_link_set_flags(req, IFF_UP, IFF_UP);
if (r < 0) {
- log_error_link(link, "Could not set link flags: %s",
+ log_link_error(link, "Could not set link flags: %s",
strerror(-r));
return r;
}
@@ -1041,7 +1041,7 @@ static int link_up(Link *link) {
r = sd_rtnl_call_async(link->manager->rtnl, req, link_up_handler, link,
0, NULL);
if (r < 0) {
- log_error_link(link,
+ log_link_error(link,
"Could not send rtnetlink message: %s",
strerror(-r));
return r;
@@ -1084,7 +1084,7 @@ static int netdev_join_handler(sd_rtnl *rtnl, sd_rtnl_message *m,
r = sd_rtnl_message_get_errno(m);
if (r < 0 && r != -EEXIST) {
- log_struct_link(LOG_ERR, link,
+ log_link_struct(LOG_ERR, link,
"MESSAGE=%-*s: could not join netdev: %s",
IFNAMSIZ,
link->ifname, strerror(-r),
@@ -1093,7 +1093,7 @@ static int netdev_join_handler(sd_rtnl *rtnl, sd_rtnl_message *m,
link_enter_failed(link);
return 1;
} else
- log_debug_link(link, "joined netdev");
+ log_link_debug(link, "joined netdev");
if (link->enslaving <= 0)
link_joined(link);
@@ -1120,7 +1120,7 @@ static int link_enter_join_netdev(Link *link) {
return link_joined(link);
if (link->network->bond) {
- log_struct_link(LOG_DEBUG, link,
+ log_link_struct(LOG_DEBUG, link,
"MESSAGE=%-*s: enslaving by '%s'",
IFNAMSIZ,
link->ifname, link->network->bond->ifname,
@@ -1129,7 +1129,7 @@ static int link_enter_join_netdev(Link *link) {
r = netdev_join(link->network->bond, link, &netdev_join_handler);
if (r < 0) {
- log_struct_link(LOG_WARNING, link,
+ log_link_struct(LOG_WARNING, link,
"MESSAGE=%-*s: could not join netdev '%s': %s",
IFNAMSIZ,
link->ifname, link->network->bond->ifname,
@@ -1144,7 +1144,7 @@ static int link_enter_join_netdev(Link *link) {
}
if (link->network->bridge) {
- log_struct_link(LOG_DEBUG, link,
+ log_link_struct(LOG_DEBUG, link,
"MESSAGE=%-*s: enslaving by '%s'",
IFNAMSIZ,
link->ifname, link->network->bridge->ifname,
@@ -1154,7 +1154,7 @@ static int link_enter_join_netdev(Link *link) {
r = netdev_join(link->network->bridge, link,
&netdev_join_handler);
if (r < 0) {
- log_struct_link(LOG_WARNING, link,
+ log_link_struct(LOG_WARNING, link,
"MESSAGE=%-*s: could not join netdev '%s': %s",
IFNAMSIZ,
link->ifname, link->network->bridge->ifname,
@@ -1169,7 +1169,7 @@ static int link_enter_join_netdev(Link *link) {
}
HASHMAP_FOREACH(netdev, link->network->stacked_netdevs, i) {
- log_struct_link(LOG_DEBUG, link,
+ log_link_struct(LOG_DEBUG, link,
"MESSAGE=%-*s: enslaving by '%s'",
IFNAMSIZ,
link->ifname, netdev->ifname, NETDEVIF(netdev),
@@ -1177,7 +1177,7 @@ static int link_enter_join_netdev(Link *link) {
r = netdev_join(netdev, link, &netdev_join_handler);
if (r < 0) {
- log_struct_link(LOG_WARNING, link,
+ log_link_struct(LOG_WARNING, link,
"MESSAGE=%-*s: could not join netdev '%s': %s",
IFNAMSIZ,
link->ifname, netdev->ifname,
@@ -1270,7 +1270,7 @@ static int link_initialized_and_synced(sd_rtnl *rtnl, sd_rtnl_message *m,
if (link->state != LINK_STATE_PENDING)
return 1;
- log_debug_link(link, "link state is up-to-date");
+ log_link_debug(link, "link state is up-to-date");
r = network_get(link->manager, link->udev_device, link->ifname,
&link->mac, &network);
@@ -1282,13 +1282,13 @@ static int link_initialized_and_synced(sd_rtnl *rtnl, sd_rtnl_message *m,
if (link->flags & IFF_LOOPBACK) {
if (network->ipv4ll)
- log_debug_link(link, "ignoring IPv4LL for loopback link");
+ log_link_debug(link, "ignoring IPv4LL for loopback link");
if (network->dhcp != DHCP_SUPPORT_NONE)
- log_debug_link(link, "ignoring DHCP clients for loopback link");
+ log_link_debug(link, "ignoring DHCP clients for loopback link");
if (network->dhcp_server)
- log_debug_link(link, "ignoring DHCP server for loopback link");
+ log_link_debug(link, "ignoring DHCP server for loopback link");
}
r = network_apply(link->manager, network, link);
@@ -1317,7 +1317,7 @@ int link_initialized(Link *link, struct udev_device *device) {
if (link->udev_device)
return 0;
- log_debug_link(link, "udev initialized link");
+ log_link_debug(link, "udev initialized link");
link->udev_device = udev_device_ref(device);
@@ -1382,28 +1382,28 @@ int link_rtnl_process_address(sd_rtnl *rtnl, sd_rtnl_message *message,
r = sd_rtnl_message_addr_get_family(message, &address->family);
if (r < 0 || !IN_SET(address->family, AF_INET, AF_INET6)) {
- log_warning_link(link,
+ log_link_warning(link,
"rtnl: received address with invalid family, ignoring");
return 0;
}
r = sd_rtnl_message_addr_get_prefixlen(message, &address->prefixlen);
if (r < 0) {
- log_warning_link(link,
+ log_link_warning(link,
"rtnl: received address with invalid prefixlen, ignoring");
return 0;
}
r = sd_rtnl_message_addr_get_scope(message, &address->scope);
if (r < 0) {
- log_warning_link(link,
+ log_link_warning(link,
"rtnl: received address with invalid scope, ignoring");
return 0;
}
r = sd_rtnl_message_addr_get_flags(message, &address->flags);
if (r < 0) {
- log_warning_link(link,
+ log_link_warning(link,
"rtnl: received address with invalid flags, ignoring");
return 0;
}
@@ -1413,7 +1413,7 @@ int link_rtnl_process_address(sd_rtnl *rtnl, sd_rtnl_message *message,
r = sd_rtnl_message_read_in_addr(message, IFA_LOCAL,
&address->in_addr.in);
if (r < 0) {
- log_warning_link(link,
+ log_link_warning(link,
"rtnl: received address without valid address, ignoring");
return 0;
}
@@ -1424,7 +1424,7 @@ int link_rtnl_process_address(sd_rtnl *rtnl, sd_rtnl_message *message,
r = sd_rtnl_message_read_in6_addr(message, IFA_ADDRESS,
&address->in_addr.in6);
if (r < 0) {
- log_warning_link(link,
+ log_link_warning(link,
"rtnl: received address without valid address, ignoring");
return 0;
}
@@ -1437,7 +1437,7 @@ int link_rtnl_process_address(sd_rtnl *rtnl, sd_rtnl_message *message,
if (!inet_ntop(address->family, &address->in_addr, buf,
INET6_ADDRSTRLEN)) {
- log_warning_link(link, "could not print address");
+ log_link_warning(link, "could not print address");
return 0;
}
@@ -1467,10 +1467,10 @@ int link_rtnl_process_address(sd_rtnl *rtnl, sd_rtnl_message *message,
switch (type) {
case RTM_NEWADDR:
if (!address_dropped)
- log_debug_link(link, "added address: %s/%u (valid for %s)",
+ log_link_debug(link, "added address: %s/%u (valid for %s)",
buf, address->prefixlen, valid_str);
else
- log_debug_link(link, "updated address: %s/%u (valid for %s)",
+ log_link_debug(link, "updated address: %s/%u (valid for %s)",
buf, address->prefixlen, valid_str);
LIST_PREPEND(addresses, link->addresses, address);
@@ -1481,12 +1481,12 @@ int link_rtnl_process_address(sd_rtnl *rtnl, sd_rtnl_message *message,
break;
case RTM_DELADDR:
if (address_dropped) {
- log_debug_link(link, "removed address: %s/%u (valid for %s)",
+ log_link_debug(link, "removed address: %s/%u (valid for %s)",
buf, address->prefixlen, valid_str);
link_save(link);
} else
- log_warning_link(link,
+ log_link_warning(link,
"removing non-existent address: %s/%u (valid for %s)",
buf, address->prefixlen, valid_str);
@@ -1516,7 +1516,7 @@ int link_add(Manager *m, sd_rtnl_message *message, Link **ret) {
link = *ret;
- log_debug_link(link, "link %d added", link->ifindex);
+ log_link_debug(link, "link %d added", link->ifindex);
r = sd_rtnl_message_new_addr(m->rtnl, &req, RTM_GETADDR, link->ifindex,
0);
@@ -1535,14 +1535,14 @@ int link_add(Manager *m, sd_rtnl_message *message, Link **ret) {
sprintf(ifindex_str, "n%d", link->ifindex);
device = udev_device_new_from_device_id(m->udev, ifindex_str);
if (!device) {
- log_warning_link(link,
+ log_link_warning(link,
"could not find udev device: %m");
return -errno;
}
if (udev_device_get_is_initialized(device) <= 0) {
/* not yet ready */
- log_debug_link(link, "link pending udev initialization...");
+ log_link_debug(link, "link pending udev initialization...");
return 0;
}
@@ -1574,13 +1574,13 @@ int link_update(Link *link, sd_rtnl_message *m) {
if (link->state == LINK_STATE_LINGER) {
link_ref(link);
- log_info_link(link, "link readded");
+ log_link_info(link, "link readded");
link->state = LINK_STATE_ENSLAVING;
}
r = sd_rtnl_message_read_string(m, IFLA_IFNAME, &ifname);
if (r >= 0 && !streq(ifname, link->ifname)) {
- log_info_link(link, "renamed to %s", ifname);
+ log_link_info(link, "renamed to %s", ifname);
free(link->ifname);
link->ifname = strdup(ifname);
@@ -1593,7 +1593,7 @@ int link_update(Link *link, sd_rtnl_message *m) {
link->mtu = mtu;
if (!link->original_mtu) {
link->original_mtu = mtu;
- log_debug_link(link, "saved original MTU: %"
+ log_link_debug(link, "saved original MTU: %"
PRIu32, link->original_mtu);
}
@@ -1601,7 +1601,7 @@ int link_update(Link *link, sd_rtnl_message *m) {
r = sd_dhcp_client_set_mtu(link->dhcp_client,
link->mtu);
if (r < 0) {
- log_warning_link(link,
+ log_link_warning(link,
"Could not update MTU in DHCP client: %s",
strerror(-r));
return r;
@@ -1619,7 +1619,7 @@ int link_update(Link *link, sd_rtnl_message *m) {
memcpy(link->mac.ether_addr_octet, mac.ether_addr_octet,
ETH_ALEN);
- log_debug_link(link, "MAC address: "
+ log_link_debug(link, "MAC address: "
"%02hhx:%02hhx:%02hhx:%02hhx:%02hhx:%02hhx",
mac.ether_addr_octet[0],
mac.ether_addr_octet[1],
@@ -1631,7 +1631,7 @@ int link_update(Link *link, sd_rtnl_message *m) {
if (link->ipv4ll) {
r = sd_ipv4ll_set_mac(link->ipv4ll, &link->mac);
if (r < 0) {
- log_warning_link(link,
+ log_link_warning(link,
"Could not update MAC address in IPv4LL client: %s",
strerror(-r));
return r;
@@ -1644,7 +1644,7 @@ int link_update(Link *link, sd_rtnl_message *m) {
sizeof (link->mac),
ARPHRD_ETHER);
if (r < 0) {
- log_warning_link(link,
+ log_link_warning(link,
"Could not update MAC address in DHCP client: %s",
strerror(-r));
return r;
@@ -1657,7 +1657,7 @@ int link_update(Link *link, sd_rtnl_message *m) {
sizeof (link->mac),
ARPHRD_ETHER);
if (r < 0) {
- log_warning_link(link,
+ log_link_warning(link,
"Could not update MAC address in DHCPv6 client: %s",
strerror(-r));
return r;
@@ -1676,7 +1676,7 @@ int link_update(Link *link, sd_rtnl_message *m) {
carrier_lost = had_carrier && !link_has_carrier(link);
if (carrier_gained) {
- log_info_link(link, "gained carrier");
+ log_link_info(link, "gained carrier");
if (link->network) {
r = link_acquire_conf(link);
@@ -1686,7 +1686,7 @@ int link_update(Link *link, sd_rtnl_message *m) {
}
}
} else if (carrier_lost) {
- log_info_link(link, "lost carrier");
+ log_link_info(link, "lost carrier");
r = link_stop_clients(link);
if (r < 0) {
@@ -1878,7 +1878,7 @@ int link_save(Link *link) {
return 0;
fail:
- log_error_link(link, "Failed to save link data to %s: %s", link->state_file, strerror(-r));
+ log_link_error(link, "Failed to save link data to %s: %s", link->state_file, strerror(-r));
unlink(link->state_file);
unlink(temp_path);
return r;
diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h
index 5eb4b88..61cdbf3 100644
--- a/src/network/networkd-link.h
+++ b/src/network/networkd-link.h
@@ -132,14 +132,14 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_unref);
/* Macros which append INTERFACE= to the message */
-#define log_full_link(level, link, fmt, ...) log_meta_object(level, 0, __FILE__, __LINE__, __func__, "INTERFACE=", link->ifname, "%-*s: " fmt, IFNAMSIZ, link->ifname, ##__VA_ARGS__)
-#define log_debug_link(link, ...) log_full_link(LOG_DEBUG, link, ##__VA_ARGS__)
-#define log_info_link(link, ...) log_full_link(LOG_INFO, link, ##__VA_ARGS__)
-#define log_notice_link(link, ...) log_full_link(LOG_NOTICE, link, ##__VA_ARGS__)
-#define log_warning_link(link, ...) log_full_link(LOG_WARNING, link, ##__VA_ARGS__)
-#define log_error_link(link, ...) log_full_link(LOG_ERR, link, ##__VA_ARGS__)
-
-#define log_struct_link(level, link, ...) log_struct(level, "INTERFACE=%s", link->ifname, __VA_ARGS__)
+#define log_link_full(level, link, fmt, ...) log_object_internal(level, 0, __FILE__, __LINE__, __func__, "INTERFACE=", link->ifname, "%-*s: " fmt, IFNAMSIZ, link->ifname, ##__VA_ARGS__)
+#define log_link_debug(link, ...) log_link_full(LOG_DEBUG, link, ##__VA_ARGS__)
+#define log_link_info(link, ...) log_link_full(LOG_INFO, link, ##__VA_ARGS__)
+#define log_link_notice(link, ...) log_link_full(LOG_NOTICE, link, ##__VA_ARGS__)
+#define log_link_warning(link, ...) log_link_full(LOG_WARNING, link, ##__VA_ARGS__)
+#define log_link_error(link, ...) log_link_full(LOG_ERR, link, ##__VA_ARGS__)
+
+#define log_link_struct(level, link, ...) log_struct(level, "INTERFACE=%s", link->ifname, __VA_ARGS__)
#define ADDRESS_FMT_VAL(address) \
(address).s_addr & 0xFF, \
diff --git a/src/network/networkd-netdev-bond.c b/src/network/networkd-netdev-bond.c
index 4640821..88321ef 100644
--- a/src/network/networkd-netdev-bond.c
+++ b/src/network/networkd-netdev-bond.c
@@ -116,7 +116,7 @@ static int netdev_bond_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m
r = sd_rtnl_message_append_u8(m, IFLA_BOND_MODE,
bond_mode_to_kernel(b->mode));
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_BOND_MODE attribute: %s",
strerror(-r));
return r;
@@ -127,7 +127,7 @@ static int netdev_bond_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m
r = sd_rtnl_message_append_u8(m, IFLA_BOND_XMIT_HASH_POLICY,
bond_xmit_hash_policy_to_kernel(b->xmit_hash_policy));
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_BOND_XMIT_HASH_POLICY attribute: %s",
strerror(-r));
return r;
@@ -138,7 +138,7 @@ static int netdev_bond_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m
b->mode == NETDEV_BOND_MODE_802_3AD) {
r = sd_rtnl_message_append_u8(m, IFLA_BOND_AD_LACP_RATE, b->lacp_rate );
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_BOND_AD_LACP_RATE attribute: %s",
strerror(-r));
return r;
@@ -148,7 +148,7 @@ static int netdev_bond_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m
if (b->miimon != 0) {
r = sd_rtnl_message_append_u32(m, IFLA_BOND_MIIMON, b->miimon / USEC_PER_MSEC);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_BOND_BOND_MIIMON attribute: %s",
strerror(-r));
return r;
@@ -158,7 +158,7 @@ static int netdev_bond_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m
if (b->downdelay != 0) {
r = sd_rtnl_message_append_u32(m, IFLA_BOND_DOWNDELAY, b->downdelay / USEC_PER_MSEC);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_BOND_DOWNDELAY attribute: %s",
strerror(-r));
return r;
@@ -168,7 +168,7 @@ static int netdev_bond_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m
if (b->updelay != 0) {
r = sd_rtnl_message_append_u32(m, IFLA_BOND_UPDELAY, b->updelay / USEC_PER_MSEC);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_BOND_UPDELAY attribute: %s",
strerror(-r));
return r;
diff --git a/src/network/networkd-netdev-macvlan.c b/src/network/networkd-netdev-macvlan.c
index 2e5554a..198fb57 100644
--- a/src/network/networkd-netdev-macvlan.c
+++ b/src/network/networkd-netdev-macvlan.c
@@ -48,7 +48,7 @@ static int netdev_macvlan_fill_message_create(NetDev *netdev, Link *link, sd_rtn
if (m->mode != _NETDEV_MACVLAN_MODE_INVALID) {
r = sd_rtnl_message_append_u32(req, IFLA_MACVLAN_MODE, m->mode);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_MACVLAN_MODE attribute: %s",
strerror(-r));
return r;
diff --git a/src/network/networkd-netdev-tunnel.c b/src/network/networkd-netdev-tunnel.c
index e5981a4..980c70e 100644
--- a/src/network/networkd-netdev-tunnel.c
+++ b/src/network/networkd-netdev-tunnel.c
@@ -45,7 +45,7 @@ static int netdev_ipip_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m
r = sd_rtnl_message_append_u32(m, IFLA_IPTUN_LINK, link->ifindex);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_IPTUN_LINK attribute: %s",
strerror(-r));
return r;
@@ -53,7 +53,7 @@ static int netdev_ipip_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m
r = sd_rtnl_message_append_in_addr(m, IFLA_IPTUN_LOCAL, &t->local.in);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_IPTUN_LOCAL attribute: %s",
strerror(-r));
return r;
@@ -61,7 +61,7 @@ static int netdev_ipip_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m
r = sd_rtnl_message_append_in_addr(m, IFLA_IPTUN_REMOTE, &t->remote.in);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_IPTUN_REMOTE attribute: %s",
strerror(-r));
return r;
@@ -69,7 +69,7 @@ static int netdev_ipip_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m
r = sd_rtnl_message_append_u8(m, IFLA_IPTUN_TTL, t->ttl);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_IPTUN_TTL attribute: %s",
strerror(-r));
return r;
@@ -77,7 +77,7 @@ static int netdev_ipip_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m
r = sd_rtnl_message_append_u8(m, IFLA_IPTUN_PMTUDISC, t->pmtudisc);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_IPTUN_PMTUDISC attribute: %s",
strerror(-r));
return r;
@@ -98,7 +98,7 @@ static int netdev_sit_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_me
r = sd_rtnl_message_append_u32(m, IFLA_IPTUN_LINK, link->ifindex);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_IPTUN_LINK attribute: %s",
strerror(-r));
return r;
@@ -106,7 +106,7 @@ static int netdev_sit_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_me
r = sd_rtnl_message_append_in_addr(m, IFLA_IPTUN_LOCAL, &t->local.in);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_IPTUN_LOCAL attribute: %s",
strerror(-r));
return r;
@@ -114,7 +114,7 @@ static int netdev_sit_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_me
r = sd_rtnl_message_append_in_addr(m, IFLA_IPTUN_REMOTE, &t->remote.in);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_IPTUN_REMOTE attribute: %s",
strerror(-r));
return r;
@@ -122,7 +122,7 @@ static int netdev_sit_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_me
r = sd_rtnl_message_append_u8(m, IFLA_IPTUN_TTL, t->ttl);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_IPTUN_TTL attribute: %s",
strerror(-r));
return r;
@@ -130,7 +130,7 @@ static int netdev_sit_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_me
r = sd_rtnl_message_append_u8(m, IFLA_IPTUN_PMTUDISC, t->pmtudisc);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_IPTUN_PMTUDISC attribute: %s",
strerror(-r));
return r;
@@ -151,7 +151,7 @@ static int netdev_gre_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_me
r = sd_rtnl_message_append_u32(m, IFLA_GRE_LINK, link->ifindex);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_GRE_LINK attribute: %s",
strerror(-r));
return r;
@@ -159,7 +159,7 @@ static int netdev_gre_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_me
r = sd_rtnl_message_append_in_addr(m, IFLA_GRE_LOCAL, &t->local.in);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_GRE_LOCAL attribute: %s",
strerror(-r));
return r;
@@ -167,7 +167,7 @@ static int netdev_gre_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_me
r = sd_rtnl_message_append_in_addr(m, IFLA_GRE_REMOTE, &t->remote.in);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_GRE_REMOTE attribute: %s",
strerror(-r));
return r;
@@ -175,7 +175,7 @@ static int netdev_gre_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_me
r = sd_rtnl_message_append_u8(m, IFLA_GRE_TTL, t->ttl);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_GRE_TTL attribute: %s",
strerror(-r));
return r;
@@ -183,7 +183,7 @@ static int netdev_gre_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_me
r = sd_rtnl_message_append_u8(m, IFLA_GRE_TOS, t->tos);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_GRE_TOS attribute: %s",
strerror(-r));
return r;
@@ -191,7 +191,7 @@ static int netdev_gre_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_me
r = sd_rtnl_message_append_u8(m, IFLA_GRE_PMTUDISC, t->pmtudisc);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_GRE_PMTUDISC attribute: %s",
strerror(-r));
return r;
@@ -212,7 +212,7 @@ static int netdev_vti_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_me
r = sd_rtnl_message_append_u32(m, IFLA_VTI_LINK, link->ifindex);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_IPTUN_LINK attribute: %s",
strerror(-r));
return r;
@@ -220,7 +220,7 @@ static int netdev_vti_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_me
r = sd_rtnl_message_append_in_addr(m, IFLA_VTI_LOCAL, &t->local.in);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_IPTUN_LOCAL attribute: %s",
strerror(-r));
return r;
@@ -228,7 +228,7 @@ static int netdev_vti_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_me
r = sd_rtnl_message_append_in_addr(m, IFLA_VTI_REMOTE, &t->remote.in);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_IPTUN_REMOTE attribute: %s",
strerror(-r));
return r;
diff --git a/src/network/networkd-netdev-tuntap.c b/src/network/networkd-netdev-tuntap.c
index eaf5df4..7767d75 100644
--- a/src/network/networkd-netdev-tuntap.c
+++ b/src/network/networkd-netdev-tuntap.c
@@ -70,13 +70,13 @@ static int netdev_tuntap_add(NetDev *netdev, struct ifreq *ifr) {
fd = open(TUN_DEV, O_RDWR);
if (fd < 0) {
- log_error_netdev(netdev, "Failed to open tun dev: %m");
+ log_netdev_error(netdev, "Failed to open tun dev: %m");
return -errno;
}
r = ioctl(fd, TUNSETIFF, ifr);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"TUNSETIFF failed on tun dev: %s",
strerror(-r));
return r;
@@ -102,7 +102,7 @@ static int netdev_tuntap_add(NetDev *netdev, struct ifreq *ifr) {
r = ioctl(fd, TUNSETOWNER, uid);
if ( r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"TUNSETOWNER failed on tun dev: %s",
strerror(-r));
}
@@ -121,7 +121,7 @@ static int netdev_tuntap_add(NetDev *netdev, struct ifreq *ifr) {
r = ioctl(fd, TUNSETGROUP, gid);
if( r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"TUNSETGROUP failed on tun dev: %s",
strerror(-r));
return r;
@@ -131,7 +131,7 @@ static int netdev_tuntap_add(NetDev *netdev, struct ifreq *ifr) {
r = ioctl(fd, TUNSETPERSIST, 1);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"TUNSETPERSIST failed on tun dev: %s",
strerror(-r));
return r;
diff --git a/src/network/networkd-netdev-veth.c b/src/network/networkd-netdev-veth.c
index ca2bb07..859c26e 100644
--- a/src/network/networkd-netdev-veth.c
+++ b/src/network/networkd-netdev-veth.c
@@ -38,7 +38,7 @@ static int netdev_veth_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m
r = sd_rtnl_message_open_container(m, VETH_INFO_PEER);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append VETH_INFO_PEER attribute: %s",
strerror(-r));
return r;
@@ -55,7 +55,7 @@ static int netdev_veth_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m
if (v->mac_peer) {
r = sd_rtnl_message_append_ether_addr(m, IFLA_ADDRESS, v->mac_peer);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_ADDRESS attribute: %s",
strerror(-r));
return r;
@@ -64,7 +64,7 @@ static int netdev_veth_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m
r = sd_rtnl_message_close_container(m);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_INFO_DATA attribute: %s",
strerror(-r));
return r;
diff --git a/src/network/networkd-netdev-vlan.c b/src/network/networkd-netdev-vlan.c
index 13c4456..665559f 100644
--- a/src/network/networkd-netdev-vlan.c
+++ b/src/network/networkd-netdev-vlan.c
@@ -37,7 +37,7 @@ static int netdev_vlan_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_m
if (v->id <= VLANID_MAX) {
r = sd_rtnl_message_append_u16(req, IFLA_VLAN_ID, v->id);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_VLAN_ID attribute: %s",
strerror(-r));
return r;
diff --git a/src/network/networkd-netdev-vxlan.c b/src/network/networkd-netdev-vxlan.c
index 326ac54..7dec69d 100644
--- a/src/network/networkd-netdev-vxlan.c
+++ b/src/network/networkd-netdev-vxlan.c
@@ -41,7 +41,7 @@ static int netdev_vxlan_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_
if (v->id <= VXLAN_VID_MAX) {
r = sd_rtnl_message_append_u32(m, IFLA_VXLAN_ID, v->id);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_VXLAN_ID attribute: %s",
strerror(-r));
return r;
@@ -50,7 +50,7 @@ static int netdev_vxlan_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_
r = sd_rtnl_message_append_in_addr(m, IFLA_VXLAN_GROUP, &v->group.in);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_VXLAN_GROUP attribute: %s",
strerror(-r));
return r;
@@ -58,7 +58,7 @@ static int netdev_vxlan_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_
r = sd_rtnl_message_append_u32(m, IFLA_VXLAN_LINK, link->ifindex);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_VXLAN_LINK attribute: %s",
strerror(-r));
return r;
@@ -67,7 +67,7 @@ static int netdev_vxlan_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_
if(v->ttl) {
r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_TTL, v->ttl);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_VXLAN_TTL attribute: %s",
strerror(-r));
return r;
@@ -77,7 +77,7 @@ static int netdev_vxlan_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_
if(v->tos) {
r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_TOS, v->tos);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_VXLAN_TOS attribute: %s",
strerror(-r));
return r;
@@ -86,7 +86,7 @@ static int netdev_vxlan_fill_message_create(NetDev *netdev, Link *link, sd_rtnl_
r = sd_rtnl_message_append_u8(m, IFLA_VXLAN_LEARNING, v->learning);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_VXLAN_LEARNING attribute: %s",
strerror(-r));
return r;
diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c
index bdb0b88..310b20a 100644
--- a/src/network/networkd-netdev.c
+++ b/src/network/networkd-netdev.c
@@ -136,7 +136,7 @@ void netdev_drop(NetDev *netdev) {
netdev->state = NETDEV_STATE_LINGER;
- log_debug_netdev(netdev, "netdev removed");
+ log_netdev_debug(netdev, "netdev removed");
netdev_cancel_callbacks(netdev);
@@ -184,7 +184,7 @@ static int netdev_enslave_ready(NetDev *netdev, Link* link, sd_rtnl_message_hand
r = sd_rtnl_message_new_link(netdev->manager->rtnl, &req,
RTM_SETLINK, link->ifindex);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not allocate RTM_SETLINK message: %s",
strerror(-r));
return r;
@@ -192,7 +192,7 @@ static int netdev_enslave_ready(NetDev *netdev, Link* link, sd_rtnl_message_hand
r = sd_rtnl_message_append_u32(req, IFLA_MASTER, netdev->ifindex);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_MASTER attribute: %s",
strerror(-r));
return r;
@@ -200,7 +200,7 @@ static int netdev_enslave_ready(NetDev *netdev, Link* link, sd_rtnl_message_hand
r = sd_rtnl_call_async(netdev->manager->rtnl, req, callback, link, 0, NULL);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not send rtnetlink message: %s",
strerror(-r));
return r;
@@ -208,7 +208,7 @@ static int netdev_enslave_ready(NetDev *netdev, Link* link, sd_rtnl_message_hand
link_ref(link);
- log_debug_netdev(netdev, "enslaving link '%s'", link->ifname);
+ log_netdev_debug(netdev, "enslaving link '%s'", link->ifname);
return 0;
}
@@ -251,7 +251,7 @@ static int netdev_create_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userda
r = sd_rtnl_message_get_errno(m);
if (r == -EEXIST)
- log_debug_netdev(netdev, "netdev exists, using existing");
+ log_netdev_debug(netdev, "netdev exists, using existing");
else if (r < 0) {
log_warning_netdev(netdev, "netdev could not be created: %s", strerror(-r));
netdev_drop(netdev);
@@ -259,7 +259,7 @@ static int netdev_create_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userda
return 1;
}
- log_debug_netdev(netdev, "created");
+ log_netdev_debug(netdev, "created");
return 1;
}
@@ -288,7 +288,7 @@ int netdev_enslave(NetDev *netdev, Link *link, sd_rtnl_message_handler_t callbac
LIST_PREPEND(callbacks, netdev->callbacks, cb);
- log_debug_netdev(netdev, "will enslave '%s', when reday",
+ log_netdev_debug(netdev, "will enslave '%s', when reday",
link->ifname);
}
@@ -307,29 +307,29 @@ int netdev_set_ifindex(NetDev *netdev, sd_rtnl_message *message) {
r = sd_rtnl_message_get_type(message, &type);
if (r < 0) {
- log_error_netdev(netdev, "Could not get rtnl message type");
+ log_netdev_error(netdev, "Could not get rtnl message type");
return r;
}
if (type != RTM_NEWLINK) {
- log_error_netdev(netdev, "Can not set ifindex from unexpected rtnl message type");
+ log_netdev_error(netdev, "Can not set ifindex from unexpected rtnl message type");
return -EINVAL;
}
r = sd_rtnl_message_link_get_ifindex(message, &ifindex);
if (r < 0) {
- log_error_netdev(netdev, "Could not get ifindex: %s", strerror(-r));
+ log_netdev_error(netdev, "Could not get ifindex: %s", strerror(-r));
netdev_enter_failed(netdev);
return r;
} else if (ifindex <= 0) {
- log_error_netdev(netdev, "Got invalid ifindex: %d", ifindex);
+ log_netdev_error(netdev, "Got invalid ifindex: %d", ifindex);
netdev_enter_failed(netdev);
return r;
}
if (netdev->ifindex > 0) {
if (netdev->ifindex != ifindex) {
- log_error_netdev(netdev, "Could not set ifindex to %d, already set to %d",
+ log_netdev_error(netdev, "Could not set ifindex to %d, already set to %d",
ifindex, netdev->ifindex);
netdev_enter_failed(netdev);
return -EEXIST;
@@ -340,12 +340,12 @@ int netdev_set_ifindex(NetDev *netdev, sd_rtnl_message *message) {
r = sd_rtnl_message_read_string(message, IFLA_IFNAME, &received_name);
if (r < 0) {
- log_error_netdev(netdev, "Could not get IFNAME");
+ log_netdev_error(netdev, "Could not get IFNAME");
return r;
}
if (!streq(netdev->ifname, received_name)) {
- log_error_netdev(netdev, "Received newlink with wrong IFNAME %s",
+ log_netdev_error(netdev, "Received newlink with wrong IFNAME %s",
received_name);
netdev_enter_failed(netdev);
return r;
@@ -353,19 +353,19 @@ int netdev_set_ifindex(NetDev *netdev, sd_rtnl_message *message) {
r = sd_rtnl_message_enter_container(message, IFLA_LINKINFO);
if (r < 0) {
- log_error_netdev(netdev, "Could not get LINKINFO");
+ log_netdev_error(netdev, "Could not get LINKINFO");
return r;
}
r = sd_rtnl_message_read_string(message, IFLA_INFO_KIND, &received_kind);
if (r < 0) {
- log_error_netdev(netdev, "Could not get KIND");
+ log_netdev_error(netdev, "Could not get KIND");
return r;
}
r = sd_rtnl_message_exit_container(message);
if (r < 0) {
- log_error_netdev(netdev, "Could not exit container");
+ log_netdev_error(netdev, "Could not exit container");
return r;
}
@@ -375,14 +375,14 @@ int netdev_set_ifindex(NetDev *netdev, sd_rtnl_message *message) {
else {
kind = netdev_kind_to_string(netdev->kind);
if (!kind) {
- log_error_netdev(netdev, "Could not get kind");
+ log_netdev_error(netdev, "Could not get kind");
netdev_enter_failed(netdev);
return -EINVAL;
}
}
if (!streq(kind, received_kind)) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Received newlink with wrong KIND %s, "
"expected %s", received_kind, kind);
netdev_enter_failed(netdev);
@@ -391,7 +391,7 @@ int netdev_set_ifindex(NetDev *netdev, sd_rtnl_message *message) {
netdev->ifindex = ifindex;
- log_debug_netdev(netdev, "netdev has index %d", netdev->ifindex);
+ log_netdev_debug(netdev, "netdev has index %d", netdev->ifindex);
netdev_enter_ready(netdev);
@@ -459,13 +459,13 @@ static int netdev_create(NetDev *netdev, Link *link,
if (r < 0)
return r;
- log_debug_netdev(netdev, "created");
+ log_netdev_debug(netdev, "created");
} else {
_cleanup_rtnl_message_unref_ sd_rtnl_message *m = NULL;
r = sd_rtnl_message_new_link(netdev->manager->rtnl, &m, RTM_NEWLINK, 0);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not allocate RTM_NEWLINK message: %s",
strerror(-r));
return r;
@@ -473,7 +473,7 @@ static int netdev_create(NetDev *netdev, Link *link,
r = sd_rtnl_message_append_string(m, IFLA_IFNAME, netdev->ifname);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_IFNAME, attribute: %s",
strerror(-r));
return r;
@@ -482,7 +482,7 @@ static int netdev_create(NetDev *netdev, Link *link,
if (netdev->mac) {
r = sd_rtnl_message_append_ether_addr(m, IFLA_ADDRESS, netdev->mac);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_ADDRESS attribute: %s",
strerror(-r));
return r;
@@ -492,7 +492,7 @@ static int netdev_create(NetDev *netdev, Link *link,
if (netdev->mtu) {
r = sd_rtnl_message_append_u32(m, IFLA_MTU, netdev->mtu);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_MTU attribute: %s",
strerror(-r));
return r;
@@ -502,7 +502,7 @@ static int netdev_create(NetDev *netdev, Link *link,
if (link) {
r = sd_rtnl_message_append_u32(m, IFLA_LINK, link->ifindex);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Colud not append IFLA_LINK attribute: %s",
strerror(-r));
return r;
@@ -511,7 +511,7 @@ static int netdev_create(NetDev *netdev, Link *link,
r = sd_rtnl_message_open_container(m, IFLA_LINKINFO);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_LINKINFO attribute: %s",
strerror(-r));
return r;
@@ -520,7 +520,7 @@ static int netdev_create(NetDev *netdev, Link *link,
r = sd_rtnl_message_open_container_union(m, IFLA_INFO_DATA,
netdev_kind_to_string(netdev->kind));
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_INFO_DATA attribute: %s",
strerror(-r));
return r;
@@ -534,7 +534,7 @@ static int netdev_create(NetDev *netdev, Link *link,
r = sd_rtnl_message_close_container(m);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_LINKINFO attribute: %s",
strerror(-r));
return r;
@@ -542,7 +542,7 @@ static int netdev_create(NetDev *netdev, Link *link,
r = sd_rtnl_message_close_container(m);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not append IFLA_LINKINFO attribute: %s",
strerror(-r));
return r;
@@ -553,7 +553,7 @@ static int netdev_create(NetDev *netdev, Link *link,
r = sd_rtnl_call_async(netdev->manager->rtnl, m,
callback, link, 0, NULL);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not send rtnetlink message: %s",
strerror(-r));
return r;
@@ -565,7 +565,7 @@ static int netdev_create(NetDev *netdev, Link *link,
netdev_create_handler, netdev, 0,
NULL);
if (r < 0) {
- log_error_netdev(netdev,
+ log_netdev_error(netdev,
"Could not send rtnetlink message: %s",
strerror(-r));
return r;
@@ -576,7 +576,7 @@ static int netdev_create(NetDev *netdev, Link *link,
netdev->state = NETDEV_STATE_CREATING;
- log_debug_netdev(netdev, "creating");
+ log_netdev_debug(netdev, "creating");
}
return 0;
@@ -713,7 +713,7 @@ static int netdev_load_one(Manager *manager, const char *filename) {
LIST_HEAD_INIT(netdev->callbacks);
- log_debug_netdev(netdev, "loaded %s", netdev_kind_to_string(netdev->kind));
+ log_netdev_debug(netdev, "loaded %s", netdev_kind_to_string(netdev->kind));
switch (NETDEV_VTABLE(netdev)->create_type) {
case NETDEV_CREATE_MASTER:
diff --git a/src/network/networkd-netdev.h b/src/network/networkd-netdev.h
index 54339ae..c1e05c2 100644
--- a/src/network/networkd-netdev.h
+++ b/src/network/networkd-netdev.h
@@ -192,12 +192,12 @@ const struct ConfigPerfItem* network_netdev_gperf_lookup(const char *key, unsign
/* Macros which append INTERFACE= to the message */
-#define log_full_netdev(level, netdev, fmt, ...) log_meta_object(level, 0, __FILE__, __LINE__, __func__, "INTERFACE=", netdev->ifname, "%-*s: " fmt, IFNAMSIZ, netdev->ifname, ##__VA_ARGS__)
-#define log_debug_netdev(netdev, ...) log_full_netdev(LOG_DEBUG, netdev, ##__VA_ARGS__)
+#define log_full_netdev(level, netdev, fmt, ...) log_object_internal(level, 0, __FILE__, __LINE__, __func__, "INTERFACE=", netdev->ifname, "%-*s: " fmt, IFNAMSIZ, netdev->ifname, ##__VA_ARGS__)
+#define log_netdev_debug(netdev, ...) log_full_netdev(LOG_DEBUG, netdev, ##__VA_ARGS__)
#define log_info_netdev(netdev, ...) log_full_netdev(LOG_INFO, netdev, ##__VA_ARGS__)
#define log_notice_netdev(netdev, ...) log_full_netdev(LOG_NOTICE, netdev, ##__VA_ARGS__)
#define log_warning_netdev(netdev, ...) log_full_netdev(LOG_WARNING, netdev,## __VA_ARGS__)
-#define log_error_netdev(netdev, ...) log_full_netdev(LOG_ERR, netdev, ##__VA_ARGS__)
+#define log_netdev_error(netdev, ...) log_full_netdev(LOG_ERR, netdev, ##__VA_ARGS__)
#define log_struct_netdev(level, netdev, ...) log_struct(level, "INTERFACE=%s", netdev->ifname, __VA_ARGS__)
diff --git a/src/network/networkd.h b/src/network/networkd.h
index 9acf31c..263cc61 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -336,14 +336,14 @@ int address_pool_acquire(AddressPool *p, unsigned prefixlen, union in_addr_union
/* Macros which append INTERFACE= to the message */
-#define log_full_link(level, link, fmt, ...) log_meta_object(level, 0, __FILE__, __LINE__, __func__, "INTERFACE=", link->ifname, "%-*s: " fmt, IFNAMSIZ, link->ifname, ##__VA_ARGS__)
-#define log_debug_link(link, ...) log_full_link(LOG_DEBUG, link, ##__VA_ARGS__)
-#define log_info_link(link, ...) log_full_link(LOG_INFO, link, ##__VA_ARGS__)
-#define log_notice_link(link, ...) log_full_link(LOG_NOTICE, link, ##__VA_ARGS__)
-#define log_warning_link(link, ...) log_full_link(LOG_WARNING, link, ##__VA_ARGS__)
-#define log_error_link(link, ...) log_full_link(LOG_ERR, link, ##__VA_ARGS__)
-
-#define log_struct_link(level, link, ...) log_struct(level, "INTERFACE=%s", link->ifname, __VA_ARGS__)
+#define log_link_full(level, link, fmt, ...) log_object_internal(level, 0, __FILE__, __LINE__, __func__, "INTERFACE=", link->ifname, "%-*s: " fmt, IFNAMSIZ, link->ifname, ##__VA_ARGS__)
+#define log_link_debug(link, ...) log_link_full(LOG_DEBUG, link, ##__VA_ARGS__)
+#define log_link_info(link, ...) log_link_full(LOG_INFO, link, ##__VA_ARGS__)
+#define log_link_notice(link, ...) log_link_full(LOG_NOTICE, link, ##__VA_ARGS__)
+#define log_link_warning(link, ...) log_link_full(LOG_WARNING, link, ##__VA_ARGS__)
+#define log_link_error(link, ...) log_link_full(LOG_ERR, link, ##__VA_ARGS__)
+
+#define log_link_struct(level, link, ...) log_struct(level, "INTERFACE=%s", link->ifname, __VA_ARGS__)
#define ADDRESS_FMT_VAL(address) \
(address).s_addr & 0xFF, \
diff --git a/src/shared/env-util.c b/src/shared/env-util.c
index d90b878..fbdc73d 100644
--- a/src/shared/env-util.c
+++ b/src/shared/env-util.c
@@ -425,7 +425,7 @@ char **strv_env_clean_log(char **e, const char *unit_id, const char *message) {
if (!env_assignment_is_valid(*p)) {
if (message)
- log_error_unit(unit_id, "Ignoring invalid environment '%s': %s", *p, message);
+ log_unit_error(unit_id, "Ignoring invalid environment '%s': %s", *p, message);
free(*p);
continue;
}
diff --git a/src/shared/log.c b/src/shared/log.c
index d87f43f..dcbcd9d 100644
--- a/src/shared/log.c
+++ b/src/shared/log.c
@@ -627,7 +627,7 @@ int log_dump_internal(
return log_dispatch(level, error, file, line, func, NULL, NULL, buffer);
}
-int log_metav(
+int log_internalv(
int level,
int error,
const char*file,
@@ -652,7 +652,7 @@ int log_metav(
return log_dispatch(level, error, file, line, func, NULL, NULL, buffer);
}
-int log_meta(
+int log_internal(
int level,
int error,
const char*file,
@@ -664,13 +664,13 @@ int log_meta(
va_list ap;
va_start(ap, format);
- r = log_metav(level, error, file, line, func, format, ap);
+ r = log_internalv(level, error, file, line, func, format, ap);
va_end(ap);
return r;
}
-int log_metav_object(
+int log_object_internalv(
int level,
int error,
const char*file,
@@ -697,7 +697,7 @@ int log_metav_object(
return log_dispatch(level, error, file, line, func, object_field, object, buffer);
}
-int log_meta_object(
+int log_object_internal(
int level,
int error,
const char*file,
@@ -711,7 +711,7 @@ int log_meta_object(
va_list ap;
va_start(ap, format);
- r = log_metav_object(level, error, file, line, func, object_field, object, format, ap);
+ r = log_object_internalv(level, error, file, line, func, object_field, object, format, ap);
va_end(ap);
return r;
@@ -756,7 +756,7 @@ void log_assert_failed_return(const char *text, const char *file, int line, cons
}
int log_oom_internal(const char *file, int line, const char *func) {
- log_meta(LOG_ERR, ENOMEM, file, line, func, "Out of memory.");
+ log_internal(LOG_ERR, ENOMEM, file, line, func, "Out of memory.");
return -ENOMEM;
}
diff --git a/src/shared/log.h b/src/shared/log.h
index 9dd68df..2780104 100644
--- a/src/shared/log.h
+++ b/src/shared/log.h
@@ -75,40 +75,40 @@ void log_close_console(void);
void log_parse_environment(void);
-int log_meta(
+int log_internal(
int level,
int error,
- const char*file,
+ const char *file,
int line,
const char *func,
const char *format, ...) _printf_(6,7);
-int log_metav(
+int log_internalv(
int level,
int error,
- const char*file,
+ const char *file,
int line,
const char *func,
const char *format,
va_list ap) _printf_(6,0);
-int log_meta_object(
+int log_object_internal(
int level,
int error,
- const char*file,
+ const char *file,
int line,
const char *func,
- const char *object_name,
+ const char *object_field,
const char *object,
const char *format, ...) _printf_(8,9);
-int log_metav_object(
+int log_object_internalv(
int level,
int error,
const char*file,
int line,
const char *func,
- const char *object_name,
+ const char *object_field,
const char *object,
const char *format,
va_list ap) _printf_(8,0);
@@ -130,7 +130,7 @@ int log_oom_internal(
int log_dump_internal(
int level,
int error,
- const char*file,
+ const char *file,
int line,
const char *func,
char *buffer);
@@ -158,7 +158,7 @@ void log_assert_failed_return(
#define log_full_errno(level, error, ...) \
do { \
if (log_get_max_level() >= (level)) \
- log_meta((level), error, __FILE__, __LINE__, __func__, __VA_ARGS__); \
+ log_internal((level), error, __FILE__, __LINE__, __func__, __VA_ARGS__); \
} while (false)
#define log_full(level, ...) log_full_errno(level, 0, __VA_ARGS__)
diff --git a/src/sysv-generator/sysv-generator.c b/src/sysv-generator/sysv-generator.c
index 6e4cdd6..a2f8533 100644
--- a/src/sysv-generator/sysv-generator.c
+++ b/src/sysv-generator/sysv-generator.c
@@ -192,7 +192,7 @@ static int generate_unit_file(SysvStub *s) {
STRV_FOREACH(p, s->wanted_by) {
r = add_symlink(s->name, *p);
if (r < 0)
- log_error_unit(s->name, "Failed to create 'Wants' symlink to %s: %s", *p, strerror(-r));
+ log_unit_error(s->name, "Failed to create 'Wants' symlink to %s: %s", *p, strerror(-r));
}
return 0;
@@ -320,7 +320,7 @@ static int load_sysv(SysvStub *s) {
if (feof(f))
break;
- log_error_unit(s->name,
+ log_unit_error(s->name,
"Failed to read configuration file '%s': %m",
s->path);
return -errno;
@@ -395,7 +395,7 @@ static int load_sysv(SysvStub *s) {
fn = strstrip(t+8);
if (!path_is_absolute(fn)) {
- log_error_unit(s->name,
+ log_unit_error(s->name,
"[%s:%u] PID file not absolute. Ignoring.",
s->path, line);
continue;
@@ -489,12 +489,12 @@ static int load_sysv(SysvStub *s) {
}
if (r < 0)
- log_error_unit(s->name,
+ log_unit_error(s->name,
"[%s:%u] Failed to add LSB Provides name %s, ignoring: %s",
s->path, line, m, strerror(-r));
}
if (!isempty(state_))
- log_error_unit(s->name,
+ log_unit_error(s->name,
"[%s:%u] Trailing garbage in Provides, ignoring.",
s->path, line);
@@ -517,7 +517,7 @@ static int load_sysv(SysvStub *s) {
r = sysv_translate_facility(n, basename(s->path), &m);
if (r < 0) {
- log_error_unit(s->name,
+ log_unit_error(s->name,
"[%s:%u] Failed to translate LSB dependency %s, ignoring: %s",
s->path, line, n, strerror(-r));
continue;
@@ -551,12 +551,12 @@ static int load_sysv(SysvStub *s) {
}
if (r < 0)
- log_error_unit(s->name,
+ log_unit_error(s->name,
"[%s:%u] Failed to add dependency on %s, ignoring: %s",
s->path, line, m, strerror(-r));
}
if (!isempty(state_))
- log_error_unit(s->name,
+ log_unit_error(s->name,
"[%s:%u] Trailing garbage in %*s, ignoring.",
s->path, line,
(int)(strchr(t, ':') - t), t);
diff --git a/src/udev/udev-builtin-kmod.c b/src/udev/udev-builtin-kmod.c
index f3d1647..0949d9f 100644
--- a/src/udev/udev-builtin-kmod.c
+++ b/src/udev/udev-builtin-kmod.c
@@ -64,7 +64,7 @@ static int load_module(struct udev *udev, const char *alias) {
}
_printf_(6,0) static void udev_kmod_log(void *data, int priority, const char *file, int line, const char *fn, const char *format, va_list args) {
- log_metav(priority, 0, file, line, fn, format, args);
+ log_internalv(priority, 0, file, line, fn, format, args);
}
static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool test) {
commit e09ca588d25a0c383880d6c2f5b129296af781ab
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Nov 27 19:52:27 2014 +0100
log: be a bit less wasteful when allocating buffers
diff --git a/src/shared/log.c b/src/shared/log.c
index ba959b9..d87f43f 100644
--- a/src/shared/log.c
+++ b/src/shared/log.c
@@ -366,7 +366,7 @@ static int write_to_syslog(
const char *object,
const char *buffer) {
- char header_priority[16], header_time[64], header_pid[16];
+ char header_priority[1 + DECIMAL_STR_MAX(int) + 2], header_time[64], header_pid[1 + DECIMAL_STR_MAX(pid_t) + 4];
struct iovec iovec[5] = {};
struct msghdr msghdr = {
.msg_iov = iovec,
@@ -429,7 +429,7 @@ static int write_to_kmsg(
const char *object,
const char *buffer) {
- char header_priority[16], header_pid[16];
+ char header_priority[1 + DECIMAL_STR_MAX(int) + 2], header_pid[1 + DECIMAL_STR_MAX(pid_t) + 4];
struct iovec iovec[5] = {};
if (kmsg_fd < 0)
commit 086891e5c119abb9854237fc32e736fe2d67234c
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Nov 27 19:48:02 2014 +0100
log: add an "error" parameter to all low-level logging calls and intrdouce log_error_errno() as log calls that take error numbers
This change has two benefits:
- The format string %m will now resolve to the specified error (or to
errno if the specified error is 0. This allows getting rid of a ton of
strerror() invocations, a function that is not thread-safe.
- The specified error can be passed to the journal in the ERRNO= field.
Now of course, we just need somebody to convert all cases of this:
log_error("Something happened: %s", strerror(-r));
into thus:
log_error_errno(-r, "Something happened: %m");
diff --git a/src/core/kmod-setup.c b/src/core/kmod-setup.c
index 4795a47..50af793 100644
--- a/src/core/kmod-setup.c
+++ b/src/core/kmod-setup.c
@@ -44,7 +44,7 @@ static void systemd_kmod_log(
/* library logging is enabled at debug only */
DISABLE_WARNING_FORMAT_NONLITERAL;
- log_metav(LOG_DEBUG, file, line, fn, format, args);
+ log_metav(LOG_DEBUG, 0, file, line, fn, format, args);
REENABLE_WARNING;
}
diff --git a/src/core/selinux-access.c b/src/core/selinux-access.c
index a50dec3..b3835d5 100644
--- a/src/core/selinux-access.c
+++ b/src/core/selinux-access.c
@@ -112,7 +112,7 @@ _printf_(2, 3) static int log_callback(int type, const char *fmt, ...) {
#endif
va_start(ap, fmt);
- log_metav(LOG_USER | LOG_INFO, __FILE__, __LINE__, __FUNCTION__, fmt, ap);
+ log_metav(LOG_USER | LOG_INFO, 0, __FILE__, __LINE__, __FUNCTION__, fmt, ap);
va_end(ap);
return 0;
diff --git a/src/core/unit.h b/src/core/unit.h
index 8b24272..54ba11a 100644
--- a/src/core/unit.h
+++ b/src/core/unit.h
@@ -596,7 +596,9 @@ UnitActiveState unit_active_state_from_string(const char *s) _pure_;
/* Macros which append UNIT= or USER_UNIT= to the message */
-#define log_full_unit(level, unit, ...) log_meta_object(level, __FILE__, __LINE__, __func__, getpid() == 1 ? "UNIT=" : "USER_UNIT=", unit, __VA_ARGS__)
+#define log_full_unit(level, unit, ...) log_meta_object(level, 0, __FILE__, __LINE__, __func__, getpid() == 1 ? "UNIT=" : "USER_UNIT=", unit, __VA_ARGS__)
+#define log_full_unit_errno(level, error, unit, ...) log_meta_object(level, error, __FILE__, __LINE__, __func__, getpid() == 1 ? "UNIT=" : "USER_UNIT=", unit, __VA_ARGS__)
+
#define log_debug_unit(unit, ...) log_full_unit(LOG_DEBUG, unit, __VA_ARGS__)
#define log_info_unit(unit, ...) log_full_unit(LOG_INFO, unit, __VA_ARGS__)
#define log_notice_unit(unit, ...) log_full_unit(LOG_NOTICE, unit, __VA_ARGS__)
diff --git a/src/journal-remote/microhttpd-util.c b/src/journal-remote/microhttpd-util.c
index 55c45f4..bec4134 100644
--- a/src/journal-remote/microhttpd-util.c
+++ b/src/journal-remote/microhttpd-util.c
@@ -41,7 +41,7 @@ void microhttpd_logger(void *arg, const char *fmt, va_list ap) {
f = strappenda("microhttpd: ", fmt);
DISABLE_WARNING_FORMAT_NONLITERAL;
- log_metav(LOG_INFO, NULL, 0, NULL, f, ap);
+ log_metav(LOG_INFO, 0, NULL, 0, NULL, f, ap);
REENABLE_WARNING;
}
@@ -126,11 +126,10 @@ void log_func_gnutls(int level, const char *message) {
if (0 <= level && level < (int) ELEMENTSOF(gnutls_log_map)) {
if (gnutls_log_map[level].enabled)
- log_meta(gnutls_log_map[level].level, NULL, 0, NULL,
- "gnutls %d/%s: %s", level, gnutls_log_map[level].names[1], message);
+ log_meta(gnutls_log_map[level].level, 0, NULL, 0, NULL, "gnutls %d/%s: %s", level, gnutls_log_map[level].names[1], message);
} else {
log_debug("Received GNUTLS message with unknown level %d.", level);
- log_meta(LOG_DEBUG, NULL, 0, NULL, "gnutls: %s", message);
+ log_meta(LOG_DEBUG, 0, NULL, 0, NULL, "gnutls: %s", message);
}
}
diff --git a/src/libsystemd-network/dhcp-internal.h b/src/libsystemd-network/dhcp-internal.h
index d358a49..d76d0c2 100644
--- a/src/libsystemd-network/dhcp-internal.h
+++ b/src/libsystemd-network/dhcp-internal.h
@@ -71,4 +71,4 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(sd_dhcp_client*, sd_dhcp_client_unref);
#define DHCP_CLIENT_DONT_DESTROY(client) \
_cleanup_dhcp_client_unref_ _unused_ sd_dhcp_client *_dont_destroy_##client = sd_dhcp_client_ref(client)
-#define log_dhcp_client(client, fmt, ...) log_meta(LOG_DEBUG, __FILE__, __LINE__, __func__, "DHCP CLIENT (0x%x): " fmt, client->xid, ##__VA_ARGS__)
+#define log_dhcp_client(client, fmt, ...) log_meta(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "DHCP CLIENT (0x%x): " fmt, client->xid, ##__VA_ARGS__)
diff --git a/src/libsystemd-network/dhcp-server-internal.h b/src/libsystemd-network/dhcp-server-internal.h
index 480da22..6c2c248 100644
--- a/src/libsystemd-network/dhcp-server-internal.h
+++ b/src/libsystemd-network/dhcp-server-internal.h
@@ -79,7 +79,7 @@ typedef struct DHCPRequest {
DEFINE_TRIVIAL_CLEANUP_FUNC(sd_dhcp_server*, sd_dhcp_server_unref);
#define _cleanup_dhcp_server_unref_ _cleanup_(sd_dhcp_server_unrefp)
-#define log_dhcp_server(client, fmt, ...) log_meta(LOG_DEBUG, __FILE__, __LINE__, __func__, "DHCP SERVER: " fmt, ##__VA_ARGS__)
+#define log_dhcp_server(client, fmt, ...) log_meta(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "DHCP SERVER: " fmt, ##__VA_ARGS__)
int dhcp_server_handle_message(sd_dhcp_server *server, DHCPMessage *message,
size_t length);
diff --git a/src/libsystemd-network/dhcp6-internal.h b/src/libsystemd-network/dhcp6-internal.h
index 6cc0aa8..3737d49 100644
--- a/src/libsystemd-network/dhcp6-internal.h
+++ b/src/libsystemd-network/dhcp6-internal.h
@@ -56,7 +56,7 @@ struct DHCP6IA {
typedef struct DHCP6IA DHCP6IA;
-#define log_dhcp6_client(p, fmt, ...) log_meta(LOG_DEBUG, __FILE__, __LINE__, __func__, "DHCPv6 CLIENT: " fmt, ##__VA_ARGS__)
+#define log_dhcp6_client(p, fmt, ...) log_meta(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "DHCPv6 CLIENT: " fmt, ##__VA_ARGS__)
int dhcp_network_icmp6_bind_router_solicitation(int index);
int dhcp_network_icmp6_send_router_solicitation(int s, const struct ether_addr *ether_addr);
diff --git a/src/libsystemd-network/ipv4ll-internal.h b/src/libsystemd-network/ipv4ll-internal.h
index fe5ef8e..7b5d372 100644
--- a/src/libsystemd-network/ipv4ll-internal.h
+++ b/src/libsystemd-network/ipv4ll-internal.h
@@ -35,4 +35,4 @@ void arp_packet_probe(struct ether_arp *arp, be32_t pa, const struct ether_addr
void arp_packet_announcement(struct ether_arp *arp, be32_t pa, const struct ether_addr *ha);
int arp_packet_verify_headers(struct ether_arp *arp);
-#define log_ipv4ll(ll, fmt, ...) log_meta(LOG_DEBUG, __FILE__, __LINE__, __func__, "IPv4LL: " fmt, ##__VA_ARGS__)
+#define log_ipv4ll(ll, fmt, ...) log_meta(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "IPv4LL: " fmt, ##__VA_ARGS__)
diff --git a/src/libsystemd-network/sd-icmp6-nd.c b/src/libsystemd-network/sd-icmp6-nd.c
index 2473fbb..23f5682 100644
--- a/src/libsystemd-network/sd-icmp6-nd.c
+++ b/src/libsystemd-network/sd-icmp6-nd.c
@@ -54,7 +54,7 @@ struct sd_icmp6_nd {
void *userdata;
};
-#define log_icmp6_nd(p, fmt, ...) log_meta(LOG_DEBUG, __FILE__, __LINE__, __func__, "ICMPv6 CLIENT: " fmt, ##__VA_ARGS__)
+#define log_icmp6_nd(p, fmt, ...) log_meta(LOG_DEBUG, 0, __FILE__, __LINE__, __func__, "ICMPv6 CLIENT: " fmt, ##__VA_ARGS__)
static void icmp6_nd_notify(sd_icmp6_nd *nd, int event)
{
diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c
index c676fd1..da67247 100644
--- a/src/modules-load/modules-load.c
+++ b/src/modules-load/modules-load.c
@@ -44,7 +44,7 @@ static void systemd_kmod_log(void *data, int priority, const char *file, int lin
const char *fn, const char *format, va_list args) {
DISABLE_WARNING_FORMAT_NONLITERAL;
- log_metav(priority, file, line, fn, format, args);
+ log_metav(priority, 0, file, line, fn, format, args);
REENABLE_WARNING;
}
diff --git a/src/network/networkd-ipv4ll.c b/src/network/networkd-ipv4ll.c
index 5467bc3..fd55f79 100644
--- a/src/network/networkd-ipv4ll.c
+++ b/src/network/networkd-ipv4ll.c
@@ -40,8 +40,7 @@ static int ipv4ll_address_lost(Link *link) {
if (r < 0)
return 0;
- log_debug_link(link, "IPv4 link-local release %u.%u.%u.%u",
- ADDRESS_FMT_VAL(addr));
+ log_debug_link(link, "IPv4 link-local release %u.%u.%u.%u", ADDRESS_FMT_VAL(addr));
r = address_new_dynamic(&address);
if (r < 0) {
diff --git a/src/network/networkd-link.h b/src/network/networkd-link.h
index 7acf404..5eb4b88 100644
--- a/src/network/networkd-link.h
+++ b/src/network/networkd-link.h
@@ -132,7 +132,7 @@ DEFINE_TRIVIAL_CLEANUP_FUNC(Link*, link_unref);
/* Macros which append INTERFACE= to the message */
-#define log_full_link(level, link, fmt, ...) log_meta_object(level, __FILE__, __LINE__, __func__, "INTERFACE=", link->ifname, "%-*s: " fmt, IFNAMSIZ, link->ifname, ##__VA_ARGS__)
+#define log_full_link(level, link, fmt, ...) log_meta_object(level, 0, __FILE__, __LINE__, __func__, "INTERFACE=", link->ifname, "%-*s: " fmt, IFNAMSIZ, link->ifname, ##__VA_ARGS__)
#define log_debug_link(link, ...) log_full_link(LOG_DEBUG, link, ##__VA_ARGS__)
#define log_info_link(link, ...) log_full_link(LOG_INFO, link, ##__VA_ARGS__)
#define log_notice_link(link, ...) log_full_link(LOG_NOTICE, link, ##__VA_ARGS__)
diff --git a/src/network/networkd-netdev.c b/src/network/networkd-netdev.c
index fd1f51e..bdb0b88 100644
--- a/src/network/networkd-netdev.c
+++ b/src/network/networkd-netdev.c
@@ -65,7 +65,6 @@ static const char* const netdev_kind_table[_NETDEV_KIND_MAX] = {
DEFINE_STRING_TABLE_LOOKUP(netdev_kind, NetDevKind);
DEFINE_CONFIG_PARSE_ENUM(config_parse_netdev_kind, netdev_kind, NetDevKind, "Failed to parse netdev kind");
-
static void netdev_cancel_callbacks(NetDev *netdev) {
_cleanup_rtnl_message_unref_ sd_rtnl_message *m = NULL;
netdev_join_callback *callback;
diff --git a/src/network/networkd-netdev.h b/src/network/networkd-netdev.h
index a6fad2d..54339ae 100644
--- a/src/network/networkd-netdev.h
+++ b/src/network/networkd-netdev.h
@@ -192,7 +192,7 @@ const struct ConfigPerfItem* network_netdev_gperf_lookup(const char *key, unsign
/* Macros which append INTERFACE= to the message */
-#define log_full_netdev(level, netdev, fmt, ...) log_meta_object(level, __FILE__, __LINE__, __func__, "INTERFACE=", netdev->ifname, "%-*s: " fmt, IFNAMSIZ, netdev->ifname, ##__VA_ARGS__)
+#define log_full_netdev(level, netdev, fmt, ...) log_meta_object(level, 0, __FILE__, __LINE__, __func__, "INTERFACE=", netdev->ifname, "%-*s: " fmt, IFNAMSIZ, netdev->ifname, ##__VA_ARGS__)
#define log_debug_netdev(netdev, ...) log_full_netdev(LOG_DEBUG, netdev, ##__VA_ARGS__)
#define log_info_netdev(netdev, ...) log_full_netdev(LOG_INFO, netdev, ##__VA_ARGS__)
#define log_notice_netdev(netdev, ...) log_full_netdev(LOG_NOTICE, netdev, ##__VA_ARGS__)
diff --git a/src/network/networkd.h b/src/network/networkd.h
index 19a661e..9acf31c 100644
--- a/src/network/networkd.h
+++ b/src/network/networkd.h
@@ -336,7 +336,7 @@ int address_pool_acquire(AddressPool *p, unsigned prefixlen, union in_addr_union
/* Macros which append INTERFACE= to the message */
-#define log_full_link(level, link, fmt, ...) log_meta_object(level, __FILE__, __LINE__, __func__, "INTERFACE=", link->ifname, "%-*s: " fmt, IFNAMSIZ, link->ifname, ##__VA_ARGS__)
+#define log_full_link(level, link, fmt, ...) log_meta_object(level, 0, __FILE__, __LINE__, __func__, "INTERFACE=", link->ifname, "%-*s: " fmt, IFNAMSIZ, link->ifname, ##__VA_ARGS__)
#define log_debug_link(link, ...) log_full_link(LOG_DEBUG, link, ##__VA_ARGS__)
#define log_info_link(link, ...) log_full_link(LOG_INFO, link, ##__VA_ARGS__)
#define log_notice_link(link, ...) log_full_link(LOG_NOTICE, link, ##__VA_ARGS__)
diff --git a/src/shared/conf-parser.c b/src/shared/conf-parser.c
index 027c49c..6bd9d9e 100644
--- a/src/shared/conf-parser.c
+++ b/src/shared/conf-parser.c
@@ -38,10 +38,16 @@
#include "exit-status.h"
#include "sd-messages.h"
-int log_syntax_internal(const char *unit, int level,
- const char *file, unsigned line, const char *func,
- const char *config_file, unsigned config_line,
- int error, const char *format, ...) {
+int log_syntax_internal(
+ const char *unit,
+ int level,
+ const char *file,
+ int line,
+ const char *func,
+ const char *config_file,
+ unsigned config_line,
+ int error,
+ const char *format, ...) {
_cleanup_free_ char *msg = NULL;
int r;
@@ -55,21 +61,21 @@ int log_syntax_internal(const char *unit, int level,
if (unit)
r = log_struct_internal(level,
+ error > 0 ? error : EINVAL,
file, line, func,
getpid() == 1 ? "UNIT=%s" : "USER_UNIT=%s", unit,
MESSAGE_ID(SD_MESSAGE_CONFIG_ERROR),
"CONFIG_FILE=%s", config_file,
"CONFIG_LINE=%u", config_line,
- "ERRNO=%d", error > 0 ? error : EINVAL,
"MESSAGE=[%s:%u] %s", config_file, config_line, msg,
NULL);
else
r = log_struct_internal(level,
+ error > 0 ? error : EINVAL,
file, line, func,
MESSAGE_ID(SD_MESSAGE_CONFIG_ERROR),
"CONFIG_FILE=%s", config_file,
"CONFIG_LINE=%u", config_line,
- "ERRNO=%d", error > 0 ? error : EINVAL,
"MESSAGE=[%s:%u] %s", config_file, config_line, msg,
NULL);
diff --git a/src/shared/conf-parser.h b/src/shared/conf-parser.h
index 69d3271..2507a44 100644
--- a/src/shared/conf-parser.h
+++ b/src/shared/conf-parser.h
@@ -119,10 +119,16 @@ int config_parse_mode(const char *unit, const char *filename, unsigned line, con
int config_parse_log_facility(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
int config_parse_log_level(const char *unit, const char *filename, unsigned line, const char *section, unsigned section_line, const char *lvalue, int ltype, const char *rvalue, void *data, void *userdata);
-int log_syntax_internal(const char *unit, int level,
- const char *file, unsigned line, const char *func,
- const char *config_file, unsigned config_line,
- int error, const char *format, ...) _printf_(9, 10);
+int log_syntax_internal(
+ const char *unit,
+ int level,
+ const char *file,
+ int line,
+ const char *func,
+ const char *config_file,
+ unsigned config_line,
+ int error,
+ const char *format, ...) _printf_(9, 10);
#define log_syntax(unit, level, config_file, config_line, error, ...) \
log_syntax_internal(unit, level, \
diff --git a/src/shared/log.c b/src/shared/log.c
index d465311..ba959b9 100644
--- a/src/shared/log.c
+++ b/src/shared/log.c
@@ -122,7 +122,7 @@ static int create_log_socket(int type) {
timeval_store(&tv, 10 * USEC_PER_MSEC);
else
timeval_store(&tv, 10 * USEC_PER_SEC);
- (void)setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
+ (void) setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, &tv, sizeof(tv));
return fd;
}
@@ -302,10 +302,11 @@ void log_set_facility(int facility) {
static int write_to_console(
int level,
+ int error,
const char*file,
int line,
const char *func,
- const char *object_name,
+ const char *object_field,
const char *object,
const char *buffer) {
@@ -356,13 +357,14 @@ static int write_to_console(
}
static int write_to_syslog(
- int level,
- const char*file,
- int line,
- const char *func,
- const char *object_name,
- const char *object,
- const char *buffer) {
+ int level,
+ int error,
+ const char*file,
+ int line,
+ const char *func,
+ const char *object_field,
+ const char *object,
+ const char *buffer) {
char header_priority[16], header_time[64], header_pid[16];
struct iovec iovec[5] = {};
@@ -418,13 +420,14 @@ static int write_to_syslog(
}
static int write_to_kmsg(
- int level,
- const char*file,
- int line,
- const char *func,
- const char *object_name,
- const char *object,
- const char *buffer) {
+ int level,
+ int error,
+ const char*file,
+ int line,
+ const char *func,
+ const char *object_field,
+ const char *object,
+ const char *buffer) {
char header_priority[16], header_pid[16];
struct iovec iovec[5] = {};
@@ -450,45 +453,55 @@ static int write_to_kmsg(
return 1;
}
-static int log_do_header(char *header, size_t size,
- int level,
- const char *file, int line, const char *func,
- const char *object_name, const char *object) {
+static int log_do_header(
+ char *header,
+ size_t size,
+ int level,
+ int error,
+ const char *file, int line, const char *func,
+ const char *object_field, const char *object) {
+
snprintf(header, size,
"PRIORITY=%i\n"
"SYSLOG_FACILITY=%i\n"
- "%s%.*s%s"
+ "%s%s%s"
"%s%.*i%s"
- "%s%.*s%s"
- "%s%.*s%s"
+ "%s%s%s"
+ "%s%.*i%s"
+ "%s%s%s"
"SYSLOG_IDENTIFIER=%s\n",
LOG_PRI(level),
LOG_FAC(level),
- file ? "CODE_FILE=" : "",
- file ? LINE_MAX : 0, file, /* %.0s means no output */
- file ? "\n" : "",
+ isempty(file) ? "" : "CODE_FILE=",
+ isempty(file) ? "" : file,
+ isempty(file) ? "" : "\n",
line ? "CODE_LINE=" : "",
line ? 1 : 0, line, /* %.0d means no output too, special case for 0 */
line ? "\n" : "",
- func ? "CODE_FUNCTION=" : "",
- func ? LINE_MAX : 0, func,
- func ? "\n" : "",
- object ? object_name : "",
- object ? LINE_MAX : 0, object, /* %.0s means no output */
- object ? "\n" : "",
+ isempty(func) ? "" : "CODE_FUNCTION=",
+ isempty(func) ? "" : func,
+ isempty(func) ? "" : "\n",
+ error ? "ERRNO=" : "",
+ error ? 1 : 0, error,
+ error ? "\n" : "",
+ isempty(object) ? "" : object_field,
+ isempty(object) ? "" : object,
+ isempty(object) ? "" : "\n",
program_invocation_short_name);
header[size - 1] = '\0';
+
return 0;
}
static int write_to_journal(
- int level,
- const char*file,
- int line,
- const char *func,
- const char *object_name,
- const char *object,
- const char *buffer) {
+ int level,
+ int error,
+ const char*file,
+ int line,
+ const char *func,
+ const char *object_field,
+ const char *object,
+ const char *buffer) {
char header[LINE_MAX];
struct iovec iovec[4] = {};
@@ -497,8 +510,7 @@ static int write_to_journal(
if (journal_fd < 0)
return 0;
- log_do_header(header, sizeof(header), level,
- file, line, func, object_name, object);
+ log_do_header(header, sizeof(header), level, error, file, line, func, object_field, object);
IOVEC_SET_STRING(iovec[0], header);
IOVEC_SET_STRING(iovec[1], "MESSAGE=");
@@ -515,13 +527,14 @@ static int write_to_journal(
}
static int log_dispatch(
- int level,
- const char*file,
- int line,
- const char *func,
- const char *object_name,
- const char *object,
- char *buffer) {
+ int level,
+ int error,
+ const char*file,
+ int line,
+ const char *func,
+ const char *object_field,
+ const char *object,
+ char *buffer) {
int r = 0;
@@ -548,8 +561,7 @@ static int log_dispatch(
log_target == LOG_TARGET_JOURNAL_OR_KMSG ||
log_target == LOG_TARGET_JOURNAL) {
- k = write_to_journal(level, file, line, func,
- object_name, object, buffer);
+ k = write_to_journal(level, error, file, line, func, object_field, object, buffer);
if (k < 0) {
if (k != -EAGAIN)
log_close_journal();
@@ -561,8 +573,7 @@ static int log_dispatch(
if (log_target == LOG_TARGET_SYSLOG_OR_KMSG ||
log_target == LOG_TARGET_SYSLOG) {
- k = write_to_syslog(level, file, line, func,
- object_name, object, buffer);
+ k = write_to_syslog(level, error, file, line, func, object_field, object, buffer);
if (k < 0) {
if (k != -EAGAIN)
log_close_syslog();
@@ -578,8 +589,7 @@ static int log_dispatch(
log_target == LOG_TARGET_JOURNAL_OR_KMSG ||
log_target == LOG_TARGET_KMSG)) {
- k = write_to_kmsg(level, file, line, func,
- object_name, object, buffer);
+ k = write_to_kmsg(level, error, file, line, func, object_field, object, buffer);
if (k < 0) {
log_close_kmsg();
log_open_console();
@@ -588,8 +598,7 @@ static int log_dispatch(
}
if (k <= 0) {
- k = write_to_console(level, file, line, func,
- object_name, object, buffer);
+ k = write_to_console(level, error, file, line, func, object_field, object, buffer);
if (k < 0)
return k;
}
@@ -602,6 +611,7 @@ static int log_dispatch(
int log_dump_internal(
int level,
+ int error,
const char*file,
int line,
const char *func,
@@ -614,16 +624,17 @@ int log_dump_internal(
if (_likely_(LOG_PRI(level) > log_max_level))
return 0;
- return log_dispatch(level, file, line, func, NULL, NULL, buffer);
+ return log_dispatch(level, error, file, line, func, NULL, NULL, buffer);
}
int log_metav(
- int level,
- const char*file,
- int line,
- const char *func,
- const char *format,
- va_list ap) {
+ int level,
+ int error,
+ const char*file,
+ int line,
+ const char *func,
+ const char *format,
+ va_list ap) {
PROTECT_ERRNO;
char buffer[LINE_MAX];
@@ -631,38 +642,44 @@ int log_metav(
if (_likely_(LOG_PRI(level) > log_max_level))
return 0;
+ /* Make sure that %m maps to the specified error */
+ if (error != 0)
+ errno = error;
+
vsnprintf(buffer, sizeof(buffer), format, ap);
char_array_0(buffer);
- return log_dispatch(level, file, line, func, NULL, NULL, buffer);
+ return log_dispatch(level, error, file, line, func, NULL, NULL, buffer);
}
int log_meta(
- int level,
- const char*file,
- int line,
- const char *func,
- const char *format, ...) {
+ int level,
+ int error,
+ const char*file,
+ int line,
+ const char *func,
+ const char *format, ...) {
int r;
va_list ap;
va_start(ap, format);
- r = log_metav(level, file, line, func, format, ap);
+ r = log_metav(level, error, file, line, func, format, ap);
va_end(ap);
return r;
}
int log_metav_object(
- int level,
- const char*file,
- int line,
- const char *func,
- const char *object_name,
- const char *object,
- const char *format,
- va_list ap) {
+ int level,
+ int error,
+ const char*file,
+ int line,
+ const char *func,
+ const char *object_field,
+ const char *object,
+ const char *format,
+ va_list ap) {
PROTECT_ERRNO;
char buffer[LINE_MAX];
@@ -670,34 +687,44 @@ int log_metav_object(
if (_likely_(LOG_PRI(level) > log_max_level))
return 0;
+ /* Make sure that %m maps to the specified error */
+ if (error != 0)
+ errno = error;
+
vsnprintf(buffer, sizeof(buffer), format, ap);
char_array_0(buffer);
- return log_dispatch(level, file, line, func,
- object_name, object, buffer);
+ return log_dispatch(level, error, file, line, func, object_field, object, buffer);
}
int log_meta_object(
- int level,
- const char*file,
- int line,
- const char *func,
- const char *object_name,
- const char *object,
- const char *format, ...) {
+ int level,
+ int error,
+ const char*file,
+ int line,
+ const char *func,
+ const char *object_field,
+ const char *object,
+ const char *format, ...) {
int r;
va_list ap;
va_start(ap, format);
- r = log_metav_object(level, file, line, func,
- object_name, object, format, ap);
+ r = log_metav_object(level, error, file, line, func, object_field, object, format, ap);
va_end(ap);
return r;
}
-static void log_assert(int level, const char *text, const char *file, int line, const char *func, const char *format) {
+static void log_assert(
+ int level,
+ const char *text,
+ const char *file,
+ int line,
+ const char *func,
+ const char *format) {
+
static char buffer[LINE_MAX];
if (_likely_(LOG_PRI(level) > log_max_level))
@@ -710,7 +737,7 @@ static void log_assert(int level, const char *text, const char *file, int line,
char_array_0(buffer);
log_abort_msg = buffer;
- log_dispatch(level, file, line, func, NULL, NULL, buffer);
+ log_dispatch(level, 0, file, line, func, NULL, NULL, buffer);
}
noreturn void log_assert_failed(const char *text, const char *file, int line, const char *func) {
@@ -729,12 +756,13 @@ void log_assert_failed_return(const char *text, const char *file, int line, cons
}
int log_oom_internal(const char *file, int line, const char *func) {
- log_meta(LOG_ERR, file, line, func, "Out of memory.");
+ log_meta(LOG_ERR, ENOMEM, file, line, func, "Out of memory.");
return -ENOMEM;
}
int log_struct_internal(
int level,
+ int error,
const char *file,
int line,
const char *func,
@@ -767,8 +795,7 @@ int log_struct_internal(
static const char nl = '\n';
/* If the journal is available do structured logging */
- log_do_header(header, sizeof(header), level,
- file, line, func, NULL, NULL);
+ log_do_header(header, sizeof(header), level, error, file, line, func, NULL, NULL);
IOVEC_SET_STRING(iovec[n++], header);
va_start(ap, format);
@@ -840,8 +867,7 @@ int log_struct_internal(
va_end(ap);
if (found)
- r = log_dispatch(level, file, line, func,
- NULL, NULL, buf + 8);
+ r = log_dispatch(level, error, file, line, func, NULL, NULL, buf + 8);
else
r = -EINVAL;
}
diff --git a/src/shared/log.h b/src/shared/log.h
index 8141e9d..9dd68df 100644
--- a/src/shared/log.h
+++ b/src/shared/log.h
@@ -77,44 +77,49 @@ void log_parse_environment(void);
int log_meta(
int level,
+ int error,
const char*file,
int line,
const char *func,
- const char *format, ...) _printf_(5,6);
+ const char *format, ...) _printf_(6,7);
int log_metav(
int level,
+ int error,
const char*file,
int line,
const char *func,
const char *format,
- va_list ap) _printf_(5,0);
+ va_list ap) _printf_(6,0);
int log_meta_object(
int level,
+ int error,
const char*file,
int line,
const char *func,
const char *object_name,
const char *object,
- const char *format, ...) _printf_(7,8);
+ const char *format, ...) _printf_(8,9);
int log_metav_object(
int level,
+ int error,
const char*file,
int line,
const char *func,
const char *object_name,
const char *object,
const char *format,
- va_list ap) _printf_(7,0);
+ va_list ap) _printf_(8,0);
int log_struct_internal(
int level,
+ int error,
const char *file,
int line,
const char *func,
- const char *format, ...) _printf_(5,0) _sentinel_;
+ const char *format, ...) _printf_(6,0) _sentinel_;
int log_oom_internal(
const char *file,
@@ -124,11 +129,13 @@ int log_oom_internal(
/* This modifies the buffer passed! */
int log_dump_internal(
int level,
+ int error,
const char*file,
int line,
const char *func,
char *buffer);
+/* Logging for various assertions */
noreturn void log_assert_failed(
const char *text,
const char *file,
@@ -147,12 +154,16 @@ void log_assert_failed_return(
int line,
const char *func);
-#define log_full(level, ...) \
-do { \
- if (log_get_max_level() >= (level)) \
- log_meta((level), __FILE__, __LINE__, __func__, __VA_ARGS__); \
-} while (0)
+/* Logging with level */
+#define log_full_errno(level, error, ...) \
+ do { \
+ if (log_get_max_level() >= (level)) \
+ log_meta((level), error, __FILE__, __LINE__, __func__, __VA_ARGS__); \
+ } while (false)
+#define log_full(level, ...) log_full_errno(level, 0, __VA_ARGS__)
+
+/* Normal logging */
#define log_debug(...) log_full(LOG_DEBUG, __VA_ARGS__)
#define log_info(...) log_full(LOG_INFO, __VA_ARGS__)
#define log_notice(...) log_full(LOG_NOTICE, __VA_ARGS__)
@@ -160,18 +171,28 @@ do { \
#define log_error(...) log_full(LOG_ERR, __VA_ARGS__)
#define log_emergency(...) log_full(getpid() == 1 ? LOG_EMERG : LOG_ERR, __VA_ARGS__)
+/* Logging triggered by an errno-like error */
+#define log_debug_errno(error, ...) log_full_errno(LOG_DEBUG, error, __VA_ARGS__)
+#define log_info_errno(error, ...) log_full_errno(LOG_INFO, error, __VA_ARGS__)
+#define log_notice_errno(error, ...) log_full_errno(LOG_NOTICE, error, __VA_ARGS__)
+#define log_warning_errno(error, ...) log_full_errno(LOG_WARNING, error, __VA_ARGS__)
+#define log_error_errno(error, ...) log_full_errno(LOG_ERR, error, __VA_ARGS__)
+#define log_emergency_errno(error, ...) log_full_errno(getpid() == 1 ? LOG_EMERG : LOG_ERR, __VA_ARGS__)
+
#ifdef LOG_TRACE
# define log_trace(...) log_debug(__VA_ARGS__)
#else
# define log_trace(...) do {} while(0)
#endif
-#define log_struct(level, ...) log_struct_internal(level, __FILE__, __LINE__, __func__, __VA_ARGS__)
-
-#define log_oom() log_oom_internal(__FILE__, __LINE__, __func__)
+/* Structured logging */
+#define log_struct(level, ...) log_struct_internal(level, 0, __FILE__, __LINE__, __func__, __VA_ARGS__)
+#define log_struct_errno(level, error, ...) log_struct_internal(level, error, __FILE__, __LINE__, __func__, __VA_ARGS__)
/* This modifies the buffer passed! */
-#define log_dump(level, buffer) log_dump_internal(level, __FILE__, __LINE__, __func__, buffer)
+#define log_dump(level, buffer) log_dump_internal(level, 0, __FILE__, __LINE__, __func__, buffer)
+
+#define log_oom() log_oom_internal(__FILE__, __LINE__, __func__)
bool log_on_console(void) _pure_;
diff --git a/src/test/test-hostname.c b/src/test/test-hostname.c
index ad4f285..1bc4126 100644
--- a/src/test/test-hostname.c
+++ b/src/test/test-hostname.c
@@ -32,7 +32,7 @@ int main(int argc, char* argv[]) {
r = hostname_setup();
if (r < 0)
- fprintf(stderr, "hostname: %s\n", strerror(-r));
+ log_error_errno(-r, "hostname: %m");
return 0;
}
diff --git a/src/udev/udev-builtin-kmod.c b/src/udev/udev-builtin-kmod.c
index 66807b3..f3d1647 100644
--- a/src/udev/udev-builtin-kmod.c
+++ b/src/udev/udev-builtin-kmod.c
@@ -31,7 +31,7 @@
#include "udev.h"
-static struct kmod_ctx *ctx;
+static struct kmod_ctx *ctx = NULL;
static int load_module(struct udev *udev, const char *alias) {
struct kmod_list *list = NULL;
@@ -43,18 +43,18 @@ static int load_module(struct udev *udev, const char *alias) {
return err;
if (list == NULL)
- log_debug("no module matches '%s'", alias);
+ log_debug("No module matches '%s'", alias);
kmod_list_foreach(l, list) {
struct kmod_module *mod = kmod_module_get_module(l);
err = kmod_module_probe_insert_module(mod, KMOD_PROBE_APPLY_BLACKLIST, NULL, NULL, NULL, NULL);
if (err == KMOD_PROBE_APPLY_BLACKLIST)
- log_debug("module '%s' is blacklisted", kmod_module_get_name(mod));
+ log_debug("Module '%s' is blacklisted", kmod_module_get_name(mod));
else if (err == 0)
- log_debug("inserted '%s'", kmod_module_get_name(mod));
+ log_debug("Inserted '%s'", kmod_module_get_name(mod));
else
- log_debug("failed to insert '%s'", kmod_module_get_name(mod));
+ log_debug("Failed to insert '%s'", kmod_module_get_name(mod));
kmod_module_unref(mod);
}
@@ -63,10 +63,8 @@ static int load_module(struct udev *udev, const char *alias) {
return err;
}
-_printf_(6,0)
-static void udev_kmod_log(void *data, int priority, const char *file, int line,
- const char *fn, const char *format, va_list args) {
- log_metav(priority, file, line, fn, format, args);
+_printf_(6,0) static void udev_kmod_log(void *data, int priority, const char *file, int line, const char *fn, const char *format, va_list args) {
+ log_metav(priority, 0, file, line, fn, format, args);
}
static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool test) {
@@ -82,7 +80,7 @@ static int builtin_kmod(struct udev_device *dev, int argc, char *argv[], bool te
}
for (i = 2; argv[i]; i++) {
- log_debug("execute '%s' '%s'", argv[1], argv[i]);
+ log_debug("Execute '%s' '%s'", argv[1], argv[i]);
load_module(udev, argv[i]);
}
@@ -98,7 +96,7 @@ static int builtin_kmod_init(struct udev *udev) {
if (!ctx)
return -ENOMEM;
- log_debug("load module index");
+ log_debug("Load module index");
kmod_set_log_fn(ctx, udev_kmod_log, udev);
kmod_load_resources(ctx);
return 0;
@@ -106,13 +104,13 @@ static int builtin_kmod_init(struct udev *udev) {
/* called on udev shutdown and reload request */
static void builtin_kmod_exit(struct udev *udev) {
- log_debug("unload module index");
+ log_debug("Unload module index");
ctx = kmod_unref(ctx);
}
/* called every couple of seconds during event activity; 'true' if config has changed */
static bool builtin_kmod_validate(struct udev *udev) {
- log_debug("validate module index");
+ log_debug("Validate module index");
if (!ctx)
return false;
return (kmod_validate_resources(ctx) != KMOD_RESOURCES_OK);
commit fb6d9b77a71a5f007392b754bf7d8e06a6bed69a
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Nov 27 12:52:13 2014 +0100
sd-bus: set creds info for "org.freedesktop.DBus.Local" generated messages, too
diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c
index e3bdda8..886e212 100644
--- a/src/libsystemd/sd-bus/bus-creds.c
+++ b/src/libsystemd/sd-bus/bus-creds.c
@@ -563,6 +563,16 @@ _public_ int sd_bus_creds_get_well_known_names(sd_bus_creds *c, char ***well_kno
return 0;
}
+ if (c->well_known_names_local) {
+ static const char* const wkn[] = {
+ "org.freedesktop.DBus.Local",
+ NULL
+ };
+
+ *well_known_names = (char**) wkn;
+ return 0;
+ }
+
*well_known_names = c->well_known_names;
return 0;
}
diff --git a/src/libsystemd/sd-bus/bus-creds.h b/src/libsystemd/sd-bus/bus-creds.h
index 9d6a5bf..5267170 100644
--- a/src/libsystemd/sd-bus/bus-creds.h
+++ b/src/libsystemd/sd-bus/bus-creds.h
@@ -72,7 +72,8 @@ struct sd_bus_creds {
char *unique_name;
char **well_known_names;
- bool well_known_names_driver;
+ bool well_known_names_driver:1;
+ bool well_known_names_local:1;
char *cgroup_root;
diff --git a/src/libsystemd/sd-bus/sd-bus.c b/src/libsystemd/sd-bus/sd-bus.c
index ea056d8..8f97a58 100644
--- a/src/libsystemd/sd-bus/sd-bus.c
+++ b/src/libsystemd/sd-bus/sd-bus.c
@@ -2505,6 +2505,15 @@ null_message:
return r;
}
+static void bus_message_set_sender_local(sd_bus *bus, sd_bus_message *m) {
+ assert(bus);
+ assert(m);
+
+ m->sender = m->creds.unique_name = (char*) "org.freedesktop.DBus.Local";
+ m->creds.well_known_names_local = true;
+ m->creds.mask |= (SD_BUS_CREDS_UNIQUE_NAME|SD_BUS_CREDS_WELL_KNOWN_NAMES) & bus->creds_mask;
+}
+
static int process_closing(sd_bus *bus, sd_bus_message **ret) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
struct reply_callback *c;
@@ -2573,7 +2582,7 @@ static int process_closing(sd_bus *bus, sd_bus_message **ret) {
if (r < 0)
return r;
- m->sender = "org.freedesktop.DBus.Local";
+ bus_message_set_sender_local(bus, m);
r = bus_seal_synthetic_message(bus, m);
if (r < 0)
commit 38ce47e262fbb76b6f6514e8e80cacfc584bee5a
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Nov 27 12:51:22 2014 +0100
sd-bus: when we get the list of well-known names back from kdbus we shouldn't confuse the empty list with unknown information
diff --git a/src/libsystemd/sd-bus/bus-control.c b/src/libsystemd/sd-bus/bus-control.c
index 758715d..e6e905c 100644
--- a/src/libsystemd/sd-bus/bus-control.c
+++ b/src/libsystemd/sd-bus/bus-control.c
@@ -692,6 +692,13 @@ static int bus_get_name_creds_kdbus(
c->mask |= SD_BUS_CREDS_UNIQUE_NAME;
}
+ /* If KDBUS_ITEM_OWNED_NAME is requested then we'll get 0 of
+ them in case the service has no names. This does not mean
+ however that the list of owned names could not be
+ acquired. Hence, let's explicitly clarify that the data is
+ complete. */
+ c->mask |= mask & SD_BUS_CREDS_WELL_KNOWN_NAMES;
+
r = bus_populate_creds_from_items(bus, conn_info, mask, c);
if (r < 0)
goto fail;
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 3a3ed20..3bf7b07 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -717,6 +717,14 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k) {
}
}
+ /* If we requested the list of well-known names to be appended
+ * and the sender had none no item for it will be
+ * attached. However, this does *not* mean that we the kernel
+ * didn't want to provide this information to us. Hence, let's
+ * explicitly mark this information as available if it was
+ * requested. */
+ m->creds.mask |= bus->creds_mask & SD_BUS_CREDS_WELL_KNOWN_NAMES;
+
r = bus_message_parse_fields(m);
if (r < 0)
goto fail;
commit 771b2724c0f9591e8f4dd7463c15bf0c957737dc
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Nov 27 03:20:51 2014 +0100
sd-bus: deal with whitespace in matches
diff --git a/src/libsystemd/sd-bus/bus-match.c b/src/libsystemd/sd-bus/bus-match.c
index 5658c61..0e92a85 100644
--- a/src/libsystemd/sd-bus/bus-match.c
+++ b/src/libsystemd/sd-bus/bus-match.c
@@ -748,6 +748,9 @@ int bus_match_parse(
bool escaped = false, quoted;
uint8_t u;
+ /* Avahi's match rules appear to include whitespace, skip over it */
+ p += strspn(p, " ");
+
eq = strchr(p, '=');
if (!eq)
return -EINVAL;
commit 7d31d92400bab9648016136da1b1e8c5cff1bfcf
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Nov 27 02:57:22 2014 +0100
sd-bus: unify logic how we patch the message source of driver messages
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 9349c1d..3a3ed20 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -348,6 +348,15 @@ fail:
return r;
}
+static void bus_message_set_sender_driver(sd_bus *bus, sd_bus_message *m) {
+ assert(bus);
+ assert(m);
+
+ m->sender = m->creds.unique_name = (char*) "org.freedesktop.DBus";
+ m->creds.well_known_names_driver = true;
+ m->creds.mask |= (SD_BUS_CREDS_UNIQUE_NAME|SD_BUS_CREDS_WELL_KNOWN_NAMES) & bus->creds_mask;
+}
+
static void unset_memfds(struct sd_bus_message *m) {
struct bus_body_part *part;
unsigned i;
@@ -737,11 +746,9 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k) {
}
/* Override information from the user header with data from the kernel */
- if (k->src_id == KDBUS_SRC_ID_KERNEL) {
- m->sender = m->creds.unique_name = (char*) "org.freedesktop.DBus";
- m->creds.well_known_names_driver = true;
- m->creds.mask |= SD_BUS_CREDS_WELL_KNOWN_NAMES & bus->creds_mask;
- } else {
+ if (k->src_id == KDBUS_SRC_ID_KERNEL)
+ bus_message_set_sender_driver(bus, m);
+ else {
snprintf(m->sender_buffer, sizeof(m->sender_buffer), ":1.%llu", (unsigned long long) k->src_id);
m->sender = m->creds.unique_name = m->sender_buffer;
}
@@ -1075,9 +1082,7 @@ static int push_name_owner_changed(sd_bus *bus, const char *name, const char *ol
if (r < 0)
return r;
- m->sender = "org.freedesktop.DBus";
- m->creds.well_known_names_driver = true;
- m->creds.mask |= SD_BUS_CREDS_WELL_KNOWN_NAMES & bus->creds_mask;
+ bus_message_set_sender_driver(bus, m);
r = bus_seal_synthetic_message(bus, m);
if (r < 0)
@@ -1146,9 +1151,7 @@ static int translate_reply(sd_bus *bus, struct kdbus_msg *k, struct kdbus_item *
if (r < 0)
return r;
- m->sender = "org.freedesktop.DBus";
- m->creds.well_known_names_driver = true;
- m->creds.mask |= SD_BUS_CREDS_WELL_KNOWN_NAMES & bus->creds_mask;
+ bus_message_set_sender_driver(bus, m);
r = bus_seal_synthetic_message(bus, m);
if (r < 0)
commit ac653862e0a99505727dc8861e734d8d6f2b0afd
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Nov 27 02:37:05 2014 +0100
sd-bus: fake valid well-known-names metadata for faked bus messages
diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c
index ad0e2e1..e3bdda8 100644
--- a/src/libsystemd/sd-bus/bus-creds.c
+++ b/src/libsystemd/sd-bus/bus-creds.c
@@ -551,6 +551,18 @@ _public_ int sd_bus_creds_get_well_known_names(sd_bus_creds *c, char ***well_kno
if (!(c->mask & SD_BUS_CREDS_WELL_KNOWN_NAMES))
return -ENODATA;
+ /* As a special hack we return the bus driver as well-known
+ * names list when this is requested. */
+ if (c->well_known_names_driver) {
+ static const char* const wkn[] = {
+ "org.freedesktop.DBus",
+ NULL
+ };
+
+ *well_known_names = (char**) wkn;
+ return 0;
+ }
+
*well_known_names = c->well_known_names;
return 0;
}
diff --git a/src/libsystemd/sd-bus/bus-creds.h b/src/libsystemd/sd-bus/bus-creds.h
index 882110b..9d6a5bf 100644
--- a/src/libsystemd/sd-bus/bus-creds.h
+++ b/src/libsystemd/sd-bus/bus-creds.h
@@ -72,6 +72,7 @@ struct sd_bus_creds {
char *unique_name;
char **well_known_names;
+ bool well_known_names_driver;
char *cgroup_root;
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 1276cd8..9349c1d 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -737,9 +737,11 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k) {
}
/* Override information from the user header with data from the kernel */
- if (k->src_id == KDBUS_SRC_ID_KERNEL)
+ if (k->src_id == KDBUS_SRC_ID_KERNEL) {
m->sender = m->creds.unique_name = (char*) "org.freedesktop.DBus";
- else {
+ m->creds.well_known_names_driver = true;
+ m->creds.mask |= SD_BUS_CREDS_WELL_KNOWN_NAMES & bus->creds_mask;
+ } else {
snprintf(m->sender_buffer, sizeof(m->sender_buffer), ":1.%llu", (unsigned long long) k->src_id);
m->sender = m->creds.unique_name = m->sender_buffer;
}
@@ -1074,6 +1076,8 @@ static int push_name_owner_changed(sd_bus *bus, const char *name, const char *ol
return r;
m->sender = "org.freedesktop.DBus";
+ m->creds.well_known_names_driver = true;
+ m->creds.mask |= SD_BUS_CREDS_WELL_KNOWN_NAMES & bus->creds_mask;
r = bus_seal_synthetic_message(bus, m);
if (r < 0)
@@ -1143,6 +1147,8 @@ static int translate_reply(sd_bus *bus, struct kdbus_msg *k, struct kdbus_item *
return r;
m->sender = "org.freedesktop.DBus";
+ m->creds.well_known_names_driver = true;
+ m->creds.mask |= SD_BUS_CREDS_WELL_KNOWN_NAMES & bus->creds_mask;
r = bus_seal_synthetic_message(bus, m);
if (r < 0)
commit 50c4521675e94ade38b8af9e3b0f7fd2f300b6f4
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Nov 27 02:28:23 2014 +0100
sd-bus: optimize how we generate the well-known-names lists in messages from kdbus
diff --git a/src/libsystemd/sd-bus/bus-creds.c b/src/libsystemd/sd-bus/bus-creds.c
index 8aa5336..ad0e2e1 100644
--- a/src/libsystemd/sd-bus/bus-creds.c
+++ b/src/libsystemd/sd-bus/bus-creds.c
@@ -51,8 +51,14 @@ void bus_creds_done(sd_bus_creds *c) {
free(c->slice);
free(c->unescaped_description);
+ free(c->well_known_names); /* note that this is an strv, but
+ * we only free the array, not the
+ * strings the array points to. The
+ * full strv we only free if
+ * c->allocated is set, see
+ * below. */
+
strv_free(c->cmdline_array);
- strv_free(c->well_known_names);
}
_public_ sd_bus_creds *sd_bus_creds_ref(sd_bus_creds *c) {
@@ -83,8 +89,6 @@ _public_ sd_bus_creds *sd_bus_creds_unref(sd_bus_creds *c) {
c->n_ref--;
if (c->n_ref == 0) {
- bus_creds_done(c);
-
free(c->comm);
free(c->tid_comm);
free(c->exe);
@@ -96,6 +100,12 @@ _public_ sd_bus_creds *sd_bus_creds_unref(sd_bus_creds *c) {
free(c->cgroup_root);
free(c->description);
free(c->supplementary_gids);
+
+ strv_free(c->well_known_names);
+ c->well_known_names = NULL;
+
+ bus_creds_done(c);
+
free(c);
}
} else {
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index ef157d6..1276cd8 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -660,9 +660,23 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k) {
}
if (bus->creds_mask & SD_BUS_CREDS_WELL_KNOWN_NAMES) {
- r = strv_extend(&m->creds.well_known_names, d->name.name);
- if (r < 0)
+ char **wkn;
+ size_t n;
+
+ /* We just extend the array here, but
+ * do not allocate the strings inside
+ * of it, instead we just point to our
+ * buffer directly. */
+ n = strv_length(m->creds.well_known_names);
+ wkn = realloc(m->creds.well_known_names, (n + 2) * sizeof(char*));
+ if (!wkn) {
+ r = -ENOMEM;
goto fail;
+ }
+
+ wkn[n] = d->name.name;
+ wkn[n+1] = NULL;
+ m->creds.well_known_names = wkn;
m->creds.mask |= SD_BUS_CREDS_WELL_KNOWN_NAMES;
}
commit 7fa934b0d35492b300b79848f4822ffc40eee21f
Author: Lennart Poettering <lennart at poettering.net>
Date: Thu Nov 27 01:19:50 2014 +0100
sd-bus: be stricter with mismatches between dbus1 and kdbus message headers
diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c
index 651ca47..ef157d6 100644
--- a/src/libsystemd/sd-bus/bus-kernel.c
+++ b/src/libsystemd/sd-bus/bus-kernel.c
@@ -268,23 +268,22 @@ static int bus_message_setup_kmsg(sd_bus *b, sd_bus_message *m) {
((m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED) ? 0 : KDBUS_MSG_FLAGS_EXPECT_REPLY) |
((m->header->flags & BUS_MESSAGE_NO_AUTO_START) ? KDBUS_MSG_FLAGS_NO_AUTO_START : 0);
- if (well_known) {
+ if (well_known)
/* verify_destination_id will usually be 0, which makes the kernel driver only look
* at the provided well-known name. Otherwise, the kernel will make sure the provided
* destination id matches the owner of the provided weel-known-name, and fail if they
* differ. Currently, this is only needed for bus-proxyd. */
m->kdbus->dst_id = m->verify_destination_id;
- } else {
+ else
m->kdbus->dst_id = destination ? unique : KDBUS_DST_ID_BROADCAST;
- }
m->kdbus->payload_type = KDBUS_PAYLOAD_DBUS;
m->kdbus->cookie = (uint64_t) m->header->serial;
m->kdbus->priority = m->priority;
- if (m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED) {
+ if (m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED)
m->kdbus->cookie_reply = m->reply_cookie;
- } else {
+ else {
struct timespec now;
assert_se(clock_gettime(CLOCK_MONOTONIC_COARSE, &now) == 0);
@@ -699,6 +698,30 @@ static int bus_kernel_make_message(sd_bus *bus, struct kdbus_msg *k) {
if (r < 0)
goto fail;
+ /* Refuse messages if kdbus and dbus1 cookie doesn't match up */
+ if ((uint64_t) m->header->serial != k->cookie) {
+ r = -EBADMSG;
+ goto fail;
+ }
+
+ /* Refuse messages where the reply flag doesn't match up */
+ if (!(m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED) != !!(k->flags & KDBUS_MSG_FLAGS_EXPECT_REPLY)) {
+ r = -EBADMSG;
+ goto fail;
+ }
+
+ /* Refuse reply messages where the reply cookie doesn't match up */
+ if ((m->header->flags & BUS_MESSAGE_NO_REPLY_EXPECTED) && m->reply_cookie != k->cookie_reply) {
+ r = -EBADMSG;
+ goto fail;
+ }
+
+ /* Refuse messages where the autostart flag doesn't match up */
+ if (!(m->header->flags & BUS_MESSAGE_NO_AUTO_START) != !(k->flags & KDBUS_MSG_FLAGS_NO_AUTO_START)) {
+ r = -EBADMSG;
+ goto fail;
+ }
+
/* Override information from the user header with data from the kernel */
if (k->src_id == KDBUS_SRC_ID_KERNEL)
m->sender = m->creds.unique_name = (char*) "org.freedesktop.DBus";
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index 9bc05c2..a4939b4 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -5170,6 +5170,10 @@ int bus_message_parse_fields(sd_bus_message *m) {
case SD_BUS_MESSAGE_SIGNAL:
if (!m->path || !m->interface || !m->member)
return -EBADMSG;
+
+ if (m->reply_cookie != 0)
+ return -EBADMSG;
+
break;
case SD_BUS_MESSAGE_METHOD_CALL:
@@ -5177,6 +5181,9 @@ int bus_message_parse_fields(sd_bus_message *m) {
if (!m->path || !m->member)
return -EBADMSG;
+ if (m->reply_cookie != 0)
+ return -EBADMSG;
+
break;
case SD_BUS_MESSAGE_METHOD_RETURN:
commit 78f9b196ab9671ceb625cd2abf90629ed201c24f
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Nov 26 23:14:13 2014 +0100
bus-proxy: beef up policy enforcement
- actually return permission errors to clients
- use the right ucreds field
- fix error paths when we cannot keep track of locally acquired names
due to OOM
- avoid unnecessary global variables
- log when the policy denies access
- enforce correct policy rule order
- always request all the metadata its we need to make decisions
diff --git a/src/bus-proxyd/bus-policy.c b/src/bus-proxyd/bus-policy.c
index d543bf9..3cfe9be 100644
--- a/src/bus-proxyd/bus-policy.c
+++ b/src/bus-proxyd/bus-policy.c
@@ -593,14 +593,29 @@ static int file_load(Policy *p, const char *path) {
}
enum {
+ DENY,
ALLOW,
DUNNO,
- DENY,
};
+static const char *verdict_to_string(int v) {
+ switch (v) {
+
+ case DENY:
+ return "DENY";
+ case ALLOW:
+ return "ALLOW";
+ case DUNNO:
+ return "DUNNO";
+ }
+
+ return NULL;
+}
+
struct policy_check_filter {
PolicyItemClass class;
- const struct ucred *ucred;
+ uid_t uid;
+ gid_t gid;
int message_type;
const char *name;
const char *interface;
@@ -656,17 +671,15 @@ static int check_policy_item(PolicyItem *i, const struct policy_check_filter *fi
break;
case POLICY_ITEM_USER:
- assert(filter->ucred);
-
- if ((streq_ptr(i->name, "*") || (i->uid_valid && i->uid == filter->ucred->uid)))
- return is_permissive(i);
+ if (filter->uid != (uid_t) -1)
+ if ((streq_ptr(i->name, "*") || (i->uid_valid && i->uid == filter->uid)))
+ return is_permissive(i);
break;
case POLICY_ITEM_GROUP:
- assert(filter->ucred);
-
- if ((streq_ptr(i->name, "*") || (i->gid_valid && i->gid == filter->ucred->gid)))
- return is_permissive(i);
+ if (filter->gid != (gid_t) -1)
+ if ((streq_ptr(i->name, "*") || (i->gid_valid && i->gid == filter->gid)))
+ return is_permissive(i);
break;
case POLICY_ITEM_IGNORE:
@@ -680,29 +693,31 @@ static int check_policy_item(PolicyItem *i, const struct policy_check_filter *fi
static int check_policy_items(PolicyItem *items, const struct policy_check_filter *filter) {
PolicyItem *i;
- int r, ret = DUNNO;
+ int verdict = DUNNO;
assert(filter);
/* Check all policies in a set - a broader one might be followed by a more specific one,
* and the order of rules in policy definitions matters */
LIST_FOREACH(items, i, items) {
+ int v;
+
if (i->class != filter->class &&
!(i->class == POLICY_ITEM_OWN_PREFIX && filter->class == POLICY_ITEM_OWN))
continue;
- r = check_policy_item(i, filter);
- if (r != DUNNO)
- ret = r;
+ v = check_policy_item(i, filter);
+ if (v != DUNNO)
+ verdict = v;
}
- return ret;
+ return verdict;
}
static int policy_check(Policy *p, const struct policy_check_filter *filter) {
PolicyItem *items;
- int r;
+ int verdict, v;
assert(p);
assert(filter);
@@ -712,68 +727,96 @@ static int policy_check(Policy *p, const struct policy_check_filter *filter) {
/*
* The policy check is implemented by the following logic:
*
- * 1. Check mandatory items. If the message matches any of these, it is decisive.
- * 2. See if the passed ucred match against the user/group hashmaps. A matching entry is also decisive.
- * 3. Consult the defaults if non of the above matched with a more specific rule.
- * 4. If the message isn't caught be the defaults either, reject it.
+ * 1. Check default items
+ * 2. Check group items
+ * 3. Check user items
+ * 4. Check mandatory items
+ *
+ * Later rules override earlier rules.
*/
- r = check_policy_items(p->mandatory_items, filter);
- if (r != DUNNO)
- return r;
+ verdict = check_policy_items(p->default_items, filter);
- if (filter->ucred) {
- items = hashmap_get(p->user_items, UINT32_TO_PTR(filter->ucred->uid));
+ if (filter->gid != (gid_t) -1) {
+ items = hashmap_get(p->group_items, UINT32_TO_PTR(filter->gid));
if (items) {
- r = check_policy_items(items, filter);
- if (r != DUNNO)
- return r;
+ v = check_policy_items(items, filter);
+ if (v != DUNNO)
+ verdict = v;
}
+ }
- items = hashmap_get(p->group_items, UINT32_TO_PTR(filter->ucred->gid));
+ if (filter->uid != (uid_t) -1) {
+ items = hashmap_get(p->user_items, UINT32_TO_PTR(filter->uid));
if (items) {
- r = check_policy_items(items, filter);
- if (r != DUNNO)
- return r;
+ v = check_policy_items(items, filter);
+ if (v != DUNNO)
+ verdict = v;
}
}
- return check_policy_items(p->default_items, filter);
+ v = check_policy_items(p->mandatory_items, filter);
+ if (v != DUNNO)
+ verdict = v;
+
+ return verdict;
}
-bool policy_check_own(Policy *p, const struct ucred *ucred, const char *name) {
+bool policy_check_own(Policy *p, uid_t uid, gid_t gid, const char *name) {
struct policy_check_filter filter = {
.class = POLICY_ITEM_OWN,
- .ucred = ucred,
+ .uid = uid,
+ .gid = gid,
.name = name,
};
- return policy_check(p, &filter) == ALLOW;
+ int verdict;
+
+ assert(p);
+ assert(name);
+
+ verdict = policy_check(p, &filter);
+
+ log_full(LOG_AUTH | (verdict != ALLOW ? LOG_WARNING : LOG_DEBUG),
+ "Ownership permission check for uid=" UID_FMT " gid=" GID_FMT" name=%s: %s",
+ uid, gid, strna(name), strna(verdict_to_string(verdict)));
+
+ return verdict == ALLOW;
}
-bool policy_check_hello(Policy *p, const struct ucred *ucred) {
+bool policy_check_hello(Policy *p, uid_t uid, gid_t gid) {
struct policy_check_filter filter = {
- .ucred = ucred,
+ .uid = uid,
+ .gid = gid,
};
- int user, group;
+ int verdict;
+
+ assert(p);
filter.class = POLICY_ITEM_USER;
- user = policy_check(p, &filter);
- if (user == DENY)
- return false;
+ verdict = policy_check(p, &filter);
+
+ if (verdict != DENY) {
+ int v;
- filter.class = POLICY_ITEM_GROUP;
- group = policy_check(p, &filter);
- if (group == DENY)
- return false;
+ filter.class = POLICY_ITEM_GROUP;
+ v = policy_check(p, &filter);
+ if (v != DUNNO)
+ verdict = v;
+ }
- return !(user == DUNNO && group == DUNNO);
+ log_full(LOG_AUTH | (verdict != ALLOW ? LOG_WARNING : LOG_DEBUG),
+ "Hello permission check for uid=" UID_FMT " gid=" GID_FMT": %s",
+ uid, gid, strna(verdict_to_string(verdict)));
+
+ return verdict == ALLOW;
}
bool policy_check_recv(Policy *p,
- const struct ucred *ucred,
+ uid_t uid,
+ gid_t gid,
int message_type,
const char *name,
const char *path,
@@ -782,7 +825,8 @@ bool policy_check_recv(Policy *p,
struct policy_check_filter filter = {
.class = POLICY_ITEM_RECV,
- .ucred = ucred,
+ .uid = uid,
+ .gid = gid,
.message_type = message_type,
.name = name,
.interface = interface,
@@ -790,11 +834,22 @@ bool policy_check_recv(Policy *p,
.member = member,
};
- return policy_check(p, &filter) == ALLOW;
+ int verdict;
+
+ assert(p);
+
+ verdict = policy_check(p, &filter);
+
+ log_full(LOG_AUTH | (verdict != ALLOW ? LOG_WARNING : LOG_DEBUG),
+ "Recieve permission check for uid=" UID_FMT " gid=" GID_FMT" message=%s name=%s interface=%s path=%s member=%s: %s",
+ uid, gid, bus_message_type_to_string(message_type), strna(name), strna(path), strna(interface), strna(member), strna(verdict_to_string(verdict)));
+
+ return verdict == ALLOW;
}
bool policy_check_send(Policy *p,
- const struct ucred *ucred,
+ uid_t uid,
+ gid_t gid,
int message_type,
const char *name,
const char *path,
@@ -803,7 +858,8 @@ bool policy_check_send(Policy *p,
struct policy_check_filter filter = {
.class = POLICY_ITEM_SEND,
- .ucred = ucred,
+ .uid = uid,
+ .gid = gid,
.message_type = message_type,
.name = name,
.interface = interface,
@@ -811,7 +867,17 @@ bool policy_check_send(Policy *p,
.member = member,
};
- return policy_check(p, &filter) == ALLOW;
+ int verdict;
+
+ assert(p);
+
+ verdict = policy_check(p, &filter);
+
+ log_full(LOG_AUTH | (verdict != ALLOW ? LOG_WARNING : LOG_DEBUG),
+ "Send permission check for uid=" UID_FMT " gid=" GID_FMT" message=%s name=%s interface=%s path=%s member=%s: %s",
+ uid, gid, bus_message_type_to_string(message_type), strna(name), strna(path), strna(interface), strna(member), strna(verdict_to_string(verdict)));
+
+ return verdict == ALLOW;
}
int policy_load(Policy *p, char **files) {
@@ -939,6 +1005,7 @@ static void dump_items(PolicyItem *items, const char *prefix) {
printf("%sGroup: %s (%d)\n",
prefix, strna(group), i->gid);
}
+ printf("%s-\n", prefix);
}
}
diff --git a/src/bus-proxyd/bus-policy.h b/src/bus-proxyd/bus-policy.h
index 64fe1ff..933a53c 100644
--- a/src/bus-proxyd/bus-policy.h
+++ b/src/bus-proxyd/bus-policy.h
@@ -76,17 +76,19 @@ typedef struct Policy {
int policy_load(Policy *p, char **files);
void policy_free(Policy *p);
-bool policy_check_own(Policy *p, const struct ucred *ucred, const char *name);
-bool policy_check_hello(Policy *p, const struct ucred *ucred);
+bool policy_check_own(Policy *p, uid_t uid, gid_t gid, const char *name);
+bool policy_check_hello(Policy *p, uid_t uid, gid_t gid);
bool policy_check_recv(Policy *p,
- const struct ucred *ucred,
+ uid_t uid,
+ gid_t gid,
int message_type,
const char *name,
const char *path,
const char *interface,
const char *member);
bool policy_check_send(Policy *p,
- const struct ucred *ucred,
+ uid_t uid,
+ gid_t gid,
int message_type,
const char *name,
const char *path,
diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c
index 4df2fb1..50ffd0a 100644
--- a/src/bus-proxyd/bus-proxyd.c
+++ b/src/bus-proxyd/bus-proxyd.c
@@ -51,8 +51,6 @@ static char *arg_command_line_buffer = NULL;
static bool arg_drop_privileges = false;
static char **arg_configuration = NULL;
-static Hashmap *names_hash = NULL;
-
static int help(void) {
printf("%s [OPTIONS...]\n\n"
@@ -442,95 +440,7 @@ static int get_creds_by_message(sd_bus *bus, sd_bus_message *m, uint64_t mask, s
return get_creds_by_name(bus, name, mask, _creds, error);
}
-static int process_policy(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *policy, const struct ucred *ucred) {
- int r;
- char **name;
- char **names_strv;
- bool granted = false;
- Iterator i;
-
- assert(a);
- assert(b);
- assert(m);
-
- if (!policy)
- return 0;
-
- if (b->is_kernel) {
-
- /* The message came from the kernel, and is sent to our legacy client. */
- r = sd_bus_creds_get_well_known_names(&m->creds, &names_strv);
- if (r < 0)
- return r;
-
- STRV_FOREACH(name, names_strv) {
- if (policy_check_send(policy, ucred, m->header->type, *name, m->path, m->interface, m->member)) {
- r = free_and_strdup(&m->destination_ptr, *name);
- if (r < 0)
- break;
-
- granted = true;
- break;
- }
- }
-
- if (r < 0)
- return r;
-
- if (!granted)
- return -EPERM;
-
- granted = false;
-
- HASHMAP_FOREACH(name, names_hash, i) {
- if (policy_check_recv(policy, ucred, m->header->type, *name, m->path, m->interface, m->member))
- return 0;
- }
-
- return -EPERM;
- } else {
- sd_bus_creds *bus_creds;
-
- /* The message came from the legacy client, and is sent to kdbus. */
- r = sd_bus_get_name_creds(a, m->destination, SD_BUS_CREDS_WELL_KNOWN_NAMES, &bus_creds);
- if (r < 0)
- return r;
-
- STRV_FOREACH(name, names_strv) {
- if (policy_check_send(policy, ucred, m->header->type, *name, m->path, m->interface, m->member)) {
- r = free_and_strdup(&m->destination_ptr, *name);
- if (r < 0)
- break;
-
- r = bus_kernel_parse_unique_name(m->sender, &m->verify_destination_id);
- if (r < 0)
- break;
-
- granted = true;
- break;
- }
- }
-
- if (r < 0)
- return r;
-
- if (!granted)
- return -EPERM;
-
- granted = false;
-
- HASHMAP_FOREACH(name, names_hash, i) {
- if (policy_check_recv(policy, ucred, m->header->type, *name, m->path, m->interface, m->member))
- return 0;
- }
-
- return -EPERM;
- }
-
- return 0;
-}
-
-static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *policy, const struct ucred *ucred) {
+static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *policy, const struct ucred *ucred, Set *owned_names) {
int r;
assert(a);
@@ -883,7 +793,7 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
return synthetic_reply_method_errno(m, r, NULL);
}
- hashmap_remove(names_hash, name);
+ set_remove(owned_names, (char*) name);
return synthetic_reply_method_return(m, "u", BUS_NAME_RELEASED);
@@ -909,7 +819,7 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
if (r < 0)
return synthetic_reply_method_errno(m, r, NULL);
- if (policy && !policy_check_own(policy, ucred, name))
+ if (policy && !policy_check_own(policy, ucred->uid, ucred->gid, name))
return synthetic_reply_method_errno(m, -EPERM, NULL);
if ((flags & ~(BUS_NAME_ALLOW_REPLACEMENT|BUS_NAME_REPLACE_EXISTING|BUS_NAME_DO_NOT_QUEUE)) != 0)
@@ -923,21 +833,24 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
if (!(flags & BUS_NAME_DO_NOT_QUEUE))
param |= SD_BUS_NAME_QUEUE;
+ r = set_put_strdup(owned_names, name);
+ if (r < 0)
+ return synthetic_reply_method_errno(m, r, NULL);
+
r = sd_bus_request_name(a, name, param);
if (r < 0) {
- if (r == -EEXIST)
- return synthetic_reply_method_return(m, "u", BUS_NAME_EXISTS);
if (r == -EALREADY)
return synthetic_reply_method_return(m, "u", BUS_NAME_ALREADY_OWNER);
+
+ set_remove(owned_names, (char*) name);
+
+ if (r == -EEXIST)
+ return synthetic_reply_method_return(m, "u", BUS_NAME_EXISTS);
return synthetic_reply_method_errno(m, r, NULL);
}
in_queue = (r == 0);
- r = hashmap_put(names_hash, name, NULL);
- if (r < 0)
- return synthetic_reply_method_errno(m, r, NULL);
-
if (in_queue)
return synthetic_reply_method_return(m, "u", BUS_NAME_IN_QUEUE);
@@ -1049,7 +962,166 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
}
}
-static int process_hello(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *policy, const struct ucred *ucred, bool *got_hello) {
+static int process_policy(sd_bus *from, sd_bus *to, sd_bus_message *m, Policy *policy, const struct ucred *our_ucred, Set *owned_names) {
+ int r;
+
+ assert(from);
+ assert(to);
+ assert(m);
+
+ if (!policy)
+ return 0;
+
+ if (from->is_kernel) {
+ uid_t sender_uid = (uid_t) -1;
+ gid_t sender_gid = (gid_t) -1;
+ char **sender_names = NULL;
+ bool granted = false;
+
+ /* Driver messages are always OK */
+ if (streq_ptr(m->sender, "org.freedesktop.DBus"))
+ return 0;
+
+ /* The message came from the kernel, and is sent to our legacy client. */
+ r = sd_bus_creds_get_well_known_names(&m->creds, &sender_names);
+ if (r < 0)
+ return r;
+
+ (void) sd_bus_creds_get_uid(&m->creds, &sender_uid);
+ (void) sd_bus_creds_get_gid(&m->creds, &sender_gid);
+
+ /* First check whether the sender can send the message to our name */
+ if (set_isempty(owned_names)) {
+ if (policy_check_send(policy, sender_uid, sender_gid, m->header->type, NULL, m->path, m->interface, m->member))
+ granted = true;
+ } else {
+ Iterator i;
+ char *n;
+
+ SET_FOREACH(n, owned_names, i)
+ if (policy_check_send(policy, sender_uid, sender_gid, m->header->type, n, m->path, m->interface, m->member)) {
+ granted = true;
+ break;
+ }
+ }
+
+ if (granted) {
+ /* Then check whether us, the recipient can recieve from the sender's name */
+ if (strv_isempty(sender_names)) {
+ if (policy_check_recv(policy, our_ucred->uid, our_ucred->gid, m->header->type, NULL, m->path, m->interface, m->member))
+ return 0;
+ } else {
+ char **n;
+
+ STRV_FOREACH(n, sender_names) {
+ if (policy_check_recv(policy, our_ucred->uid, our_ucred->gid, m->header->type, *n, m->path, m->interface, m->member))
+ return 0;
+ }
+ }
+ }
+
+ /* Return an error back to the caller */
+ if (m->header->type == SD_BUS_MESSAGE_METHOD_CALL)
+ return sd_bus_reply_method_errorf(m, SD_BUS_ERROR_ACCESS_DENIED, "Access prohibited by XML receiver policy.");
+
+ /* Return 1, indicating that the message shall not be processed any further */
+ return 1;
+ }
+
+ if (to->is_kernel) {
+ _cleanup_bus_creds_unref_ sd_bus_creds *destination_creds = NULL;
+ uid_t destination_uid = (uid_t) -1;
+ gid_t destination_gid = (gid_t) -1;
+ const char *destination_unique = NULL;
+ char **destination_names = NULL;
+ bool granted = false;
+
+ /* Driver messages are always OK */
+ if (streq_ptr(m->destination, "org.freedesktop.DBus"))
+ return 0;
+
+ /* The message came from the legacy client, and is sent to kdbus. */
+ if (m->destination) {
+ r = sd_bus_get_name_creds(to, m->destination,
+ SD_BUS_CREDS_WELL_KNOWN_NAMES|SD_BUS_CREDS_UNIQUE_NAME|
+ SD_BUS_CREDS_UID|SD_BUS_CREDS_GID|SD_BUS_CREDS_PID, &destination_creds);
+ if (r < 0)
+ return r;
+
+ r = sd_bus_creds_get_well_known_names(destination_creds, &destination_names);
+ if (r < 0)
+ return r;
+
+ r = sd_bus_creds_get_unique_name(destination_creds, &destination_unique);
+ if (r < 0)
+ return r;
+
+ (void) sd_bus_creds_get_uid(destination_creds, &destination_uid);
+ (void) sd_bus_creds_get_gid(destination_creds, &destination_gid);
+ }
+
+ /* First check if we, the sender can send to this name */
+ if (strv_isempty(destination_names)) {
+ if (policy_check_send(policy, our_ucred->uid, our_ucred->gid, m->header->type, NULL, m->path, m->interface, m->member))
+ granted = true;
+ } else {
+ char **n;
+
+ STRV_FOREACH(n, destination_names) {
+ if (policy_check_send(policy, our_ucred->uid, our_ucred->gid, m->header->type, *n, m->path, m->interface, m->member)) {
+
+ /* If we made a receiver decision,
+ then remember which name's policy
+ we used, and to which unique ID it
+ mapped when we made the
+ decision. Then, let's pass this to
+ the kernel when sending the
+ message, so that it refuses the
+ operation should the name and
+ unique ID not map to each other
+ anymore. */
+
+ r = free_and_strdup(&m->destination_ptr, *n);
+ if (r < 0)
+ return r;
+
+ r = bus_kernel_parse_unique_name(destination_unique, &m->verify_destination_id);
+ if (r < 0)
+ break;
+
+ granted = true;
+ break;
+ }
+ }
+ }
+
+ /* Then check if the recipient can receive from our name */
+ if (granted) {
+ if (set_isempty(owned_names)) {
+ if (policy_check_recv(policy, destination_uid, destination_gid, m->header->type, NULL, m->path, m->interface, m->member))
+ return 0;
+ } else {
+ Iterator i;
+ char *n;
+
+ SET_FOREACH(n, owned_names, i)
+ if (policy_check_recv(policy, destination_uid, destination_gid, m->header->type, n, m->path, m->interface, m->member))
+ return 0;
+ }
+ }
+
+ /* Return an error back to the caller */
+ if (m->header->type == SD_BUS_MESSAGE_METHOD_CALL)
+ return sd_bus_reply_method_errorf(m, SD_BUS_ERROR_ACCESS_DENIED, "Access prohibited by XML sender policy.");
+
+ /* Return 1, indicating that the message shall not be processed any further */
+ return 1;
+ }
+
+ return 0;
+}
+
+static int process_hello(sd_bus *a, sd_bus *b, sd_bus_message *m, bool *got_hello) {
_cleanup_bus_message_unref_ sd_bus_message *n = NULL;
bool is_hello;
int r;
@@ -1081,11 +1153,6 @@ static int process_hello(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *policy
return -EIO;
}
- if (policy && !policy_check_hello(policy, ucred)) {
- log_error("Policy denied HELLO");
- return -EPERM;
- }
-
*got_hello = true;
if (!a->is_kernel)
@@ -1192,7 +1259,6 @@ static int patch_sender(sd_bus *a, sd_bus_message *m) {
int main(int argc, char *argv[]) {
- _cleanup_bus_creds_unref_ sd_bus_creds *bus_creds = NULL;
_cleanup_bus_close_unref_ sd_bus *a = NULL, *b = NULL;
sd_id128_t server_id;
int r, in_fd, out_fd;
@@ -1200,7 +1266,8 @@ int main(int argc, char *argv[]) {
bool is_unix;
struct ucred ucred = {};
_cleanup_free_ char *peersec = NULL;
- Policy policy = {};
+ Policy policy_buffer = {}, *policy = NULL;
+ _cleanup_set_free_free_ Set *owned_names = NULL;
log_set_target(LOG_TARGET_JOURNAL_OR_KMSG);
log_parse_environment();
@@ -1210,14 +1277,6 @@ int main(int argc, char *argv[]) {
if (r <= 0)
goto finish;
- r = policy_load(&policy, arg_configuration);
- if (r < 0) {
- log_error("Failed to load policy: %s", strerror(-r));
- goto finish;
- }
-
- /* policy_dump(&policy); */
-
r = sd_listen_fds(0);
if (r == 0) {
in_fd = STDIN_FILENO;
@@ -1255,8 +1314,8 @@ int main(int argc, char *argv[]) {
goto finish;
}
- names_hash = hashmap_new(&string_hash_ops);
- if (!names_hash) {
+ owned_names = set_new(&string_hash_ops);
+ if (!owned_names) {
log_oom();
goto finish;
}
@@ -1285,6 +1344,12 @@ int main(int argc, char *argv[]) {
goto finish;
}
+ r = sd_bus_negotiate_creds(a, true, SD_BUS_CREDS_UID|SD_BUS_CREDS_PID|SD_BUS_CREDS_GID|SD_BUS_CREDS_SELINUX_CONTEXT);
+ if (r < 0) {
+ log_error("Failed to set credential negotiation: %s", strerror(-r));
+ goto finish;
+ }
+
if (ucred.pid > 0) {
a->fake_pids.pid = ucred.pid;
a->fake_pids_valid = true;
@@ -1319,10 +1384,41 @@ int main(int argc, char *argv[]) {
goto finish;
}
- r = sd_bus_get_owner_creds(a, SD_BUS_CREDS_UID, &bus_creds);
- if (r < 0) {
- log_error("Failed to get bus creds: %s", strerror(-r));
- goto finish;
+ if (a->is_kernel) {
+ _cleanup_bus_creds_unref_ sd_bus_creds *bus_creds = NULL;
+ uid_t bus_uid;
+
+ r = sd_bus_get_owner_creds(a, SD_BUS_CREDS_UID, &bus_creds);
+ if (r < 0) {
+ log_error("Failed to get bus creds: %s", strerror(-r));
+ goto finish;
+ }
+
+ r = sd_bus_creds_get_uid(bus_creds, &bus_uid);
+ if (r < 0) {
+ log_error("Failed to get bus owner UID: %s", strerror(-r));
+ goto finish;
+ }
+
+ if (bus_uid == 0) {
+ /* We only enforce the old XML policy on
+ * kernel busses owned by root users. */
+
+ r = policy_load(&policy_buffer, arg_configuration);
+ if (r < 0) {
+ log_error("Failed to load policy: %s", strerror(-r));
+ goto finish;
+ }
+
+ if (!policy_check_hello(&policy_buffer, ucred.uid, ucred.gid)) {
+ log_error("Policy denied connection");
+ r = -EPERM;
+ goto finish;
+ }
+
+ policy_dump(&policy_buffer);
+ policy = &policy_buffer;
+ }
}
r = sd_bus_new(&b);
@@ -1349,6 +1445,12 @@ int main(int argc, char *argv[]) {
goto finish;
}
+ r = sd_bus_negotiate_creds(b, true, SD_BUS_CREDS_UID|SD_BUS_CREDS_PID|SD_BUS_CREDS_GID|SD_BUS_CREDS_SELINUX_CONTEXT);
+ if (r < 0) {
+ log_error("Failed to set credential negotiation: %s", strerror(-r));
+ goto finish;
+ }
+
r = sd_bus_set_anonymous(b, true);
if (r < 0) {
log_error("Failed to set anonymous authentication: %s", strerror(-r));
@@ -1428,6 +1530,8 @@ int main(int argc, char *argv[]) {
int k;
if (got_hello) {
+ /* Read messages from bus, to pass them on to our client */
+
r = sd_bus_process(a, &m);
if (r < 0) {
/* treat 'connection reset by peer' as clean exit condition */
@@ -1440,6 +1544,8 @@ int main(int argc, char *argv[]) {
}
if (m) {
+ bool processed = false;
+
/* We officially got EOF, let's quit */
if (sd_bus_message_is_signal(m, "org.freedesktop.DBus.Local", "Disconnected")) {
r = 0;
@@ -1455,16 +1561,31 @@ int main(int argc, char *argv[]) {
patch_sender(a, m);
- k = sd_bus_send(b, m, NULL);
- if (k < 0) {
- if (k == -ECONNRESET)
- r = 0;
- else {
+ if (policy) {
+ k = process_policy(a, b, m, policy, &ucred, owned_names);
+ if (k < 0) {
r = k;
- log_error("Failed to send message: %s", strerror(-r));
+ log_error("Failed to process policy: %s", strerror(-r));
+ goto finish;
+ } else if (k > 0) {
+ r = 1;
+ processed = true;
}
+ }
- goto finish;
+ if (!processed) {
+ k = sd_bus_send(b, m, NULL);
+ if (k < 0) {
+ if (k == -ECONNRESET)
+ r = 0;
+ else {
+ r = k;
+ log_error("Failed to send message to client: %s", strerror(-r));
+ }
+
+ goto finish;
+ } else
+ r = 1;
}
}
@@ -1472,6 +1593,7 @@ int main(int argc, char *argv[]) {
continue;
}
+ /* Read messages from our client, to pass them on to the bus */
r = sd_bus_process(b, &m);
if (r < 0) {
/* treat 'connection reset by peer' as clean exit condition */
@@ -1484,15 +1606,7 @@ int main(int argc, char *argv[]) {
}
if (m) {
- Policy *p = NULL;
- uid_t uid;
-
- assert_se(sd_bus_creds_get_uid(bus_creds, &uid) == 0);
-
-/*
- if (uid == 0 || uid != ucred.uid)
- p = &policy;
-*/
+ bool processed = false;
/* We officially got EOF, let's quit */
if (sd_bus_message_is_signal(m, "org.freedesktop.DBus.Local", "Disconnected")) {
@@ -1500,53 +1614,61 @@ int main(int argc, char *argv[]) {
goto finish;
}
- k = process_hello(a, b, m, p, &ucred, &got_hello);
+ k = process_hello(a, b, m, &got_hello);
if (k < 0) {
r = k;
log_error("Failed to process HELLO: %s", strerror(-r));
goto finish;
+ } else if (k > 0) {
+ processed = true;
+ r = 1;
}
- if (k > 0)
- r = k;
- else {
- k = process_driver(a, b, m, p, &ucred);
+ if (!processed) {
+ k = process_driver(a, b, m, policy, &ucred, owned_names);
if (k < 0) {
r = k;
log_error("Failed to process driver calls: %s", strerror(-r));
goto finish;
+ } else if (k > 0) {
+ processed = true;
+ r = 1;
}
- if (k > 0)
- r = k;
- else {
- bool retry;
-
- do {
- retry = false;
+ if (!processed) {
- k = process_policy(a, b, m, p, &ucred);
- if (k < 0) {
- r = k;
- log_error("Failed to process policy: %s", strerror(-r));
- goto finish;
+ for (;;) {
+ if (policy) {
+ k = process_policy(b, a, m, policy, &ucred, owned_names);
+ if (k < 0) {
+ r = k;
+ log_error("Failed to process policy: %s", strerror(-r));
+ goto finish;
+ } else if (k > 0) {
+ processed = true;
+ r = 1;
+ break;
+ }
}
k = sd_bus_send(a, m, NULL);
if (k < 0) {
- if (k == -ECONNRESET)
+ if (k == -EREMCHG)
+ /* The name database changed since the policy check, hence let's check again */
+ continue;
+ else if (k == -ECONNRESET)
r = 0;
- else if (k == -EREMCHG)
- retry = true;
else {
r = k;
- log_error("Failed to send message: %s", strerror(-r));
+ log_error("Failed to send message to bus: %s", strerror(-r));
}
- if (!retry)
- goto finish;
- }
- } while (retry);
+ goto finish;
+ } else
+ r = 1;
+
+ break;
+ }
}
}
}
@@ -1620,9 +1742,8 @@ finish:
"STOPPING=1\n"
"STATUS=Shutting down.");
- policy_free(&policy);
+ policy_free(&policy_buffer);
strv_free(arg_configuration);
- hashmap_free(names_hash);
free(arg_address);
return r < 0 ? EXIT_FAILURE : EXIT_SUCCESS;
diff --git a/src/bus-proxyd/test-bus-policy.c b/src/bus-proxyd/test-bus-policy.c
index 1c1d1ef..91ab33d 100644
--- a/src/bus-proxyd/test-bus-policy.c
+++ b/src/bus-proxyd/test-bus-policy.c
@@ -62,41 +62,29 @@ static int test_policy_load(Policy *p, const char *name)
int main(int argc, char *argv[]) {
Policy p = {};
- struct ucred ucred = {};
/* Ownership tests */
assert_se(test_policy_load(&p, "ownerships.conf") == 0);
- ucred.uid = 0;
- assert_se(policy_check_own(&p, &ucred, "org.test.test1") == true);
- ucred.uid = 1;
- assert_se(policy_check_own(&p, &ucred, "org.test.test1") == true);
+ assert_se(policy_check_own(&p, 0, 0, "org.test.test1") == true);
+ assert_se(policy_check_own(&p, 1, 0, "org.test.test1") == true);
- ucred.uid = 0;
- assert_se(policy_check_own(&p, &ucred, "org.test.test2") == true);
- ucred.uid = 1;
- assert_se(policy_check_own(&p, &ucred, "org.test.test2") == false);
+ assert_se(policy_check_own(&p, 0, 0, "org.test.test2") == true);
+ assert_se(policy_check_own(&p, 1, 0, "org.test.test2") == false);
- ucred.uid = 0;
- assert_se(policy_check_own(&p, &ucred, "org.test.test3") == false);
- ucred.uid = 1;
- assert_se(policy_check_own(&p, &ucred, "org.test.test3") == false);
+ assert_se(policy_check_own(&p, 0, 0, "org.test.test3") == false);
+ assert_se(policy_check_own(&p, 1, 0, "org.test.test3") == false);
- ucred.uid = 0;
- assert_se(policy_check_own(&p, &ucred, "org.test.test4") == false);
- ucred.uid = 1;
- assert_se(policy_check_own(&p, &ucred, "org.test.test4") == true);
+ assert_se(policy_check_own(&p, 0, 0, "org.test.test4") == false);
+ assert_se(policy_check_own(&p, 1, 0, "org.test.test4") == true);
policy_free(&p);
/* Signaltest */
assert_se(test_policy_load(&p, "signals.conf") == 0);
- ucred.uid = 0;
- assert_se(policy_check_send(&p, &ucred, SD_BUS_MESSAGE_SIGNAL, "bli.bla.blubb", NULL, "/an/object/path", NULL) == true);
-
- ucred.uid = 1;
- assert_se(policy_check_send(&p, &ucred, SD_BUS_MESSAGE_SIGNAL, "bli.bla.blubb", NULL, "/an/object/path", NULL) == false);
+ assert_se(policy_check_send(&p, 0, 0, SD_BUS_MESSAGE_SIGNAL, "bli.bla.blubb", NULL, "/an/object/path", NULL) == true);
+ assert_se(policy_check_send(&p, 1, 0, SD_BUS_MESSAGE_SIGNAL, "bli.bla.blubb", NULL, "/an/object/path", NULL) == false);
policy_free(&p);
@@ -104,14 +92,12 @@ int main(int argc, char *argv[]) {
assert_se(test_policy_load(&p, "methods.conf") == 0);
policy_dump(&p);
- ucred.uid = 0;
-
- assert_se(policy_check_send(&p, &ucred, SD_BUS_MESSAGE_METHOD_CALL, "org.test.test1", "/an/object/path", "bli.bla.blubb", "Member") == false);
- assert_se(policy_check_send(&p, &ucred, SD_BUS_MESSAGE_METHOD_CALL, "org.test.test1", "/an/object/path", "bli.bla.blubb", "Member") == false);
- assert_se(policy_check_send(&p, &ucred, SD_BUS_MESSAGE_METHOD_CALL, "org.test.test1", "/an/object/path", "org.test.int1", "Member") == true);
- assert_se(policy_check_send(&p, &ucred, SD_BUS_MESSAGE_METHOD_CALL, "org.test.test1", "/an/object/path", "org.test.int2", "Member") == true);
+ assert_se(policy_check_send(&p, 0, 0, SD_BUS_MESSAGE_METHOD_CALL, "org.test.test1", "/an/object/path", "bli.bla.blubb", "Member") == false);
+ assert_se(policy_check_send(&p, 0, 0, SD_BUS_MESSAGE_METHOD_CALL, "org.test.test1", "/an/object/path", "bli.bla.blubb", "Member") == false);
+ assert_se(policy_check_send(&p, 0, 0, SD_BUS_MESSAGE_METHOD_CALL, "org.test.test1", "/an/object/path", "org.test.int1", "Member") == true);
+ assert_se(policy_check_send(&p, 0, 0, SD_BUS_MESSAGE_METHOD_CALL, "org.test.test1", "/an/object/path", "org.test.int2", "Member") == true);
- assert_se(policy_check_recv(&p, &ucred, SD_BUS_MESSAGE_METHOD_CALL, "org.test.test3", "/an/object/path", "org.test.int3", "Member111") == true);
+ assert_se(policy_check_recv(&p, 0, 0, SD_BUS_MESSAGE_METHOD_CALL, "org.test.test3", "/an/object/path", "org.test.int3", "Member111") == true);
policy_free(&p);
@@ -119,15 +105,9 @@ int main(int argc, char *argv[]) {
assert_se(test_policy_load(&p, "hello.conf") == 0);
policy_dump(&p);
- ucred.uid = 0;
- assert_se(policy_check_hello(&p, &ucred) == true);
-
- ucred.uid = 1;
- assert_se(policy_check_hello(&p, &ucred) == false);
-
- ucred.uid = 0;
- ucred.gid = 1;
- assert_se(policy_check_hello(&p, &ucred) == false);
+ assert_se(policy_check_hello(&p, 0, 0) == true);
+ assert_se(policy_check_hello(&p, 1, 0) == false);
+ assert_se(policy_check_hello(&p, 0, 1) == false);
policy_free(&p);
@@ -136,14 +116,14 @@ int main(int argc, char *argv[]) {
assert_se(test_policy_load(&p, "check-own-rules.conf") >= 0);
policy_dump(&p);
- assert_se(policy_check_own(&p, &ucred, "org.freedesktop") == false);
- assert_se(policy_check_own(&p, &ucred, "org.freedesktop.ManySystem") == false);
- assert_se(policy_check_own(&p, &ucred, "org.freedesktop.ManySystems") == true);
- assert_se(policy_check_own(&p, &ucred, "org.freedesktop.ManySystems.foo") == true);
- assert_se(policy_check_own(&p, &ucred, "org.freedesktop.ManySystems.foo.bar") == true);
- assert_se(policy_check_own(&p, &ucred, "org.freedesktop.ManySystems2") == false);
- assert_se(policy_check_own(&p, &ucred, "org.freedesktop.ManySystems2.foo") == false);
- assert_se(policy_check_own(&p, &ucred, "org.freedesktop.ManySystems2.foo.bar") == false);
+ assert_se(policy_check_own(&p, 0, 0, "org.freedesktop") == false);
+ assert_se(policy_check_own(&p, 0, 0, "org.freedesktop.ManySystem") == false);
+ assert_se(policy_check_own(&p, 0, 0, "org.freedesktop.ManySystems") == true);
+ assert_se(policy_check_own(&p, 0, 0, "org.freedesktop.ManySystems.foo") == true);
+ assert_se(policy_check_own(&p, 0, 0, "org.freedesktop.ManySystems.foo.bar") == true);
+ assert_se(policy_check_own(&p, 0, 0, "org.freedesktop.ManySystems2") == false);
+ assert_se(policy_check_own(&p, 0, 0, "org.freedesktop.ManySystems2.foo") == false);
+ assert_se(policy_check_own(&p, 0, 0, "org.freedesktop.ManySystems2.foo.bar") == false);
policy_free(&p);
@@ -158,23 +138,21 @@ int main(int argc, char *argv[]) {
assert_se(test_policy_load(&p, "test.conf") >= 0);
policy_dump(&p);
- ucred.uid = 0;
- assert_se(policy_check_own(&p, &ucred, "org.foo.FooService") == true);
- assert_se(policy_check_own(&p, &ucred, "org.foo.FooService2") == false);
- assert_se(policy_check_send(&p, &ucred, SD_BUS_MESSAGE_METHOD_CALL, "org.test.test1", "/an/object/path", "org.test.int2", "Member") == false);
- assert_se(policy_check_send(&p, &ucred, SD_BUS_MESSAGE_METHOD_CALL, "org.test.test1", "/an/object/path", "org.foo.FooBroadcastInterface", "Member") == true);
- assert_se(policy_check_recv(&p, &ucred, SD_BUS_MESSAGE_METHOD_CALL, "org.foo.FooService", "/an/object/path", "org.foo.FooBroadcastInterface", "Member") == true);
- assert_se(policy_check_recv(&p, &ucred, SD_BUS_MESSAGE_METHOD_CALL, "org.foo.FooService", "/an/object/path", "org.foo.FooBroadcastInterface2", "Member") == false);
- assert_se(policy_check_recv(&p, &ucred, SD_BUS_MESSAGE_METHOD_CALL, "org.foo.FooService2", "/an/object/path", "org.foo.FooBroadcastInterface", "Member") == false);
-
- ucred.uid = 100;
- assert_se(policy_check_own(&p, &ucred, "org.foo.FooService") == false);
- assert_se(policy_check_own(&p, &ucred, "org.foo.FooService2") == false);
- assert_se(policy_check_send(&p, &ucred, SD_BUS_MESSAGE_METHOD_CALL, "org.test.test1", "/an/object/path", "org.test.int2", "Member") == false);
- assert_se(policy_check_send(&p, &ucred, SD_BUS_MESSAGE_METHOD_CALL, "org.test.test1", "/an/object/path", "org.foo.FooBroadcastInterface", "Member") == false);
- assert_se(policy_check_recv(&p, &ucred, SD_BUS_MESSAGE_METHOD_CALL, "org.foo.FooService", "/an/object/path", "org.foo.FooBroadcastInterface", "Member") == true);
- assert_se(policy_check_recv(&p, &ucred, SD_BUS_MESSAGE_METHOD_CALL, "org.foo.FooService", "/an/object/path", "org.foo.FooBroadcastInterface2", "Member") == false);
- assert_se(policy_check_recv(&p, &ucred, SD_BUS_MESSAGE_METHOD_CALL, "org.foo.FooService2", "/an/object/path", "org.foo.FooBroadcastInterface", "Member") == false);
+ assert_se(policy_check_own(&p, 0, 0, "org.foo.FooService") == true);
+ assert_se(policy_check_own(&p, 0, 0, "org.foo.FooService2") == false);
+ assert_se(policy_check_send(&p, 0, 0, SD_BUS_MESSAGE_METHOD_CALL, "org.test.test1", "/an/object/path", "org.test.int2", "Member") == false);
+ assert_se(policy_check_send(&p, 0, 0, SD_BUS_MESSAGE_METHOD_CALL, "org.test.test1", "/an/object/path", "org.foo.FooBroadcastInterface", "Member") == true);
+ assert_se(policy_check_recv(&p, 0, 0, SD_BUS_MESSAGE_METHOD_CALL, "org.foo.FooService", "/an/object/path", "org.foo.FooBroadcastInterface", "Member") == true);
+ assert_se(policy_check_recv(&p, 0, 0, SD_BUS_MESSAGE_METHOD_CALL, "org.foo.FooService", "/an/object/path", "org.foo.FooBroadcastInterface2", "Member") == false);
+ assert_se(policy_check_recv(&p, 0, 0, SD_BUS_MESSAGE_METHOD_CALL, "org.foo.FooService2", "/an/object/path", "org.foo.FooBroadcastInterface", "Member") == false);
+
+ assert_se(policy_check_own(&p, 100, 0, "org.foo.FooService") == false);
+ assert_se(policy_check_own(&p, 100, 0, "org.foo.FooService2") == false);
+ assert_se(policy_check_send(&p, 100, 0, SD_BUS_MESSAGE_METHOD_CALL, "org.test.test1", "/an/object/path", "org.test.int2", "Member") == false);
+ assert_se(policy_check_send(&p, 100, 0, SD_BUS_MESSAGE_METHOD_CALL, "org.test.test1", "/an/object/path", "org.foo.FooBroadcastInterface", "Member") == false);
+ assert_se(policy_check_recv(&p, 100, 0, SD_BUS_MESSAGE_METHOD_CALL, "org.foo.FooService", "/an/object/path", "org.foo.FooBroadcastInterface", "Member") == true);
+ assert_se(policy_check_recv(&p, 100, 0, SD_BUS_MESSAGE_METHOD_CALL, "org.foo.FooService", "/an/object/path", "org.foo.FooBroadcastInterface2", "Member") == false);
+ assert_se(policy_check_recv(&p, 100, 0, SD_BUS_MESSAGE_METHOD_CALL, "org.foo.FooService2", "/an/object/path", "org.foo.FooBroadcastInterface", "Member") == false);
policy_free(&p);
commit 9398f650939aec0d44ea7d20240502cafd667c29
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Nov 26 23:13:52 2014 +0100
update TODO
diff --git a/TODO b/TODO
index a1581a6..306652e 100644
--- a/TODO
+++ b/TODO
@@ -257,14 +257,15 @@ Features:
ReadOnlyDirectories=... for whitelisting files for a service.
* sd-bus:
+ - kdbus: the kernel needs to tell us whether it accepted a message because of a method call window. THis can then be used by the proxy to blindly accept all method replies with that flag set as OK.
- systemd-bus-proxyd needs to enforce good old XML policy
- - kdbus: maybe add controlling tty and ppid metadata fields
- kdbus: for some reason "busctl monitor" only shows metadata for signal msgs, never method call or method reply msgs
- kdbus: busnames.target should get pulled in by basic.target
- Ignore .busname units on classic D-Bus boots, systemd-resolved cannot be started on kdbus
without the active policy and should get a Wants=org.freedesktop.resolve1.busname to
pull-in the policy.
- port to sd-resolve for connecting to TCP dbus servers
+ - kdbus: maybe add controlling tty and ppid metadata fields
- see if we can introduce a new sd_bus_get_owner_machine_id() call to retrieve the machine ID of the machine of the bus itself
- when kdbus does not take our message without memfds, try again with memfds
- introduce sd_bus_emit_object_added()/sd_bus_emit_object_removed() that automatically includes the build-in interfaces in the list
commit 64e96a194d9fb8e9e69769bf88f067fadf9acce7
Author: Lennart Poettering <lennart at poettering.net>
Date: Wed Nov 26 22:52:10 2014 +0100
bus-proxy: check passed parameter signature of all driver method calls
diff --git a/src/bus-proxyd/bus-proxyd.c b/src/bus-proxyd/bus-proxyd.c
index 32c8242..4df2fb1 100644
--- a/src/bus-proxyd/bus-proxyd.c
+++ b/src/bus-proxyd/bus-proxyd.c
@@ -543,14 +543,12 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
if (!streq_ptr(sd_bus_message_get_destination(m), "org.freedesktop.DBus"))
return 0;
- if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) {
- if (0 && !isempty(sd_bus_message_get_signature(m, true))) {
- _cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
+ /* The "Hello()" call is is handled in process_hello() */
- r = sd_bus_error_setf(&error, SD_BUS_ERROR_INVALID_ARGS, "Expected no parameters");
+ if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus.Introspectable", "Introspect")) {
- return synthetic_reply_method_errno(m, r, &error);
- }
+ if (!sd_bus_message_has_signature(m, ""))
+ return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters"));
return synthetic_reply_method_return(m, "s",
"<!DOCTYPE node PUBLIC \"-//freedesktop//DTD D-BUS Object Introspection 1.0//EN\" "
@@ -640,6 +638,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
} else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "AddMatch")) {
const char *match;
+ if (!sd_bus_message_has_signature(m, "s"))
+ return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters"));
+
r = sd_bus_message_read(m, "s", &match);
if (r < 0)
return synthetic_reply_method_errno(m, r, NULL);
@@ -653,6 +654,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
} else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "RemoveMatch")) {
const char *match;
+ if (!sd_bus_message_has_signature(m, "s"))
+ return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters"));
+
r = sd_bus_message_read(m, "s", &match);
if (r < 0)
return synthetic_reply_method_errno(m, r, NULL);
@@ -669,6 +673,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
+ if (!sd_bus_message_has_signature(m, "s"))
+ return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters"));
+
r = get_creds_by_message(a, m, SD_BUS_CREDS_SELINUX_CONTEXT, &creds, &error);
if (r < 0)
return synthetic_reply_method_errno(m, r, &error);
@@ -679,6 +686,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
+ if (!sd_bus_message_has_signature(m, "s"))
+ return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters"));
+
r = get_creds_by_message(a, m, SD_BUS_CREDS_PID, &creds, &error);
if (r < 0)
return synthetic_reply_method_errno(m, r, &error);
@@ -689,6 +699,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
+ if (!sd_bus_message_has_signature(m, "s"))
+ return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters"));
+
r = get_creds_by_message(a, m, SD_BUS_CREDS_UID, &creds, &error);
if (r < 0)
return synthetic_reply_method_errno(m, r, &error);
@@ -699,6 +712,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
sd_id128_t server_id;
char buf[SD_ID128_STRING_MAX];
+ if (!sd_bus_message_has_signature(m, ""))
+ return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters"));
+
r = sd_bus_get_owner_id(a, &server_id);
if (r < 0)
return synthetic_reply_method_errno(m, r, NULL);
@@ -710,6 +726,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
_cleanup_bus_creds_unref_ sd_bus_creds *creds = NULL;
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
+ if (!sd_bus_message_has_signature(m, "s"))
+ return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters"));
+
r = sd_bus_message_read(m, "s", &name);
if (r < 0)
return synthetic_reply_method_errno(m, r, NULL);
@@ -723,11 +742,12 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
return synthetic_reply_method_return(m, "s", creds->unique_name);
- /* "Hello" is handled in process_hello() */
-
} else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "ListActivatableNames")) {
_cleanup_strv_free_ char **names = NULL;
+ if (!sd_bus_message_has_signature(m, ""))
+ return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters"));
+
r = sd_bus_list_names(a, NULL, &names);
if (r < 0)
return synthetic_reply_method_errno(m, r, NULL);
@@ -740,6 +760,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
} else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "ListNames")) {
_cleanup_strv_free_ char **names = NULL;
+ if (!sd_bus_message_has_signature(m, ""))
+ return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters"));
+
r = sd_bus_list_names(a, &names, NULL);
if (r < 0)
return synthetic_reply_method_errno(m, r, NULL);
@@ -763,6 +786,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
char *arg0;
int err = 0;
+ if (!sd_bus_message_has_signature(m, "s"))
+ return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters"));
+
r = sd_bus_message_read(m, "s", &arg0);
if (r < 0)
return synthetic_reply_method_errno(m, r, NULL);
@@ -821,6 +847,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
} else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "NameHasOwner")) {
const char *name;
+ if (!sd_bus_message_has_signature(m, "s"))
+ return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters"));
+
r = sd_bus_message_read(m, "s", &name);
if (r < 0)
return synthetic_reply_method_errno(m, r, NULL);
@@ -837,6 +866,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
} else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "ReleaseName")) {
const char *name;
+ if (!sd_bus_message_has_signature(m, "s"))
+ return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters"));
+
r = sd_bus_message_read(m, "s", &name);
if (r < 0)
return synthetic_reply_method_errno(m, r, NULL);
@@ -858,6 +890,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
} else if (sd_bus_message_is_method_call(m, "org.freedesktop.DBus", "ReloadConfig")) {
_cleanup_bus_error_free_ sd_bus_error error = SD_BUS_ERROR_NULL;
+ if (!sd_bus_message_has_signature(m, ""))
+ return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters"));
+
r = sd_bus_error_setf(&error, SD_BUS_ERROR_NOT_SUPPORTED, "%s() is not supported", sd_bus_message_get_member(m));
return synthetic_reply_method_errno(m, r, &error);
@@ -867,6 +902,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
uint32_t flags, param;
bool in_queue;
+ if (!sd_bus_message_has_signature(m, "su"))
+ return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters"));
+
r = sd_bus_message_read(m, "su", &name, &flags);
if (r < 0)
return synthetic_reply_method_errno(m, r, NULL);
@@ -910,6 +948,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
const char *name;
uint32_t flags;
+ if (!sd_bus_message_has_signature(m, "su"))
+ return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters"));
+
r = sd_bus_message_read(m, "su", &name, &flags);
if (r < 0)
return synthetic_reply_method_errno(m, r, NULL);
@@ -943,6 +984,9 @@ static int process_driver(sd_bus *a, sd_bus *b, sd_bus_message *m, Policy *polic
_cleanup_bus_message_unref_ sd_bus_message *msg = NULL;
_cleanup_strv_free_ char **args = NULL;
+ if (!sd_bus_message_has_signature(m, "a{ss}"))
+ return synthetic_reply_method_error(m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_INVALID_ARGS, "Invalid parameters"));
+
r = sd_bus_message_enter_container(m, SD_BUS_TYPE_ARRAY, "{ss}");
if (r < 0)
return synthetic_reply_method_errno(m, r, NULL);
diff --git a/src/libsystemd/sd-bus/bus-message.c b/src/libsystemd/sd-bus/bus-message.c
index 6889754..9bc05c2 100644
--- a/src/libsystemd/sd-bus/bus-message.c
+++ b/src/libsystemd/sd-bus/bus-message.c
@@ -5396,6 +5396,12 @@ _public_ int sd_bus_message_is_empty(sd_bus_message *m) {
return isempty(m->root_container.signature);
}
+_public_ int sd_bus_message_has_signature(sd_bus_message *m, const char *signature) {
+ assert_return(m, -EINVAL);
+
+ return streq(strempty(m->root_container.signature), strempty(signature));
+}
+
_public_ int sd_bus_message_copy(sd_bus_message *m, sd_bus_message *source, int all) {
bool done_something = false;
int r;
diff --git a/src/systemd/sd-bus.h b/src/systemd/sd-bus.h
index 28c7ee4..47fc8df 100644
--- a/src/systemd/sd-bus.h
+++ b/src/systemd/sd-bus.h
@@ -231,6 +231,7 @@ int sd_bus_message_is_signal(sd_bus_message *m, const char *interface, const cha
int sd_bus_message_is_method_call(sd_bus_message *m, const char *interface, const char *member);
int sd_bus_message_is_method_error(sd_bus_message *m, const char *name);
int sd_bus_message_is_empty(sd_bus_message *m);
+int sd_bus_message_has_signature(sd_bus_message *m, const char *signature);
int sd_bus_message_set_expect_reply(sd_bus_message *m, int b);
int sd_bus_message_set_auto_start(sd_bus_message *m, int b);
More information about the systemd-commits
mailing list