From 613b6e73d0107a95767dfa0889c31c2842fddebb Mon Sep 17 00:00:00 2001 From: Daan De Meyer Date: Oct 11 2024 16:41:41 +0000 Subject: Add missing patches --- diff --git a/34686.patch b/34686.patch new file mode 100644 index 0000000..21c46f4 --- /dev/null +++ b/34686.patch @@ -0,0 +1,255 @@ +From 0d0ecaab000cf2768a3edf1e73119bf2fce952b0 Mon Sep 17 00:00:00 2001 +From: Daan De Meyer +Date: Wed, 9 Oct 2024 14:49:07 +0200 +Subject: [PATCH 1/6] mkosi: Fix up ownership of testuser home directory on + first boot + +When building unprivileged, the testuser home directory ends up +owned by root:root because mkosi can't chown directories to other +owners when running unprivileged. So let's fix up the testuser +ownership on first boot with tmpfiles instead. +--- + mkosi.extra/usr/lib/tmpfiles.d/testuser.conf | 3 +++ + 1 file changed, 3 insertions(+) + create mode 100644 mkosi.extra/usr/lib/tmpfiles.d/testuser.conf + +diff --git a/mkosi.extra/usr/lib/tmpfiles.d/testuser.conf b/mkosi.extra/usr/lib/tmpfiles.d/testuser.conf +new file mode 100644 +index 0000000000000..7113177f4deba +--- /dev/null ++++ b/mkosi.extra/usr/lib/tmpfiles.d/testuser.conf +@@ -0,0 +1,3 @@ ++# SPDX-License-Identifier: LGPL-2.1-or-later ++ ++z! /home/testuser 700 testuser testuser + +From ec9fd0d4f5f77404fbfabde9e7a9d01aaa1356ff Mon Sep 17 00:00:00 2001 +From: Daan De Meyer +Date: Wed, 9 Oct 2024 16:37:06 +0200 +Subject: [PATCH 2/6] update-utmp: Make reconnect logic more robust + +We might also fail to connect to the private manager bus itself if +the daemon-reexec is still ongoing, so let's handle that as well by +retrying on ECONNREFUSED. +--- + src/update-utmp/update-utmp.c | 45 +++++++++++++++++++---------------- + 1 file changed, 25 insertions(+), 20 deletions(-) + +diff --git a/src/update-utmp/update-utmp.c b/src/update-utmp/update-utmp.c +index c376676e8d0a5..7a8a53f7e8ec5 100644 +--- a/src/update-utmp/update-utmp.c ++++ b/src/update-utmp/update-utmp.c +@@ -82,6 +82,25 @@ static int get_current_runlevel(Context *c) { + assert(c); + + for (unsigned n_attempts = 0;;) { ++ if (n_attempts++ > 0) { ++ /* systemd might have dropped off momentarily, let's not make this an error, ++ * and wait some random time. Let's pick a random time in the range 0ms…250ms, ++ * linearly scaled by the number of failed attempts. */ ++ c->bus = sd_bus_flush_close_unref(c->bus); ++ ++ usec_t usec = random_u64_range(UINT64_C(10) * USEC_PER_MSEC + ++ UINT64_C(240) * USEC_PER_MSEC * n_attempts/64); ++ (void) usleep_safe(usec); ++ ++ r = bus_connect_system_systemd(&c->bus); ++ if (r == -ECONNREFUSED && n_attempts < 64) { ++ log_debug_errno(r, "Failed to reconnect to system bus, retrying after a slight delay: %m"); ++ continue; ++ } ++ if (r < 0) ++ return log_error_errno(r, "Failed to reconnect to system bus: %m"); ++ } ++ + FOREACH_ELEMENT(e, table) { + _cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL; + _cleanup_free_ char *state = NULL, *path = NULL; +@@ -102,18 +121,10 @@ static int get_current_runlevel(Context *c) { + sd_bus_error_has_names(&error, + SD_BUS_ERROR_NO_REPLY, + SD_BUS_ERROR_DISCONNECTED)) && +- ++n_attempts < 64) { +- +- /* systemd might have dropped off momentarily, let's not make this an error, +- * and wait some random time. Let's pick a random time in the range 0ms…250ms, +- * linearly scaled by the number of failed attempts. */ +- +- usec_t usec = random_u64_range(UINT64_C(10) * USEC_PER_MSEC + +- UINT64_C(240) * USEC_PER_MSEC * n_attempts/64); +- log_debug_errno(r, "Failed to get state of %s, retrying after %s: %s", +- e->special, FORMAT_TIMESPAN(usec, USEC_PER_MSEC), bus_error_message(&error, r)); +- (void) usleep_safe(usec); +- goto reconnect; ++ n_attempts < 64) { ++ log_debug_errno(r, "Failed to get state of %s, retrying after a slight delay: %s", ++ e->special, bus_error_message(&error, r)); ++ break; + } + if (r < 0) + return log_warning_errno(r, "Failed to get state of %s: %s", e->special, bus_error_message(&error, r)); +@@ -121,14 +132,8 @@ static int get_current_runlevel(Context *c) { + if (STR_IN_SET(state, "active", "reloading")) + return e->runlevel; + } +- +- return 0; +- +-reconnect: +- c->bus = sd_bus_flush_close_unref(c->bus); +- r = bus_connect_system_systemd(&c->bus); +- if (r < 0) +- return log_error_errno(r, "Failed to reconnect to system bus: %m"); ++ if (r >= 0) ++ return 0; + } + } + + +From a339495b1d67f69f49ffffdd96002164a28f1c93 Mon Sep 17 00:00:00 2001 +From: Daan De Meyer +Date: Wed, 9 Oct 2024 11:44:34 +0200 +Subject: [PATCH 3/6] bus-util: Drop fallback to system/user bus if manager bus + doesn't work + +We have various callsites that explicitly need the manager bus and +won't work with the system bus, like daemon-reexec and friends which +can't properly wait until the operation has finished unless using the +manager bus. + +If we silently fall back to the system bus for these operations, we +can end up with rather hard to debug issues so let's remove the fallback +as it was added back in 2013 in a6aa89122d2fa5e811a72200773068c13bfffea2 +without a clear explanation of why it was needed (I expect as a fallback +if kdbus wasn't available but that's not a thing anymore these days). +--- + src/shared/bus-util.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c +index f4c4eed70702a..44ed617da8dfb 100644 +--- a/src/shared/bus-util.c ++++ b/src/shared/bus-util.c +@@ -245,7 +245,7 @@ int bus_connect_system_systemd(sd_bus **ret_bus) { + + r = sd_bus_start(bus); + if (r < 0) +- return sd_bus_default_system(ret_bus); ++ return r; + + r = bus_check_peercred(bus); + if (r < 0) +@@ -265,7 +265,7 @@ int bus_connect_user_systemd(sd_bus **ret_bus) { + + e = secure_getenv("XDG_RUNTIME_DIR"); + if (!e) +- return sd_bus_default_user(ret_bus); ++ return -ENXIO; + + ee = bus_address_escape(e); + if (!ee) +@@ -281,7 +281,7 @@ int bus_connect_user_systemd(sd_bus **ret_bus) { + + r = sd_bus_start(bus); + if (r < 0) +- return sd_bus_default_user(ret_bus); ++ return r; + + r = bus_check_peercred(bus); + if (r < 0) + +From a178ffdfcd9d25886a6e563a0fbd9929852e85c4 Mon Sep 17 00:00:00 2001 +From: Daan De Meyer +Date: Wed, 9 Oct 2024 12:10:44 +0200 +Subject: [PATCH 4/6] bus-util: Move geteuid() check out of + bus_connect_system_systemd() + +Let's move this check to bus_connect_transport_systemd() so that +bus_connect_system_systemd() will only ever connect to the manager +private manager bus instance and fail otherwise. +--- + src/shared/bus-util.c | 13 ++++++------- + 1 file changed, 6 insertions(+), 7 deletions(-) + +diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c +index 44ed617da8dfb..a196ba47f647c 100644 +--- a/src/shared/bus-util.c ++++ b/src/shared/bus-util.c +@@ -229,12 +229,6 @@ int bus_connect_system_systemd(sd_bus **ret_bus) { + + assert(ret_bus); + +- if (geteuid() != 0) +- return sd_bus_default_system(ret_bus); +- +- /* If we are root then let's talk directly to the system +- * instance, instead of going via the bus */ +- + r = sd_bus_new(&bus); + if (r < 0) + return r; +@@ -521,8 +515,13 @@ int bus_connect_transport_systemd( + /* Print a friendly message when the local system is actually not running systemd as PID 1. */ + return log_error_errno(SYNTHETIC_ERRNO(EHOSTDOWN), + "System has not been booted with systemd as init system (PID 1). Can't operate."); +- return bus_connect_system_systemd(ret_bus); + ++ if (geteuid() == 0) ++ /* If we are root then let's talk directly to the system ++ * instance, instead of going via the bus. */ ++ return bus_connect_system_systemd(ret_bus); ++ ++ return sd_bus_default_system(ret_bus); + default: + assert_not_reached(); + } + +From b066b683539675bc51a71259f1e0f42cef5379ad Mon Sep 17 00:00:00 2001 +From: Daan De Meyer +Date: Thu, 10 Oct 2024 15:54:37 +0200 +Subject: [PATCH 5/6] stdio-bridge: Use bus_log_connect_error() + +--- + src/stdio-bridge/stdio-bridge.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/stdio-bridge/stdio-bridge.c b/src/stdio-bridge/stdio-bridge.c +index d3629f5fb0dc5..7b774860c8eb1 100644 +--- a/src/stdio-bridge/stdio-bridge.c ++++ b/src/stdio-bridge/stdio-bridge.c +@@ -142,7 +142,7 @@ static int run(int argc, char *argv[]) { + + r = sd_bus_start(a); + if (r < 0) +- return log_error_errno(r, "Failed to start bus client: %m"); ++ return bus_log_connect_error(r, arg_transport, arg_runtime_scope); + + r = sd_bus_get_bus_id(a, &server_id); + if (r < 0) + +From d94e85c2279ac255a9c964046723684ca99b7f00 Mon Sep 17 00:00:00 2001 +From: Daan De Meyer +Date: Thu, 10 Oct 2024 15:54:57 +0200 +Subject: [PATCH 6/6] stdio-bridge: Use customized log message for forwarding + bus + +Let's more clearly indicate that we failed to set up the server +which forwards messages from the remote client to the local bus +instead of logging a generic bus client message. +--- + src/stdio-bridge/stdio-bridge.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/src/stdio-bridge/stdio-bridge.c b/src/stdio-bridge/stdio-bridge.c +index 7b774860c8eb1..22570511cbabb 100644 +--- a/src/stdio-bridge/stdio-bridge.c ++++ b/src/stdio-bridge/stdio-bridge.c +@@ -170,7 +170,7 @@ static int run(int argc, char *argv[]) { + + r = sd_bus_start(b); + if (r < 0) +- return log_error_errno(r, "Failed to start bus client: %m"); ++ return log_error_errno(r, "Failed to start bus forwarding server: %m"); + + for (;;) { + _cleanup_(sd_bus_message_unrefp) sd_bus_message *m = NULL; diff --git a/34707.patch b/34707.patch new file mode 100644 index 0000000..5d8e278 --- /dev/null +++ b/34707.patch @@ -0,0 +1,233 @@ +From da81a108653e2ef19102698dbc0184bd18b084d9 Mon Sep 17 00:00:00 2001 +From: Mike Yuan +Date: Thu, 10 Oct 2024 21:16:05 +0200 +Subject: [PATCH 1/4] core/manager: still send out STATUS=Ready for user + manager + +This effectively reverts 37d15cd132f3a8a0bf42fb252c1604e804171ff2. + +The offending commit wrongly assumed that the second READY=1 +notification is for system scope only, but it also serves the purpose +of flushing out previous STATUS= containing user unit job status. +--- + src/core/manager.c | 14 +++++++------- + 1 file changed, 7 insertions(+), 7 deletions(-) + +diff --git a/src/core/manager.c b/src/core/manager.c +index 2789f0e3d0c9c..456ad46135b72 100644 +--- a/src/core/manager.c ++++ b/src/core/manager.c +@@ -3885,7 +3885,7 @@ static void manager_notify_finished(Manager *m) { + log_taint_string(m); + } + +-static void manager_send_ready_user_scope(Manager *m) { ++static void manager_send_ready_on_basic_target(Manager *m) { + int r; + + assert(m); +@@ -3904,18 +3904,18 @@ static void manager_send_ready_user_scope(Manager *m) { + m->status_ready = false; + } + +-static void manager_send_ready_system_scope(Manager *m) { ++static void manager_send_ready_on_idle(Manager *m) { + int r; + + assert(m); + +- if (!MANAGER_IS_SYSTEM(m)) +- return; +- + /* Skip the notification if nothing changed. */ + if (m->ready_sent && m->status_ready) + return; + ++ /* Note that for user managers, we might have already sent READY=1 in manager_send_ready_user_scope(). ++ * But we still need to flush STATUS=. The second READY=1 will be treated as a noop so it doesn't ++ * hurt to send it twice. */ + r = sd_notify(/* unset_environment= */ false, + "READY=1\n" + "STATUS=Ready."); +@@ -3940,7 +3940,7 @@ static void manager_check_basic_target(Manager *m) { + return; + + /* For user managers, send out READY=1 as soon as we reach basic.target */ +- manager_send_ready_user_scope(m); ++ manager_send_ready_on_basic_target(m); + + /* Log the taint string as soon as we reach basic.target */ + log_taint_string(m); +@@ -3971,7 +3971,7 @@ void manager_check_finished(Manager *m) { + if (hashmap_buckets(m->jobs) > hashmap_size(m->units) / 10) + m->jobs = hashmap_free(m->jobs); + +- manager_send_ready_system_scope(m); ++ manager_send_ready_on_idle(m); + + /* Notify Type=idle units that we are done now */ + manager_close_idle_pipe(m); + +From 155098a702c4f6de6b1dca534661492625773fed Mon Sep 17 00:00:00 2001 +From: Mike Yuan +Date: Thu, 10 Oct 2024 21:06:35 +0200 +Subject: [PATCH 2/4] core/manager-serialize: drop serialization for + Manager.ready_sent + +This field indicates whether READY=1 has been sent to +the service manager/supervisor. Whenever we reload/reexec/soft-reboot, +manager_send_reloading() always resets it to false first, +so that READY=1 is sent after reloading finishes. Hence +we utterly get "false" at all times. Kill it. +--- + src/core/manager-serialize.c | 12 +----------- + 1 file changed, 1 insertion(+), 11 deletions(-) + +diff --git a/src/core/manager-serialize.c b/src/core/manager-serialize.c +index 62dfce93a0a85..3f624619dfd19 100644 +--- a/src/core/manager-serialize.c ++++ b/src/core/manager-serialize.c +@@ -92,7 +92,6 @@ int manager_serialize( + (void) serialize_item_format(f, "current-job-id", "%" PRIu32, m->current_job_id); + (void) serialize_item_format(f, "n-installed-jobs", "%u", m->n_installed_jobs); + (void) serialize_item_format(f, "n-failed-jobs", "%u", m->n_failed_jobs); +- (void) serialize_bool(f, "ready-sent", m->ready_sent); + (void) serialize_bool(f, "taint-logged", m->taint_logged); + (void) serialize_bool(f, "service-watchdogs", m->service_watchdogs); + +@@ -356,15 +355,6 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) { + else + m->n_failed_jobs += n; + +- } else if ((val = startswith(l, "ready-sent="))) { +- int b; +- +- b = parse_boolean(val); +- if (b < 0) +- log_notice("Failed to parse ready-sent flag '%s', ignoring.", val); +- else +- m->ready_sent = m->ready_sent || b; +- + } else if ((val = startswith(l, "taint-logged="))) { + int b; + +@@ -558,7 +548,7 @@ int manager_deserialize(Manager *m, FILE *f, FDSet *fds) { + + if (q < _MANAGER_TIMESTAMP_MAX) /* found it */ + (void) deserialize_dual_timestamp(val, m->timestamps + q); +- else if (!STARTSWITH_SET(l, "kdbus-fd=", "honor-device-enumeration=")) /* ignore deprecated values */ ++ else if (!STARTSWITH_SET(l, "kdbus-fd=", "honor-device-enumeration=", "ready-sent=")) /* ignore deprecated values */ + log_notice("Unknown serialization item '%s', ignoring.", l); + } + } + +From a375e145190482e8a2f0971bffb332e31211622f Mon Sep 17 00:00:00 2001 +From: Mike Yuan +Date: Thu, 10 Oct 2024 21:32:17 +0200 +Subject: [PATCH 3/4] units/{user,capsule}@.service: issue daemon-reexec when + notify-reloading + +Closes #28367 (but not really in the exact form, see below) + +We have the problem of restarting all user manager instances +after upgrade. Current approaches involve systemctl kill +with SIGRTMIN+25, which is async and feels rather ugly [1][2]; +or systemctl --machine=user@ --user, which requires entering +each user session. Neither is particularly elegant. +Instead, let's just signal daemon-reexec when user@.service +is reloaded from system manager. Our long goal of dropping +daemon-reload in favor of reexec (see TODO) is unlikely to happen +due to user dbus restrictions, but here the synchronization +is done via READY=1. + +[1] https://gitlab.archlinux.org/archlinux/packaging/packages/systemd/-/blob/main/systemd.install?ref_type=heads#L37 +[2] https://salsa.debian.org/systemd-team/systemd/-/blob/debian/master/debian/systemd.postinst#L24 + +#28367 would not really work for us now I come to think about it, +because all processes will be reparented to pid1 as soon as +original user manager process exits. This alternative approach +seems good enough for our use case. +--- + units/capsule@.service.in | 4 ++++ + units/user@.service.in | 4 ++++ + 2 files changed, 8 insertions(+) + +diff --git a/units/capsule@.service.in b/units/capsule@.service.in +index f2bb9e3a45a83..a64298786e490 100644 +--- a/units/capsule@.service.in ++++ b/units/capsule@.service.in +@@ -23,6 +23,10 @@ StateDirectory=capsules/%i + RuntimeDirectory=capsules/%i + LogExtraFields=CAPSULE=%i + Slice=capsule.slice ++# Reexecute the manager on service reload, instead of reloading. ++# This provides a synchronous method for restarting all user manager ++# instances after upgrade. ++ReloadSignal=RTMIN+25 + KillMode=mixed + Delegate=pids memory cpu + DelegateSubgroup=init.scope +diff --git a/units/user@.service.in b/units/user@.service.in +index 5695465747217..381ab2a0db54e 100644 +--- a/units/user@.service.in ++++ b/units/user@.service.in +@@ -20,6 +20,10 @@ PAMName=systemd-user + Type=notify-reload + ExecStart={{LIBEXECDIR}}/systemd --user + Slice=user-%i.slice ++# Reexecute the manager on service reload, instead of reloading. ++# This provides a synchronous method for restarting all user manager ++# instances after upgrade. ++ReloadSignal=RTMIN+25 + KillMode=mixed + Delegate=pids memory cpu + DelegateSubgroup=init.scope + +From 2d0af8bc354f4a1429cebedfb387af72c88720a0 Mon Sep 17 00:00:00 2001 +From: Daan De Meyer +Date: Thu, 10 Oct 2024 22:37:39 +0200 +Subject: [PATCH 4/4] rpm/systemd-update-helper: Use systemctl reload to + reexec/reload user managers + +Let's always use systemctl reload to reexec and reload user managers +now that it always implies a reexec. This moves all the job management +logic to pid 1 instead of bash and reduces the complexity of the logic +as we remove systemd-run, pam and systemd-stdio-bridge from the equation. +--- + src/rpm/systemd-update-helper.in | 20 ++++---------------- + 1 file changed, 4 insertions(+), 16 deletions(-) + +diff --git a/src/rpm/systemd-update-helper.in b/src/rpm/systemd-update-helper.in +index c81e16c3d3ffb..8af914935261a 100755 +--- a/src/rpm/systemd-update-helper.in ++++ b/src/rpm/systemd-update-helper.in +@@ -107,25 +107,13 @@ case "$command" in + + [ -d /run/systemd/system ] || exit 0 + +- users=$(systemctl list-units 'user@*' --legend=no | sed -n -r 's/.*user@([0-9]+).service.*/\1/p') +- +- if [[ "$command" =~ reexec ]]; then +- for user in $users; do +- SYSTEMD_BUS_TIMEOUT={{UPDATE_HELPER_USER_TIMEOUT_SEC}}s \ +- systemctl --user -M "$user@" daemon-reexec & +- done +- wait +- fi +- +- if [[ "$command" =~ reload ]]; then +- for user in $users; do +- SYSTEMD_BUS_TIMEOUT={{UPDATE_HELPER_USER_TIMEOUT_SEC}}s \ +- systemctl --user -M "$user@" daemon-reload & +- done +- wait ++ if [[ "$command" =~ reexec|reload ]]; then ++ SYSTEMD_BUS_TIMEOUT={{UPDATE_HELPER_USER_TIMEOUT_SEC}}s systemctl reload "user@*.service" + fi + + if [[ "$command" =~ restart ]]; then ++ users=$(systemctl list-units 'user@*' --legend=no | sed -n -r 's/.*user@([0-9]+).service.*/\1/p') ++ + for user in $users; do + SYSTEMD_BUS_TIMEOUT={{UPDATE_HELPER_USER_TIMEOUT_SEC}}s \ + systemctl --user -M "$user@" reload-or-restart --marked & diff --git a/34728.patch b/34728.patch new file mode 100644 index 0000000..158fee3 --- /dev/null +++ b/34728.patch @@ -0,0 +1,580 @@ +From 871ee2f08715f8fae441786db04ba8497822f79a Mon Sep 17 00:00:00 2001 +From: Daan De Meyer +Date: Tue, 8 Oct 2024 16:22:58 +0200 +Subject: [PATCH 1/3] bus-util: Log more information when connecting to a bus + socket fails + +Let's log about which bus we're trying to connect to and what transport +we're using to do it. + +(cherry picked from commit d8a77d55e6ad7f251ae0eb6758af6bba111095df) +--- + src/analyze/analyze-blame.c | 2 +- + src/analyze/analyze-critical-chain.c | 2 +- + src/analyze/analyze-dot.c | 2 +- + src/analyze/analyze-dump.c | 2 +- + src/analyze/analyze-fdstore.c | 2 +- + src/analyze/analyze-log-control.c | 2 +- + src/analyze/analyze-malloc.c | 2 +- + src/analyze/analyze-plot.c | 2 +- + src/analyze/analyze-security.c | 2 +- + src/analyze/analyze-service-watchdogs.c | 2 +- + src/analyze/analyze-time.c | 2 +- + src/busctl/busctl.c | 2 +- + src/cgls/cgls.c | 9 ++++----- + src/firstboot/firstboot.c | 4 ++-- + src/home/homectl.c | 2 +- + src/hostname/hostnamectl.c | 2 +- + src/import/importctl.c | 2 +- + src/locale/localectl.c | 2 +- + src/login/inhibit.c | 2 +- + src/login/loginctl.c | 2 +- + src/machine/machinectl.c | 2 +- + src/mount/mount-tool.c | 2 +- + src/portable/portablectl.c | 2 +- + src/run/run.c | 2 +- + src/shared/bus-util.c | 18 ++++++++++++++---- + src/shared/bus-util.h | 4 +++- + src/shared/cgroup-show.c | 2 +- + src/systemctl/systemctl-util.c | 2 +- + src/timedate/timedatectl.c | 2 +- + 29 files changed, 48 insertions(+), 37 deletions(-) + +diff --git a/src/analyze/analyze-blame.c b/src/analyze/analyze-blame.c +index 81e5c590b9cc2..4d78ed405d7d4 100644 +--- a/src/analyze/analyze-blame.c ++++ b/src/analyze/analyze-blame.c +@@ -14,7 +14,7 @@ int verb_blame(int argc, char *argv[], void *userdata) { + + r = acquire_bus(&bus, NULL); + if (r < 0) +- return bus_log_connect_error(r, arg_transport); ++ return bus_log_connect_error(r, arg_transport, arg_runtime_scope); + + n = acquire_time_data(bus, /* require_finished = */ false, ×); + if (n <= 0) +diff --git a/src/analyze/analyze-critical-chain.c b/src/analyze/analyze-critical-chain.c +index 7d78de3d388d1..03c014d4023e6 100644 +--- a/src/analyze/analyze-critical-chain.c ++++ b/src/analyze/analyze-critical-chain.c +@@ -200,7 +200,7 @@ int verb_critical_chain(int argc, char *argv[], void *userdata) { + + r = acquire_bus(&bus, NULL); + if (r < 0) +- return bus_log_connect_error(r, arg_transport); ++ return bus_log_connect_error(r, arg_transport, arg_runtime_scope); + + n = acquire_time_data(bus, /* require_finished = */ true, ×); + if (n <= 0) +diff --git a/src/analyze/analyze-dot.c b/src/analyze/analyze-dot.c +index 9e92d59bceeee..b93bf4a9a5bb0 100644 +--- a/src/analyze/analyze-dot.c ++++ b/src/analyze/analyze-dot.c +@@ -149,7 +149,7 @@ int verb_dot(int argc, char *argv[], void *userdata) { + + r = acquire_bus(&bus, NULL); + if (r < 0) +- return bus_log_connect_error(r, arg_transport); ++ return bus_log_connect_error(r, arg_transport, arg_runtime_scope); + + r = expand_patterns(bus, strv_skip(argv, 1), &expanded_patterns); + if (r < 0) +diff --git a/src/analyze/analyze-dump.c b/src/analyze/analyze-dump.c +index 2642582903b09..4ee547ed4c969 100644 +--- a/src/analyze/analyze-dump.c ++++ b/src/analyze/analyze-dump.c +@@ -123,7 +123,7 @@ int verb_dump(int argc, char *argv[], void *userdata) { + + r = acquire_bus(&bus, NULL); + if (r < 0) +- return bus_log_connect_error(r, arg_transport); ++ return bus_log_connect_error(r, arg_transport, arg_runtime_scope); + + pager_open(arg_pager_flags); + +diff --git a/src/analyze/analyze-fdstore.c b/src/analyze/analyze-fdstore.c +index 8ada6d4e73e1f..1f4adb7089ab0 100644 +--- a/src/analyze/analyze-fdstore.c ++++ b/src/analyze/analyze-fdstore.c +@@ -98,7 +98,7 @@ int verb_fdstore(int argc, char *argv[], void *userdata) { + + r = acquire_bus(&bus, NULL); + if (r < 0) +- return bus_log_connect_error(r, arg_transport); ++ return bus_log_connect_error(r, arg_transport, arg_runtime_scope); + + STRV_FOREACH(arg, strv_skip(argv, 1)) { + r = dump_fdstore(bus, *arg); +diff --git a/src/analyze/analyze-log-control.c b/src/analyze/analyze-log-control.c +index cead0e833f5da..854cf6cb806c2 100644 +--- a/src/analyze/analyze-log-control.c ++++ b/src/analyze/analyze-log-control.c +@@ -12,7 +12,7 @@ int verb_log_control(int argc, char *argv[], void *userdata) { + + r = acquire_bus(&bus, NULL); + if (r < 0) +- return bus_log_connect_error(r, arg_transport); ++ return bus_log_connect_error(r, arg_transport, arg_runtime_scope); + + r = verb_log_control_common(bus, "org.freedesktop.systemd1", argv[0], argc == 2 ? argv[1] : NULL); + if (r < 0) +diff --git a/src/analyze/analyze-malloc.c b/src/analyze/analyze-malloc.c +index 5e6ff5bb9627c..514526d14256a 100644 +--- a/src/analyze/analyze-malloc.c ++++ b/src/analyze/analyze-malloc.c +@@ -43,7 +43,7 @@ int verb_malloc(int argc, char *argv[], void *userdata) { + + r = acquire_bus(&bus, NULL); + if (r < 0) +- return bus_log_connect_error(r, arg_transport); ++ return bus_log_connect_error(r, arg_transport, arg_runtime_scope); + + r = sd_bus_can_send(bus, SD_BUS_TYPE_UNIX_FD); + if (r < 0) +diff --git a/src/analyze/analyze-plot.c b/src/analyze/analyze-plot.c +index e271296b6875b..ce67c092c37cd 100644 +--- a/src/analyze/analyze-plot.c ++++ b/src/analyze/analyze-plot.c +@@ -468,7 +468,7 @@ int verb_plot(int argc, char *argv[], void *userdata) { + + r = acquire_bus(&bus, &use_full_bus); + if (r < 0) +- return bus_log_connect_error(r, arg_transport); ++ return bus_log_connect_error(r, arg_transport, arg_runtime_scope); + + n = acquire_boot_times(bus, /* require_finished = */ true, &boot); + if (n < 0) +diff --git a/src/analyze/analyze-security.c b/src/analyze/analyze-security.c +index 3d7b647a6f361..d3ba975107297 100644 +--- a/src/analyze/analyze-security.c ++++ b/src/analyze/analyze-security.c +@@ -2904,7 +2904,7 @@ int verb_security(int argc, char *argv[], void *userdata) { + if (!arg_offline) { + r = acquire_bus(&bus, NULL); + if (r < 0) +- return bus_log_connect_error(r, arg_transport); ++ return bus_log_connect_error(r, arg_transport, arg_runtime_scope); + } + + pager_open(arg_pager_flags); +diff --git a/src/analyze/analyze-service-watchdogs.c b/src/analyze/analyze-service-watchdogs.c +index 6535eb1a894f7..b1fad4328caa5 100644 +--- a/src/analyze/analyze-service-watchdogs.c ++++ b/src/analyze/analyze-service-watchdogs.c +@@ -16,7 +16,7 @@ int verb_service_watchdogs(int argc, char *argv[], void *userdata) { + + r = acquire_bus(&bus, NULL); + if (r < 0) +- return bus_log_connect_error(r, arg_transport); ++ return bus_log_connect_error(r, arg_transport, arg_runtime_scope); + + if (argc == 1) { + /* get ServiceWatchdogs */ +diff --git a/src/analyze/analyze-time.c b/src/analyze/analyze-time.c +index c233b1f08558e..8135112dec42b 100644 +--- a/src/analyze/analyze-time.c ++++ b/src/analyze/analyze-time.c +@@ -11,7 +11,7 @@ int verb_time(int argc, char *argv[], void *userdata) { + + r = acquire_bus(&bus, NULL); + if (r < 0) +- return bus_log_connect_error(r, arg_transport); ++ return bus_log_connect_error(r, arg_transport, arg_runtime_scope); + + r = pretty_boot_time(bus, &buf); + if (r < 0) +diff --git a/src/busctl/busctl.c b/src/busctl/busctl.c +index 8db9076997232..bbd36c1dc42bc 100644 +--- a/src/busctl/busctl.c ++++ b/src/busctl/busctl.c +@@ -152,7 +152,7 @@ static int acquire_bus(bool set_monitor, sd_bus **ret) { + + r = sd_bus_start(bus); + if (r < 0) +- return bus_log_connect_error(r, arg_transport); ++ return bus_log_connect_error(r, arg_transport, arg_runtime_scope); + + *ret = TAKE_PTR(bus); + +diff --git a/src/cgls/cgls.c b/src/cgls/cgls.c +index 70fa260246929..1dcd316cdb379 100644 +--- a/src/cgls/cgls.c ++++ b/src/cgls/cgls.c +@@ -221,13 +221,12 @@ static int run(int argc, char *argv[]) { + return log_error_errno(r, "Failed to mangle unit name: %m"); + + if (!bus) { ++ RuntimeScope scope = arg_show_unit == SHOW_UNIT_USER ? RUNTIME_SCOPE_USER : RUNTIME_SCOPE_SYSTEM; ++ + /* Connect to the bus only if necessary */ +- r = bus_connect_transport_systemd( +- BUS_TRANSPORT_LOCAL, NULL, +- arg_show_unit == SHOW_UNIT_USER ? RUNTIME_SCOPE_USER : RUNTIME_SCOPE_SYSTEM, +- &bus); ++ r = bus_connect_transport_systemd(BUS_TRANSPORT_LOCAL, NULL, scope, &bus); + if (r < 0) +- return bus_log_connect_error(r, BUS_TRANSPORT_LOCAL); ++ return bus_log_connect_error(r, BUS_TRANSPORT_LOCAL, scope); + } + + q = show_cgroup_get_unit_path_and_warn(bus, unit_name, &cgroup); +diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c +index 0dbdfc663871f..3b732b38609ab 100644 +--- a/src/firstboot/firstboot.c ++++ b/src/firstboot/firstboot.c +@@ -1616,7 +1616,7 @@ static int reload_system_manager(sd_bus **bus) { + if (!*bus) { + r = bus_connect_transport_systemd(BUS_TRANSPORT_LOCAL, NULL, RUNTIME_SCOPE_SYSTEM, bus); + if (r < 0) +- return bus_log_connect_error(r, BUS_TRANSPORT_LOCAL); ++ return bus_log_connect_error(r, BUS_TRANSPORT_LOCAL, RUNTIME_SCOPE_SYSTEM); + } + + r = bus_service_manager_reload(*bus); +@@ -1639,7 +1639,7 @@ static int reload_vconsole(sd_bus **bus) { + if (!*bus) { + r = bus_connect_transport_systemd(BUS_TRANSPORT_LOCAL, NULL, RUNTIME_SCOPE_SYSTEM, bus); + if (r < 0) +- return bus_log_connect_error(r, BUS_TRANSPORT_LOCAL); ++ return bus_log_connect_error(r, BUS_TRANSPORT_LOCAL, RUNTIME_SCOPE_SYSTEM); + } + + r = bus_wait_for_jobs_new(*bus, &w); +diff --git a/src/home/homectl.c b/src/home/homectl.c +index 346daa1195ccd..36e3bf729948f 100644 +--- a/src/home/homectl.c ++++ b/src/home/homectl.c +@@ -134,7 +134,7 @@ static int acquire_bus(sd_bus **bus) { + + r = bus_connect_transport(arg_transport, arg_host, RUNTIME_SCOPE_SYSTEM, bus); + if (r < 0) +- return bus_log_connect_error(r, arg_transport); ++ return bus_log_connect_error(r, arg_transport, RUNTIME_SCOPE_SYSTEM); + + (void) sd_bus_set_allow_interactive_authorization(*bus, arg_ask_password); + +diff --git a/src/hostname/hostnamectl.c b/src/hostname/hostnamectl.c +index d1c4d476f66b9..ead0cc4da6e82 100644 +--- a/src/hostname/hostnamectl.c ++++ b/src/hostname/hostnamectl.c +@@ -813,7 +813,7 @@ static int run(int argc, char *argv[]) { + + r = bus_connect_transport(arg_transport, arg_host, RUNTIME_SCOPE_SYSTEM, &bus); + if (r < 0) +- return bus_log_connect_error(r, arg_transport); ++ return bus_log_connect_error(r, arg_transport, RUNTIME_SCOPE_SYSTEM); + + return hostnamectl_main(bus, argc, argv); + } +diff --git a/src/import/importctl.c b/src/import/importctl.c +index f939d80815dca..da9e5b62d23d6 100644 +--- a/src/import/importctl.c ++++ b/src/import/importctl.c +@@ -1235,7 +1235,7 @@ static int run(int argc, char *argv[]) { + + r = bus_connect_transport(arg_transport, arg_host, RUNTIME_SCOPE_SYSTEM, &bus); + if (r < 0) +- return bus_log_connect_error(r, arg_transport); ++ return bus_log_connect_error(r, arg_transport, RUNTIME_SCOPE_SYSTEM); + + (void) sd_bus_set_allow_interactive_authorization(bus, arg_ask_password); + +diff --git a/src/locale/localectl.c b/src/locale/localectl.c +index 32354027f1755..2fb4657fe24fb 100644 +--- a/src/locale/localectl.c ++++ b/src/locale/localectl.c +@@ -527,7 +527,7 @@ static int run(int argc, char *argv[]) { + + r = bus_connect_transport(arg_transport, arg_host, RUNTIME_SCOPE_SYSTEM, &bus); + if (r < 0) +- return bus_log_connect_error(r, arg_transport); ++ return bus_log_connect_error(r, arg_transport, RUNTIME_SCOPE_SYSTEM); + + return localectl_main(bus, argc, argv); + } +diff --git a/src/login/inhibit.c b/src/login/inhibit.c +index 4682830d198a8..e060c614004b1 100644 +--- a/src/login/inhibit.c ++++ b/src/login/inhibit.c +@@ -265,7 +265,7 @@ static int run(int argc, char *argv[]) { + + r = sd_bus_default_system(&bus); + if (r < 0) +- return bus_log_connect_error(r, BUS_TRANSPORT_LOCAL); ++ return bus_log_connect_error(r, BUS_TRANSPORT_LOCAL, RUNTIME_SCOPE_SYSTEM); + + if (arg_action == ACTION_LIST) + return print_inhibitors(bus); +diff --git a/src/login/loginctl.c b/src/login/loginctl.c +index cf3bff437a0bc..e950bfc985ff5 100644 +--- a/src/login/loginctl.c ++++ b/src/login/loginctl.c +@@ -1727,7 +1727,7 @@ static int run(int argc, char *argv[]) { + + r = bus_connect_transport(arg_transport, arg_host, RUNTIME_SCOPE_SYSTEM, &bus); + if (r < 0) +- return bus_log_connect_error(r, arg_transport); ++ return bus_log_connect_error(r, arg_transport, RUNTIME_SCOPE_SYSTEM); + + (void) sd_bus_set_allow_interactive_authorization(bus, arg_ask_password); + +diff --git a/src/machine/machinectl.c b/src/machine/machinectl.c +index 1b63e6d203786..b9105f298b6b1 100644 +--- a/src/machine/machinectl.c ++++ b/src/machine/machinectl.c +@@ -2446,7 +2446,7 @@ static int run(int argc, char *argv[]) { + + r = bus_connect_transport(arg_transport, arg_host, RUNTIME_SCOPE_SYSTEM, &bus); + if (r < 0) +- return bus_log_connect_error(r, arg_transport); ++ return bus_log_connect_error(r, arg_transport, RUNTIME_SCOPE_SYSTEM); + + (void) sd_bus_set_allow_interactive_authorization(bus, arg_ask_password); + +diff --git a/src/mount/mount-tool.c b/src/mount/mount-tool.c +index fcebdcaf18c9b..b991bed714896 100644 +--- a/src/mount/mount-tool.c ++++ b/src/mount/mount-tool.c +@@ -1503,7 +1503,7 @@ static int run(int argc, char* argv[]) { + + r = bus_connect_transport_systemd(arg_transport, arg_host, arg_runtime_scope, &bus); + if (r < 0) +- return bus_log_connect_error(r, arg_transport); ++ return bus_log_connect_error(r, arg_transport, arg_runtime_scope); + + if (arg_action == ACTION_UMOUNT) + return action_umount(bus, argc, argv); +diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c +index 57b930d6cba41..2681cf4dd2070 100644 +--- a/src/portable/portablectl.c ++++ b/src/portable/portablectl.c +@@ -229,7 +229,7 @@ static int acquire_bus(sd_bus **bus) { + + r = bus_connect_transport(arg_transport, arg_host, RUNTIME_SCOPE_SYSTEM, bus); + if (r < 0) +- return bus_log_connect_error(r, arg_transport); ++ return bus_log_connect_error(r, arg_transport, RUNTIME_SCOPE_SYSTEM); + + (void) sd_bus_set_allow_interactive_authorization(*bus, arg_ask_password); + +diff --git a/src/run/run.c b/src/run/run.c +index ba7bb2148a15f..3a7102e32923b 100644 +--- a/src/run/run.c ++++ b/src/run/run.c +@@ -2405,7 +2405,7 @@ static int run(int argc, char* argv[]) { + else + r = bus_connect_transport_systemd(arg_transport, arg_host, arg_runtime_scope, &bus); + if (r < 0) +- return bus_log_connect_error(r, arg_transport); ++ return bus_log_connect_error(r, arg_transport, arg_runtime_scope); + + if (arg_scope) + return start_transient_scope(bus); +diff --git a/src/shared/bus-util.c b/src/shared/bus-util.c +index 30f9602b1edbc..f347ea604ec25 100644 +--- a/src/shared/bus-util.c ++++ b/src/shared/bus-util.c +@@ -28,6 +28,7 @@ + #include "path-util.h" + #include "socket-util.h" + #include "stdio-util.h" ++#include "string-table.h" + #include "uid-classification.h" + + static int name_owner_change_callback(sd_bus_message *m, void *userdata, sd_bus_error *ret_error) { +@@ -49,14 +50,14 @@ int bus_log_address_error(int r, BusTransport transport) { + "Failed to set bus address: %m"); + } + +-int bus_log_connect_error(int r, BusTransport transport) { ++int bus_log_connect_error(int r, BusTransport transport, RuntimeScope scope) { + bool hint_vars = transport == BUS_TRANSPORT_LOCAL && r == -ENOMEDIUM, + hint_addr = transport == BUS_TRANSPORT_LOCAL && ERRNO_IS_PRIVILEGE(r); + + return log_error_errno(r, +- r == hint_vars ? "Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=@.host --user to connect to bus of other user)" : +- r == hint_addr ? "Failed to connect to bus: Operation not permitted (consider using --machine=@.host --user to connect to bus of other user)" : +- "Failed to connect to bus: %m"); ++ r == hint_vars ? "Failed to connect to %s scope bus via %s transport: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=@.host --user to connect to bus of other user)" : ++ r == hint_addr ? "Failed to connect to %s scope bus via %s transport: Operation not permitted (consider using --machine=@.host --user to connect to bus of other user)" : ++ "Failed to connect to %s scope bus via %s transport: %m", runtime_scope_to_string(scope), bus_transport_to_string(transport)); + } + + int bus_async_unregister_and_exit(sd_event *e, sd_bus *bus, const char *name) { +@@ -926,3 +927,12 @@ int bus_message_read_id128(sd_bus_message *m, sd_id128_t *ret) { + return -EINVAL; + } + } ++ ++static const char* const bus_transport_table[] = { ++ [BUS_TRANSPORT_LOCAL] = "local", ++ [BUS_TRANSPORT_REMOTE] = "remote", ++ [BUS_TRANSPORT_MACHINE] = "machine", ++ [BUS_TRANSPORT_CAPSULE] = "capsule", ++}; ++ ++DEFINE_STRING_TABLE_LOOKUP_TO_STRING(bus_transport, BusTransport); +diff --git a/src/shared/bus-util.h b/src/shared/bus-util.h +index 9c6f01d8eb846..fbccb24314fe4 100644 +--- a/src/shared/bus-util.h ++++ b/src/shared/bus-util.h +@@ -48,7 +48,7 @@ int bus_connect_transport(BusTransport transport, const char *host, RuntimeScope + int bus_connect_transport_systemd(BusTransport transport, const char *host, RuntimeScope runtime_scope, sd_bus **bus); + + int bus_log_address_error(int r, BusTransport transport); +-int bus_log_connect_error(int r, BusTransport transport); ++int bus_log_connect_error(int r, BusTransport transport, RuntimeScope scope); + + #define bus_log_parse_error(r) \ + log_error_errno(r, "Failed to parse bus message: %m") +@@ -84,3 +84,5 @@ int bus_creds_get_pidref(sd_bus_creds *c, PidRef *ret); + int bus_query_sender_pidref(sd_bus_message *m, PidRef *ret); + + int bus_message_read_id128(sd_bus_message *m, sd_id128_t *ret); ++ ++const char* bus_transport_to_string(BusTransport transport) _const_; +diff --git a/src/shared/cgroup-show.c b/src/shared/cgroup-show.c +index 87177316da8f9..96826ac7d8e87 100644 +--- a/src/shared/cgroup-show.c ++++ b/src/shared/cgroup-show.c +@@ -433,7 +433,7 @@ int show_cgroup_get_path_and_warn( + + r = bus_connect_transport_systemd(BUS_TRANSPORT_LOCAL, NULL, RUNTIME_SCOPE_SYSTEM, &bus); + if (r < 0) +- return bus_log_connect_error(r, BUS_TRANSPORT_LOCAL); ++ return bus_log_connect_error(r, BUS_TRANSPORT_LOCAL, RUNTIME_SCOPE_SYSTEM); + + r = show_cgroup_get_unit_path_and_warn(bus, unit, &root); + if (r < 0) +diff --git a/src/systemctl/systemctl-util.c b/src/systemctl/systemctl-util.c +index 38e1f23740ed6..18c8823e3fe70 100644 +--- a/src/systemctl/systemctl-util.c ++++ b/src/systemctl/systemctl-util.c +@@ -54,7 +54,7 @@ int acquire_bus(BusFocus focus, sd_bus **ret) { + else + r = bus_connect_transport(arg_transport, arg_host, arg_runtime_scope, &buses[focus]); + if (r < 0) +- return bus_log_connect_error(r, arg_transport); ++ return bus_log_connect_error(r, arg_transport, arg_runtime_scope); + + (void) sd_bus_set_allow_interactive_authorization(buses[focus], arg_ask_password); + } +diff --git a/src/timedate/timedatectl.c b/src/timedate/timedatectl.c +index 46ec6b31bc46a..db9f3b22b9b5e 100644 +--- a/src/timedate/timedatectl.c ++++ b/src/timedate/timedatectl.c +@@ -1031,7 +1031,7 @@ static int run(int argc, char *argv[]) { + + r = bus_connect_transport(arg_transport, arg_host, RUNTIME_SCOPE_SYSTEM, &bus); + if (r < 0) +- return bus_log_connect_error(r, arg_transport); ++ return bus_log_connect_error(r, arg_transport, RUNTIME_SCOPE_SYSTEM); + + return timedatectl_main(bus, argc, argv); + } + +From 31e38b55b2e4bb1aa42fe106ea14df8e82758303 Mon Sep 17 00:00:00 2001 +From: Daan De Meyer +Date: Tue, 8 Oct 2024 16:25:52 +0200 +Subject: [PATCH 2/3] core: Bump log level of reexecute request to notice + +A daemon-reload is important enough to deserve logging at notice +level. + +(cherry picked from commit 4ee41be82507348fbbc9d3ab28aae6330eb51663) +--- + src/core/dbus-manager.c | 8 ++++---- + 1 file changed, 4 insertions(+), 4 deletions(-) + +diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c +index 7da35a803c62c..2412bd1aab742 100644 +--- a/src/core/dbus-manager.c ++++ b/src/core/dbus-manager.c +@@ -1571,10 +1571,10 @@ static void log_caller(sd_bus_message *message, Manager *manager, const char *me + (void) sd_bus_creds_get_comm(creds, &comm); + caller = manager_get_unit_by_pid(manager, pid); + +- log_info("%s requested from client PID " PID_FMT "%s%s%s%s%s%s...", +- method, pid, +- comm ? " ('" : "", strempty(comm), comm ? "')" : "", +- caller ? " (unit " : "", caller ? caller->id : "", caller ? ")" : ""); ++ log_notice("%s requested from client PID " PID_FMT "%s%s%s%s%s%s...", ++ method, pid, ++ comm ? " ('" : "", strempty(comm), comm ? "')" : "", ++ caller ? " (unit " : "", caller ? caller->id : "", caller ? ")" : ""); + } + + static int method_reload(sd_bus_message *message, void *userdata, sd_bus_error *error) { + +From 814be7116dda14074749253d94b83387ceff0ff1 Mon Sep 17 00:00:00 2001 +From: Daan De Meyer +Date: Tue, 8 Oct 2024 16:28:25 +0200 +Subject: [PATCH 3/3] core: Log in more scenarios about which process initiated + an operation + +Exit/Reboot/Poweroff and similar operations are invasive enough that +logging about who initiated them is very useful to debug issues. + +(cherry picked from commit acb0f501f4291efce82bcf89d4ad92b6a895f4fa) +--- + src/core/dbus-manager.c | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/src/core/dbus-manager.c b/src/core/dbus-manager.c +index 2412bd1aab742..0c1260f2d9cbe 100644 +--- a/src/core/dbus-manager.c ++++ b/src/core/dbus-manager.c +@@ -1671,6 +1671,8 @@ static int method_exit(sd_bus_message *message, void *userdata, sd_bus_error *er + if (r < 0) + return r; + ++ log_caller(message, m, "Exit"); ++ + /* Exit() (in contrast to SetExitCode()) is actually allowed even if + * we are running on the host. It will fall back on reboot() in + * systemd-shutdown if it cannot do the exit() because it isn't a +@@ -1695,6 +1697,8 @@ static int method_reboot(sd_bus_message *message, void *userdata, sd_bus_error * + return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, + "Reboot is only supported for system managers."); + ++ log_caller(message, m, "Reboot"); ++ + m->objective = MANAGER_REBOOT; + + return sd_bus_reply_method_return(message, NULL); +@@ -1737,6 +1741,8 @@ static int method_soft_reboot(sd_bus_message *message, void *userdata, sd_bus_er + return -ENOMEM; + } + ++ log_caller(message, m, "Soft reboot"); ++ + free_and_replace(m->switch_root, rt); + m->objective = MANAGER_SOFT_REBOOT; + +@@ -1757,6 +1763,8 @@ static int method_poweroff(sd_bus_message *message, void *userdata, sd_bus_error + return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, + "Powering off is only supported for system managers."); + ++ log_caller(message, m, "Poweroff"); ++ + m->objective = MANAGER_POWEROFF; + + return sd_bus_reply_method_return(message, NULL); +@@ -1776,6 +1784,8 @@ static int method_halt(sd_bus_message *message, void *userdata, sd_bus_error *er + return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, + "Halt is only supported for system managers."); + ++ log_caller(message, m, "Halt"); ++ + m->objective = MANAGER_HALT; + + return sd_bus_reply_method_return(message, NULL); +@@ -1795,6 +1805,8 @@ static int method_kexec(sd_bus_message *message, void *userdata, sd_bus_error *e + return sd_bus_error_setf(error, SD_BUS_ERROR_NOT_SUPPORTED, + "KExec is only supported for system managers."); + ++ log_caller(message, m, "Kexec"); ++ + m->objective = MANAGER_KEXEC; + + return sd_bus_reply_method_return(message, NULL);