]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
manager: move is-system check into manager_enable_special_signals()
authorLennart Poettering <lennart@poettering.net>
Thu, 11 Jul 2024 12:33:38 +0000 (14:33 +0200)
committerLennart Poettering <lennart@poettering.net>
Fri, 12 Jul 2024 02:47:19 +0000 (04:47 +0200)
It's usually how we do this: make the functions robust to be called in
any context, and validate the context in the functions themselves early,
instead of in the caller.

src/core/manager.c

index f5588380d63214645091cb02abae4acf9cae7b9d..1504d3fd7de0dcc24f0b9e49b5a3df272d125400 100644 (file)
@@ -477,12 +477,12 @@ static int manager_setup_timezone_change(Manager *m) {
         return 0;
 }
 
-static int enable_special_signals(Manager *m) {
+static int manager_enable_special_signals(Manager *m) {
         _cleanup_close_ int fd = -EBADF;
 
         assert(m);
 
-        if (MANAGER_IS_TEST_RUN(m))
+        if (!MANAGER_IS_SYSTEM(m) || MANAGER_IS_TEST_RUN(m))
                 return 0;
 
         /* Enable that we get SIGINT on control-alt-del. In containers this will fail with EPERM (older) or
@@ -608,10 +608,7 @@ static int manager_setup_signals(Manager *m) {
         (void) sd_notify(/* unset_environment= */ false,
                          "X_SYSTEMD_SIGNALS_LEVEL=2");
 
-        if (MANAGER_IS_SYSTEM(m))
-                return enable_special_signals(m);
-
-        return 0;
+        return manager_enable_special_signals(m);
 }
 
 static char** sanitize_environment(char **l) {