diff options
author | Mike Yuan <me@yhndnzj.com> | 2024-07-02 18:14:33 +0200 |
---|---|---|
committer | Mike Yuan <me@yhndnzj.com> | 2024-07-03 10:12:53 +0200 |
commit | 33a06bbc742fc27d24127a2d6a64d5f2f5cf23dd (patch) | |
tree | c668be586718ee2ab89b36717bef3f2509871574 /src/core/main.c | |
parent | core/manager: invoke special targets on signal only for system manager (diff) | |
download | systemd-33a06bbc742fc27d24127a2d6a64d5f2f5cf23dd.tar.xz systemd-33a06bbc742fc27d24127a2d6a64d5f2f5cf23dd.zip |
core/main: add an assertion to ensure user managers won't initiate destructive/system-wide operation
Diffstat (limited to 'src/core/main.c')
-rw-r--r-- | src/core/main.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/core/main.c b/src/core/main.c index 6792a79c1f..8dc0245fa0 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(); |