summaryrefslogtreecommitdiffstats
path: root/login-utils/su-common.c
diff options
context:
space:
mode:
authorKarel Zak2018-02-01 15:37:22 +0100
committerKarel Zak2018-02-01 15:37:22 +0100
commit3c29b695dda3a8b50ec77a115887907f6ee03da2 (patch)
tree915b09f4be68d6a2cd449323019635e7113693fd /login-utils/su-common.c
parentinclude/c: add errexec() (diff)
downloadkernel-qcow2-util-linux-3c29b695dda3a8b50ec77a115887907f6ee03da2.tar.gz
kernel-qcow2-util-linux-3c29b695dda3a8b50ec77a115887907f6ee03da2.tar.xz
kernel-qcow2-util-linux-3c29b695dda3a8b50ec77a115887907f6ee03da2.zip
su: use errexec()
The new macro is fully compatible with original (coreutils) code. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'login-utils/su-common.c')
-rw-r--r--login-utils/su-common.c10
1 files changed, 1 insertions, 9 deletions
diff --git a/login-utils/su-common.c b/login-utils/su-common.c
index 32cdd1954..afd75a1f1 100644
--- a/login-utils/su-common.c
+++ b/login-utils/su-common.c
@@ -104,11 +104,6 @@ extern char **environ;
#endif
enum {
- EXIT_CANNOT_INVOKE = 126,
- EXIT_ENOENT = 127
-};
-
-enum {
SIGTERM_IDX = 0,
SIGINT_IDX,
SIGQUIT_IDX,
@@ -1041,7 +1036,6 @@ static void run_shell(
size_t n_args = 1 + su->fast_startup + 2 * ! !command + n_additional_args + 1;
const char **args = xcalloc(n_args, sizeof *args);
size_t argno = 1;
- int rc;
DBG(MISC, ul_debug("starting shell [shell=%s, command=\"%s\"%s%s]",
shell, command,
@@ -1070,9 +1064,7 @@ static void run_shell(
memcpy(args + argno, additional_args, n_additional_args * sizeof *args);
args[argno + n_additional_args] = NULL;
execv(shell, (char **)args);
-
- rc = errno == ENOENT ? EXIT_ENOENT : EXIT_CANNOT_INVOKE;
- err(rc, _("failed to execute %s"), shell);
+ errexec(shell);
}
/* Return true if SHELL is a restricted shell (one not returned by