]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
su: move parent signals setup to separate function
authorKarel Zak <kzak@redhat.com>
Thu, 17 Aug 2017 10:01:01 +0000 (12:01 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 18 Sep 2017 09:49:11 +0000 (11:49 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
login-utils/su-common.c

index f4e11dd2d8a293c5618da1a20a0ccfeb473ebe70..ff96a18c51a46abe8be8e3c56b30a9a19616f544 100644 (file)
@@ -371,34 +371,9 @@ static int wait_for_child(struct su_context *su)
        return status;
 }
 
-static void create_watching_parent(struct su_context *su)
+static void parent_setup_signals(struct su_context *su)
 {
        sigset_t ourset;
-       int status;
-
-       DBG(MISC, ul_debug("forking..."));
-
-       switch ((int) (su->child = fork())) {
-       case -1: /* error */
-               supam_cleanup(su, PAM_ABORT);
-               err(EXIT_FAILURE, _("cannot create child process"));
-               break;
-
-       case 0: /* child */
-               return;
-
-       default: /* parent */
-               DBG(MISC, ul_debug("child [pid=%d]", (int) su->child));
-               break;
-       }
-
-
-       /* In the parent watch the child.  */
-
-       /* su without pam support does not have a helper that keeps
-          sitting on any directory so let's go to /.  */
-       if (chdir("/") != 0)
-               warn(_("cannot change directory to %s"), "/");
 
        /*
         * Signals setup
@@ -464,6 +439,38 @@ static void create_watching_parent(struct su_context *su)
                        caught_signal = true;
                }
        }
+}
+
+
+static void create_watching_parent(struct su_context *su)
+{
+       int status;
+
+       DBG(MISC, ul_debug("forking..."));
+
+       switch ((int) (su->child = fork())) {
+       case -1: /* error */
+               supam_cleanup(su, PAM_ABORT);
+               err(EXIT_FAILURE, _("cannot create child process"));
+               break;
+
+       case 0: /* child */
+               return;
+
+       default: /* parent */
+               DBG(MISC, ul_debug("child [pid=%d]", (int) su->child));
+               break;
+       }
+
+
+       /* In the parent watch the child.  */
+
+       /* su without pam support does not have a helper that keeps
+          sitting on any directory so let's go to /.  */
+       if (chdir("/") != 0)
+               warn(_("cannot change directory to %s"), "/");
+
+       parent_setup_signals(su);
 
        /*
         * Wait for child