mirror of
https://github.com/troglobit/finit.git
synced 2026-11-13 17:00:16 +00:00
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:
4 files changed
+29
-23
No files matched your search
@@ -94,6 +94,30 @@ static void shutdown_wdt_cb(uev_t *w, void *arg, int events)
|
||||
do_shutdown(halt);
|
||||
}
|
||||
|
||||
/*
|
||||
* User-requested runlevel change, shared by the legacy API and the
|
||||
* D-Bus SetRunlevel method. Refused in runlevel 0/6, deferred via
|
||||
* cfglevel during bootstrap.
|
||||
*/
|
||||
void sm_request_runlevel(int lvl)
|
||||
{
|
||||
if (IS_RESERVED_RUNLEVEL(runlevel) && runlevel != INIT_LEVEL) {
|
||||
warnx("Cannot abort runlevel 6/0.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (lvl == 0)
|
||||
halt = SHUT_OFF;
|
||||
if (lvl == 6)
|
||||
halt = SHUT_REBOOT;
|
||||
|
||||
/* Runlevel S: user requested change in next runlevel */
|
||||
if (runlevel == INIT_LEVEL)
|
||||
cfglevel = lvl;
|
||||
else
|
||||
sm_runlevel(lvl);
|
||||
}
|
||||
|
||||
/*
|
||||
* Console input callback - handles Ctrl-C during bootstrap wait
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user