Make the configure script test for the availability of readpassphrase() in the

C library or libbsd, and use it if is available since it is far more robust 
than getpass().


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/ec/trunk@39104 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Niels Grewe 2015-10-28 20:08:04 +00:00
parent 6e37e343b0
commit 6c7e7055b9
6 changed files with 428 additions and 339 deletions

View file

@ -1,3 +1,13 @@
2015-10-28 Niels Grewe <niels.grewe@halbordnung.de>
* EcConsole.m: Use readpassphrase() instead of getpass() if available.
* configure.ac
* config.make.in:
Test for readpassphrase in the C library and libbsd, link if needed.
* configure:
* config.h.in:
Regenerate
2015-10-15 Richard Frith-Macdonald <rfm@gnu.org>
* EcTest.h:

View file

@ -42,6 +42,11 @@
# include <readline/history.h>
#endif
#if defined(HAVE_READPASSPHRASE_H)
# include <readpassphrase.h>
#elif defined(HAVE_BSD_READPASSPHRASE_H)
# include <bsd/readpassphrase.h>
#endif
static BOOL commandIsRepeat (NSString *string)
{
switch ([string length])
@ -1067,7 +1072,7 @@ consoleCompleter(const char *text, int start, int end)
{
[self cmdQuit: 0];
}
#ifndef HAVE_READPASSPHRASE
/* read password (glibc documentation says not to use getpass?) */
line = getpass("Password: ");
@ -1076,6 +1081,14 @@ consoleCompleter(const char *text, int start, int end)
NSLog(@"Could not read password: %s", strerror(errno));
exit(1);
}
#else
line = readpassphrase("Password: ", &buf[0], 128, RPP_ECHO_OFF);
if (NULL == line)
{
NSLog(@"Could not read password");
exit(1);
}
#endif
p = [[NSString stringWithCString: line] stringByTrimmingSpaces];
if ([p caseInsensitiveCompare: @"quit"] == NSOrderedSame)
{

View file

@ -10,6 +10,9 @@
/* Define to 1 if you have the <arpa/telnet.h> header file. */
#undef HAVE_ARPA_TELNET_H
/* Define to 1 if you have the <bsd/readpassphrase.h> header file. */
#undef HAVE_BSD_READPASSPHRASE_H
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
@ -43,6 +46,12 @@
/* Define to 1 if you have the <pwd.h> header file. */
#undef HAVE_PWD_H
/* Define to 1 if you have the `readpassphrase' function. */
#undef HAVE_READPASSPHRASE
/* Define to 1 if you have the <readpassphrase.h> header file. */
#undef HAVE_READPASSPHRASE_H
/* Define to 1 if you have the `setpgid' function. */
#undef HAVE_SETPGID

View file

@ -1,7 +1,7 @@
WITH_NET_SNMP=@WITH_NET_SNMP@
Console_TOOL_LIBS += @LIBREADLINE@
Console_TOOL_LIBS += @LIBREADLINE@ @READPASSPHRASE_LIBS@
ECCL_LIBS=@LIBS@

719
configure vendored

File diff suppressed because it is too large Load diff

View file

@ -79,6 +79,18 @@ if test $enable_net_snmp = "yes"; then
fi
AC_SUBST(WITH_NET_SNMP)
AC_CHECK_HEADERS(readpassphrase.h bsd/readpassphrase.h)
oldlibs=$LIBS
AC_SEARCH_LIBS(readpassphrase, bsd)
AC_CHECK_FUNCS(readpassphrase)
if test "x$ac_cv_search_readpassphrase" != "xno";
then
if test "x$ac_cv_search_readpassphrase" != "xnone needed" ;
then
AC_SUBST([READPASSPHRASE_LIBS], ["$ac_cv_search_readpassphrase"])
fi
fi
LIBS=$oldlibs
AC_OUTPUT(config.make)