]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
sulogin: restore signals after failed exec() only
authorKarel Zak <kzak@redhat.com>
Thu, 16 Aug 2018 14:16:40 +0000 (16:16 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 16 Aug 2018 14:16:40 +0000 (16:16 +0200)
* 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 <kzak@redhat.com>
login-utils/sulogin.c

index 78a01f4328ff975b3f15f0ca435eeb0978f3f805..5f09bd48e4ab9ddc8b7ab7deb703f25d24a3bd89 100644 (file)
@@ -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;
                                }