]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
shadow: Fix can not print full login timeout message
authorSoumyaWind <121475834+SoumyaWind@users.noreply.github.com>
Tue, 27 Dec 2022 12:10:17 +0000 (17:40 +0530)
committerSerge Hallyn <serge@hallyn.com>
Fri, 13 Jan 2023 00:30:32 +0000 (18:30 -0600)
Login timed out message prints only first few bytes when write is immediately followed by exit.
Calling exit from new handler provides enough time to display full message.

src/login.c

index 116e2cb3669c7de1b24fd7623c04cfb03f2f079c..c55f4de0a1da2bbc1b401d2c3b2671de58f39381 100644 (file)
@@ -120,6 +120,7 @@ static void get_pam_user (char **ptr_pam_user);
 
 static void init_env (void);
 static void alarm_handler (int);
+static void exit_handler (int);
 
 /*
  * usage - print login command usage and exit
@@ -391,11 +392,16 @@ static void init_env (void)
 #endif                         /* !USE_PAM */
 }
 
+static void exit_handler (unused int sig)
+{
+       _exit (0);
+}
 
 static void alarm_handler (unused int sig)
 {
        write (STDERR_FILENO, tmsg, strlen (tmsg));
-       _exit (0);
+       signal(SIGALRM, exit_handler);
+       alarm(2);
 }
 
 #ifdef USE_PAM