From: Mike Yuan Date: Tue, 2 Jul 2024 16:14:33 +0000 (+0200) Subject: core/main: add an assertion to ensure user managers won't initiate destructive/system... X-Git-Tag: v257-rc1~986^2 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F33575%2Fhead;p=thirdparty%2Fsystemd.git core/main: add an assertion to ensure user managers won't initiate destructive/system-wide operation --- diff --git a/src/core/main.c b/src/core/main.c index 6792a79c1f4..8dc0245fa0c 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -3285,14 +3285,15 @@ int main(int argc, char *argv[]) { &switch_root_dir, &switch_root_init, &error_message); - assert(r < 0 || IN_SET(r, MANAGER_EXIT, /* MANAGER_OK and MANAGER_RELOAD are not expected here. */ - MANAGER_REEXECUTE, - MANAGER_REBOOT, - MANAGER_SOFT_REBOOT, - MANAGER_POWEROFF, - MANAGER_HALT, - MANAGER_KEXEC, - MANAGER_SWITCH_ROOT)); + /* MANAGER_OK and MANAGER_RELOAD are not expected here. */ + assert(r < 0 || IN_SET(r, MANAGER_REEXECUTE, MANAGER_EXIT) || + (arg_runtime_scope == RUNTIME_SCOPE_SYSTEM && + IN_SET(r, MANAGER_REBOOT, + MANAGER_SOFT_REBOOT, + MANAGER_POWEROFF, + MANAGER_HALT, + MANAGER_KEXEC, + MANAGER_SWITCH_ROOT))); finish: pager_close();