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 54b1e7e167
commit 8e00a61812
3 changed files with 4 additions and 14 deletions

View file

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

View file

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

View file

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