diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-08-04 07:09:53 +0200 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2024-08-05 22:33:25 +0200 |
commit | 1056457d1132e78cbf914e8abfa661465b952412 (patch) | |
tree | 0fb29262baa16c8db3516c58d47544e4a07d828f /src | |
parent | systemctl: refuse --capsule=foo with --system (diff) | |
download | systemd-1056457d1132e78cbf914e8abfa661465b952412.tar.xz systemd-1056457d1132e78cbf914e8abfa661465b952412.zip |
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 97af80c5a7029c3f92e982dcf9338b9e67ad9cde.
Fixes #33661.
Fixes oss-fuzz#70153.
Diffstat (limited to 'src')
-rw-r--r-- | src/systemctl/systemctl-logind.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/systemctl/systemctl-logind.c b/src/systemctl/systemctl-logind.c index a727606eea..e4ef7cf915 100644 --- a/src/systemctl/systemctl-logind.c +++ b/src/systemctl/systemctl-logind.c @@ -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; |