From: Karel Zak Date: Thu, 16 Aug 2018 14:16:40 +0000 (+0200) Subject: sulogin: restore signals after failed exec() only X-Git-Tag: v2.33-rc1~52 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=a8224e8e7e412470e2fe37d5060224ed98bf8284;p=thirdparty%2Futil-linux.git sulogin: restore signals after failed exec() only * removes unnecessary variable * the current code restores signals always when shell has not been executed -- this is correct as function sushell() modify signal mask, but in all another cases we do not need touch the mask. Especially when we ask for the password in endless while() loop... Signed-off-by: Karel Zak --- diff --git a/login-utils/sulogin.c b/login-utils/sulogin.c index 78a01f4328..5f09bd48e4 100644 --- a/login-utils/sulogin.c +++ b/login-utils/sulogin.c @@ -976,7 +976,7 @@ int main(int argc, char **argv) while (1) { const char *passwd = pwd->pw_passwd; const char *answer; - int failed = 0, doshell = 0; + int doshell = 0; int deny = !opt_e && locked_account_password(pwd->pw_passwd); doprompt(passwd, con, deny); @@ -999,15 +999,13 @@ int main(int argc, char **argv) } if (doshell) { + /* sushell() unmask signals */ sushell(pwd); - failed++; - } - mask_signal(SIGQUIT, SIG_IGN, &saved_sigquit); - mask_signal(SIGTSTP, SIG_IGN, &saved_sigtstp); - mask_signal(SIGINT, SIG_IGN, &saved_sigint); + mask_signal(SIGQUIT, SIG_IGN, &saved_sigquit); + mask_signal(SIGTSTP, SIG_IGN, &saved_sigtstp); + mask_signal(SIGINT, SIG_IGN, &saved_sigint); - if (failed) { fprintf(stderr, _("cannot execute su shell\n\n")); break; }