dbus: mirror legacy runlevel edge cases in Manager1.SetRunlevel

The bus method called sm_runlevel() unconditionally.  In runlevel 0
and 6 that aborts an in-flight shutdown, which INIT_CMD_RUNLVL
refuses with a warning, and during bootstrap it switches immediately
where the legacy path defers via cfglevel to the end of runlevel S.

Port both.  A bad runlevel argument still returns InvalidArgs, where
the legacy protocol acks silently: a typed interface rejects garbage.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2026-08-16 22:03:37 +02:00
1 parent 8114508bbb
commit b53c7e6879
4 files changed
+29 -23

No files matched your search

+1 -3
View File
@@ -454,9 +454,7 @@ static int manager_set_runlevel(link_call_t *call, void *userdata)
"org.freedesktop.DBus.Error.InvalidArgs",
"runlevel must be 0-9 (excluding internal levels)");
if (lvl == 0) halt = SHUT_OFF;
if (lvl == 6) halt = SHUT_REBOOT;
sm_runlevel((int)lvl);
sm_request_runlevel((int)lvl);
(void)link_call_reply(call);
return 0;