]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: gracefully adjust bus transport and runtime scope when --boot-loader-entry... 33933/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 4 Aug 2024 05:09:53 +0000 (14:09 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Mon, 5 Aug 2024 20:33:25 +0000 (05:33 +0900)
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.

src/systemctl/systemctl-logind.c
test/fuzz/fuzz-systemctl-parse-argv/oss-fuzz-70153 [new file with mode: 0644]

index a727606eea7d4610d9719cc563f8c04346b39748..e4ef7cf9154ca2ce730d5c11d871df3f245c9d94 100644 (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;
diff --git a/test/fuzz/fuzz-systemctl-parse-argv/oss-fuzz-70153 b/test/fuzz/fuzz-systemctl-parse-argv/oss-fuzz-70153
new file mode 100644 (file)
index 0000000..cb874fa
Binary files /dev/null and b/test/fuzz/fuzz-systemctl-parse-argv/oss-fuzz-70153 differ