From 3c29b695dda3a8b50ec77a115887907f6ee03da2 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 1 Feb 2018 15:37:22 +0100 Subject: su: use errexec() The new macro is fully compatible with original (coreutils) code. Signed-off-by: Karel Zak --- login-utils/su-common.c | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'login-utils') 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 @@ -103,11 +103,6 @@ UL_DEBUG_DEFINE_MASKNAMES(su) = UL_DEBUG_EMPTY_MASKNAMES; extern char **environ; #endif -enum { - EXIT_CANNOT_INVOKE = 126, - EXIT_ENOENT = 127 -}; - enum { SIGTERM_IDX = 0, SIGINT_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 -- cgit v1.2.3-55-g7522