1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-22 17:35:35 +03:00

systemctl: gracefully adjust bus transport and runtime scope when --boot-loader-entry=help

This fixes the following assertion:
===
SYSTEMD_LOG_LEVEL=debug systemctl --user -H foo --boot-loader-entry=help
Assertion 'transport != BUS_TRANSPORT_REMOTE || runtime_scope == RUNTIME_SCOPE_SYSTEM' failed at src/shared/bus-util.c:284, function bus_connect_transport(). Ignoring.
Failed to connect to bus: Operation not supported
===

Fixes a bug introduced by 97af80c5a7.
Fixes #33661.
Fixes oss-fuzz#70153.
This commit is contained in:
Yu Watanabe 2024-08-04 14:09:53 +09:00
parent bcf982223c
commit 1056457d11
2 changed files with 8 additions and 0 deletions

View File

@ -432,6 +432,14 @@ int help_boot_loader_entry(void) {
sd_bus *bus;
int r;
/* This is called without checking runtime scope and bus transport like we do in parse_argv().
* Loading boot entries is only supported by system scope. Let's gracefully adjust them. */
arg_runtime_scope = RUNTIME_SCOPE_SYSTEM;
if (arg_transport == BUS_TRANSPORT_CAPSULE) {
arg_host = NULL;
arg_transport = BUS_TRANSPORT_LOCAL;
}
r = acquire_bus(BUS_FULL, &bus);
if (r < 0)
return r;

Binary file not shown.