client: Drop use of getpass()

getpass() is traditional Unix, but has been withdrawn from POSIX.  We
still use it when it's available, and fall back to portable code only
when it's not.

The portable code behaves differently: it reads stdin instead of
/dev/tty, and in noncanonical mode.

Simplify things: always use the replacement.

Signed-off-by: Markus Armbruster <armbru@pond.sub.org>
This commit is contained in:
Markus Armbruster 2020-12-27 11:57:54 +01:00
parent 53b2271d1d
commit ab93877534
3 changed files with 4 additions and 14 deletions

View file

@ -27,7 +27,7 @@
# configure.ac: Autoconf input file
#
# Known contributors to this file:
# Markus Armbruster, 2005-2016
# Markus Armbruster, 2005-2020
#
# Process this file with autoconf to produce a configure script.
@ -167,7 +167,7 @@ main(int argc, char *argv[])
### Checks for library functions
AC_CHECK_FUNCS(getaddrinfo getpass)
AC_CHECK_FUNCS(getaddrinfo)
MY_FUNC_MAKECONTEXT

View file

@ -27,7 +27,7 @@
# configure.ac: Autoconf input file
#
# Known contributors to this file:
# Markus Armbruster, 2005-2016
# Markus Armbruster, 2005-2020
#
# Process this file with autoconf to produce a configure script.
@ -76,7 +76,7 @@ fi
### Checks for library functions.
AC_CHECK_FUNCS(getaddrinfo getpass)
AC_CHECK_FUNCS(getaddrinfo)
### Site configuration

View file

@ -32,19 +32,14 @@
#include <config.h>
#ifdef HAVE_GETPASS
#include <unistd.h>
#else
#include <string.h>
#ifdef _WIN32
#include <windows.h>
#else
#include <termios.h>
#endif
#endif
#include "misc.h"
#ifndef HAVE_GETPASS
static int
set_echo_if_tty(int on)
{
@ -79,14 +74,10 @@ set_echo_if_tty(int on)
return 1;
#endif
}
#endif /* !HAVE_GETPASS */
char *
get_password(const char *prompt)
{
#ifdef HAVE_GETPASS
return getpass(prompt);
#else
static char buf[128];
char *p;
size_t len;
@ -109,5 +100,4 @@ get_password(const char *prompt)
if (p[len - 1] == '\n')
p[len - 1] = 0;
return p;
#endif /* !HAVE_GETPASS */
}