mirror of
https://github.com/rfc1036/whois.git
synced 2026-05-03 06:51:09 +00:00
mkpasswd: use readpassphrase(3) if available
This commit is contained in:
parent
b64054961d
commit
6e74da05d1
6
config.h
6
config.h
@ -26,12 +26,17 @@
|
|||||||
/* which versions? */
|
/* which versions? */
|
||||||
# define HAVE_GETOPT_LONG
|
# define HAVE_GETOPT_LONG
|
||||||
# define HAVE_GETADDRINFO
|
# define HAVE_GETADDRINFO
|
||||||
|
# define HAVE_READPASSPHRASE
|
||||||
# define ENABLE_NLS
|
# define ENABLE_NLS
|
||||||
# ifndef LOCALEDIR
|
# ifndef LOCALEDIR
|
||||||
# define LOCALEDIR "/usr/local/share/locale"
|
# define LOCALEDIR "/usr/local/share/locale"
|
||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined OpenBSD
|
||||||
|
# define HAVE_READPASSPHRASE
|
||||||
|
#endif
|
||||||
|
|
||||||
/* needs unistd.h */
|
/* needs unistd.h */
|
||||||
#if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 200112L
|
#if defined _POSIX_C_SOURCE && _POSIX_C_SOURCE >= 200112L
|
||||||
# define HAVE_GETADDRINFO
|
# define HAVE_GETADDRINFO
|
||||||
@ -41,6 +46,7 @@
|
|||||||
#if defined __APPLE__ && defined __MACH__
|
#if defined __APPLE__ && defined __MACH__
|
||||||
# define HAVE_GETOPT_LONG
|
# define HAVE_GETOPT_LONG
|
||||||
# define HAVE_GETADDRINFO
|
# define HAVE_GETADDRINFO
|
||||||
|
# define HAVE_READPASSPHRASE
|
||||||
# define HAVE_BSDICRYPT
|
# define HAVE_BSDICRYPT
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
13
mkpasswd.c
13
mkpasswd.c
@ -47,6 +47,9 @@
|
|||||||
#ifdef HAVE_GETTIMEOFDAY
|
#ifdef HAVE_GETTIMEOFDAY
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef HAVE_READPASSPHRASE
|
||||||
|
#include <readpassphrase.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/* Application-specific */
|
/* Application-specific */
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
@ -387,11 +390,21 @@ int main(int argc, char *argv[])
|
|||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
#ifdef HAVE_READPASSPHRASE
|
||||||
|
const size_t size = 128;
|
||||||
|
|
||||||
|
password = NOFAIL(malloc(size));
|
||||||
|
if (!readpassphrase(_("Password: "), password, size, 0)) {
|
||||||
|
perror("readpassphrase");
|
||||||
|
exit(2);
|
||||||
|
}
|
||||||
|
#else
|
||||||
password = getpass(_("Password: "));
|
password = getpass(_("Password: "));
|
||||||
if (!password) {
|
if (!password) {
|
||||||
perror("getpass");
|
perror("getpass");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user