Replace the deprecated getpass(3) by our agetpass()

getpass(3) is broken in all implementations; in some, more than
others, but somewhat broken in all of them.  Check the immediate
previous commit, which added the functions, for more details.
Check also the Linux man-pages commit that marked it as
deprecated, for more details:
7ca189099d73bde954eed2d7fc21732bcc8ddc6b.

Link: <https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit?id=7ca189099d73bde954eed2d7fc21732bcc8ddc6b>
Reported-by: Christian Göttsche <cgzones@googlemail.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
This commit is contained in:
Alejandro Colomar
2022-09-27 21:21:35 +02:00
committed by Iker Pedrosa
parent 155c9421b9
commit 554f86bafa
4 changed files with 21 additions and 18 deletions

View File

@@ -182,7 +182,7 @@ static void catch_signals (unused int sig)
*/
/* get a password for root */
cp = getpass (_(
cp = agetpass (_(
"\n"
"Type control-d to proceed with normal startup,\n"
"(or give root password for system maintenance):"));
@@ -193,6 +193,7 @@ static void catch_signals (unused int sig)
* --marekm
*/
if ((NULL == cp) || ('\0' == *cp)) {
erase_pass (cp);
#ifdef USE_SYSLOG
SYSLOG (LOG_INFO, "Normal startup\n");
closelog ();
@@ -204,7 +205,8 @@ static void catch_signals (unused int sig)
exit (0);
}
STRFCPY (pass, cp);
strzero (cp);
erase_pass (cp);
if (valid (pass, &pwent)) { /* check encrypted passwords ... */
break; /* ... encrypted passwords matched */
}