diff options
author | Karel Zak | 2016-11-09 14:19:22 +0100 |
---|---|---|
committer | Karel Zak | 2017-09-18 11:48:56 +0200 |
commit | c34865b96df98c1f39eeca10134f01287aa235a3 (patch) | |
tree | 9395da6125830aa6b3a38fe495a6317f04c88e4a /login-utils/su-common.c | |
parent | su: move PAM session initialization to separate function (diff) | |
download | kernel-qcow2-util-linux-c34865b96df98c1f39eeca10134f01287aa235a3.tar.gz kernel-qcow2-util-linux-c34865b96df98c1f39eeca10134f01287aa235a3.tar.xz kernel-qcow2-util-linux-c34865b96df98c1f39eeca10134f01287aa235a3.zip |
su: use switch() to split after fork
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'login-utils/su-common.c')
-rw-r--r-- | login-utils/su-common.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/login-utils/su-common.c b/login-utils/su-common.c index e004e22cf..b153909c8 100644 --- a/login-utils/su-common.c +++ b/login-utils/su-common.c @@ -288,18 +288,22 @@ static void create_watching_parent(struct su_context *su) struct sigaction oldact[3]; int status = 0; - memset(oldact, 0, sizeof(oldact)); - - child = fork(); - if (child == (pid_t) - 1) { + switch ((int) (child = fork())) { + case -1: /* error */ supam_cleanup(su, PAM_ABORT); err(EXIT_FAILURE, _("cannot create child process")); - } + break; - /* the child proceeds to run the shell */ - if (child == 0) + case 0: /* child */ return; + default: /* parent */ + break; + } + + memset(oldact, 0, sizeof(oldact)); + + /* In the parent watch the child. */ /* su without pam support does not have a helper that keeps |