mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-04-18 15:20:35 +08:00
Use getpassphrase() instead of getpass() if available.
This commit is contained in:
parent
72db2b73dc
commit
8045b54124
@ -318,7 +318,7 @@ main( int argc, char **argv )
|
||||
}
|
||||
|
||||
if (want_bindpw)
|
||||
passwd.bv_val = getpass("Enter LDAP Password: ");
|
||||
passwd.bv_val = getpassphrase("Enter LDAP Password: ");
|
||||
passwd.bv_len = strlen( passwd.bv_val );
|
||||
|
||||
if ( authmethod == LDAP_AUTH_SASL ) {
|
||||
|
@ -382,7 +382,7 @@ main( int argc, char **argv )
|
||||
}
|
||||
|
||||
if (want_bindpw)
|
||||
passwd.bv_val = getpass("Enter LDAP Password: ");
|
||||
passwd.bv_val = getpassphrase("Enter LDAP Password: ");
|
||||
passwd.bv_len = strlen( passwd.bv_val );
|
||||
|
||||
if ( authmethod == LDAP_AUTH_SASL ) {
|
||||
|
@ -365,7 +365,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
if (want_bindpw)
|
||||
passwd.bv_val = getpass("Enter LDAP Password: ");
|
||||
passwd.bv_val = getpassphrase("Enter LDAP Password: ");
|
||||
passwd.bv_len = strlen( passwd.bv_val );
|
||||
|
||||
if ( authmethod == LDAP_AUTH_SASL ) {
|
||||
|
@ -246,8 +246,8 @@ main( int argc, char *argv[] )
|
||||
if( want_oldpw && oldpw == NULL ) {
|
||||
/* prompt for old password */
|
||||
char *ckoldpw;
|
||||
newpw = strdup(getpass("Old password: "));
|
||||
ckoldpw = getpass("Re-enter old password: ");
|
||||
newpw = strdup(getpassphrase("Old password: "));
|
||||
ckoldpw = getpassphrase("Re-enter old password: ");
|
||||
|
||||
if( strncmp( oldpw, ckoldpw, strlen(oldpw) )) {
|
||||
fprintf( stderr, "passwords do not match\n" );
|
||||
@ -258,8 +258,8 @@ main( int argc, char *argv[] )
|
||||
if( want_newpw && newpw == NULL ) {
|
||||
/* prompt for new password */
|
||||
char *cknewpw;
|
||||
newpw = strdup(getpass("New password: "));
|
||||
cknewpw = getpass("Re-enter new password: ");
|
||||
newpw = strdup(getpassphrase("New password: "));
|
||||
cknewpw = getpassphrase("Re-enter new password: ");
|
||||
|
||||
if( strncmp( newpw, cknewpw, strlen(newpw) )) {
|
||||
fprintf( stderr, "passwords do not match\n" );
|
||||
@ -280,7 +280,7 @@ main( int argc, char *argv[] )
|
||||
if (want_bindpw && passwd.bv_val == NULL ) {
|
||||
/* handle bind password */
|
||||
fprintf( stderr, "Bind DN: %s\n", binddn );
|
||||
passwd.bv_val = strdup( getpass("Enter bind password: "));
|
||||
passwd.bv_val = strdup( getpassphrase("Enter bind password: "));
|
||||
passwd.bv_len = strlen( passwd.bv_val );
|
||||
}
|
||||
|
||||
|
@ -521,7 +521,7 @@ main( int argc, char **argv )
|
||||
}
|
||||
|
||||
if (want_bindpw) {
|
||||
passwd.bv_val = getpass("Enter LDAP Password: ");
|
||||
passwd.bv_val = getpassphrase("Enter LDAP Password: ");
|
||||
passwd.bv_len = strlen( passwd.bv_val );
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ int
|
||||
auth( char *who, int implicit )
|
||||
{
|
||||
int rc; /* return code from ldap_bind() */
|
||||
char *passwd = NULL; /* returned by getpass() */
|
||||
char *passwd = NULL; /* returned by getpassphrase() */
|
||||
char **rdns; /* for fiddling with the DN */
|
||||
int authmethod;
|
||||
int name_provided; /* was a name passed in? */
|
||||
@ -241,7 +241,7 @@ auth( char *who, int implicit )
|
||||
authmethod = LDAP_AUTH_SIMPLE;
|
||||
sprintf(prompt, " Enter your LDAP password: ");
|
||||
do {
|
||||
passwd = getpass(prompt);
|
||||
passwd = getpassphrase(prompt);
|
||||
} while (passwd != NULL && *passwd == '\0');
|
||||
if (passwd == NULL) {
|
||||
(void) ldap_value_free(rdns);
|
||||
@ -352,7 +352,7 @@ krbgetpass( char *user, char *inst, char *realm, char *pw, C_Block key )
|
||||
sprintf(prompt, " Enter Kerberos password for %s: ", kauth_name );
|
||||
#endif
|
||||
do {
|
||||
passwd = getpass(prompt);
|
||||
passwd = getpassphrase(prompt);
|
||||
} while (passwd != NULL && *passwd == '\0');
|
||||
if (passwd == NULL) {
|
||||
return(-1);
|
||||
|
25
configure
vendored
25
configure
vendored
@ -15539,6 +15539,7 @@ for ac_func in \
|
||||
getgrgid \
|
||||
gethostname \
|
||||
getpass \
|
||||
getpassphrase \
|
||||
getpwuid \
|
||||
getpwnam \
|
||||
getspnam \
|
||||
@ -15580,12 +15581,12 @@ for ac_func in \
|
||||
|
||||
do
|
||||
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
|
||||
echo "configure:15584: checking for $ac_func" >&5
|
||||
echo "configure:15585: checking for $ac_func" >&5
|
||||
if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 15589 "configure"
|
||||
#line 15590 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char $ac_func(); below. */
|
||||
@ -15609,7 +15610,7 @@ f = $ac_func;
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:15613: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:15614: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func_$ac_func=yes"
|
||||
else
|
||||
@ -15637,12 +15638,12 @@ done
|
||||
for ac_func in getopt tempnam
|
||||
do
|
||||
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
|
||||
echo "configure:15641: checking for $ac_func" >&5
|
||||
echo "configure:15642: checking for $ac_func" >&5
|
||||
if eval "test \"\${ac_cv_func_$ac_func+set}\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 15646 "configure"
|
||||
#line 15647 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char $ac_func(); below. */
|
||||
@ -15666,7 +15667,7 @@ f = $ac_func;
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:15670: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:15671: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func_$ac_func=yes"
|
||||
else
|
||||
@ -15703,13 +15704,13 @@ fi
|
||||
|
||||
# Check Configuration
|
||||
echo $ac_n "checking declaration of sys_errlist""... $ac_c" 1>&6
|
||||
echo "configure:15707: checking declaration of sys_errlist" >&5
|
||||
echo "configure:15708: checking declaration of sys_errlist" >&5
|
||||
if eval "test \"\${ol_cv_dcl_sys_errlist+set}\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 15713 "configure"
|
||||
#line 15714 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
#include <stdio.h>
|
||||
@ -15722,7 +15723,7 @@ int main() {
|
||||
char *c = (char *) *sys_errlist
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:15726: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:15727: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ol_cv_dcl_sys_errlist=yes
|
||||
ol_cv_have_sys_errlist=yes
|
||||
@ -15745,20 +15746,20 @@ EOF
|
||||
|
||||
|
||||
echo $ac_n "checking existence of sys_errlist""... $ac_c" 1>&6
|
||||
echo "configure:15749: checking existence of sys_errlist" >&5
|
||||
echo "configure:15750: checking existence of sys_errlist" >&5
|
||||
if eval "test \"\${ol_cv_have_sys_errlist+set}\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 15755 "configure"
|
||||
#line 15756 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <errno.h>
|
||||
int main() {
|
||||
char *c = (char *) *sys_errlist
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:15762: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:15763: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
ol_cv_have_sys_errlist=yes
|
||||
else
|
||||
|
@ -2138,6 +2138,7 @@ AC_CHECK_FUNCS( \
|
||||
getgrgid \
|
||||
gethostname \
|
||||
getpass \
|
||||
getpassphrase \
|
||||
getpwuid \
|
||||
getpwnam \
|
||||
getspnam \
|
||||
|
@ -27,10 +27,17 @@
|
||||
|
||||
/* note: callers of crypt(3) should include <ac/crypt.h> */
|
||||
|
||||
#ifndef HAVE_GETPASS
|
||||
LIBLUTIL_F(char*)(getpass) LDAP_P((const char *getpass));
|
||||
#else
|
||||
#if defined(HAVE_GETPASSPHRASE)
|
||||
LIBC_F(char*)(getpassphrase)();
|
||||
|
||||
#elif defined(HAVE_GETPASS)
|
||||
#define getpassphrase(p) getpass(p)
|
||||
LIBC_F(char*)(getpass)();
|
||||
|
||||
#else
|
||||
#define NEED_GETPASSPHRASE 1
|
||||
#define getpassphrase(p) lutil_getpass(p)
|
||||
LIBLUTIL_F(char*)(lutil_getpass) LDAP_P((const char *getpass));
|
||||
#endif
|
||||
|
||||
/* getopt() defines may be in separate include file */
|
||||
|
@ -166,6 +166,9 @@
|
||||
/* Define if you have the getpass function. */
|
||||
#undef HAVE_GETPASS
|
||||
|
||||
/* Define if you have the getpassphrase function. */
|
||||
#undef HAVE_GETPASSPHRASE
|
||||
|
||||
/* Define if you have the getpwnam function. */
|
||||
#undef HAVE_GETPWNAM
|
||||
|
||||
|
@ -17,8 +17,6 @@
|
||||
|
||||
#include "portable.h"
|
||||
|
||||
#ifndef HAVE_GETPASS
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <ac/stdlib.h>
|
||||
@ -30,6 +28,8 @@
|
||||
#include <ac/time.h>
|
||||
#include <ac/unistd.h>
|
||||
|
||||
#ifdef NEED_GETPASSPHRASE
|
||||
|
||||
#ifdef HAVE_FCNTL_H
|
||||
#include <fcntl.h>
|
||||
#endif
|
||||
@ -44,16 +44,19 @@
|
||||
#include "ldap_defaults.h"
|
||||
|
||||
char *
|
||||
getpass( const char *prompt )
|
||||
lutil_getpass( const char *prompt )
|
||||
{
|
||||
#if !defined(HAVE_POSIX_TERMIOS) && !defined(HAVE_SGTTY_H)
|
||||
static char buf[256];
|
||||
int i, c;
|
||||
|
||||
if( prompt == NULL ) prompt = "Password: ";
|
||||
|
||||
#ifdef DEBUG
|
||||
if (debug & D_TRACE)
|
||||
printf("->getpass(%s)\n", prompt);
|
||||
#endif
|
||||
|
||||
printf("%s", prompt);
|
||||
i = 0;
|
||||
while ( (c = getch()) != EOF && c != '\n' && c != '\r' )
|
||||
@ -73,6 +76,8 @@ getpass( const char *prompt )
|
||||
FILE *fi;
|
||||
RETSIGTYPE (*sig)( int sig );
|
||||
|
||||
if( prompt == NULL ) prompt = "Password: ";
|
||||
|
||||
#ifdef DEBUG
|
||||
if (debug & D_TRACE)
|
||||
printf("->getpass(%s)\n", prompt);
|
||||
@ -155,4 +160,4 @@ getpass( const char *prompt )
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* !HAVE_GETPASS */
|
||||
#endif /* !NEED_GETPASSPHRASE */
|
||||
|
Loading…
x
Reference in New Issue
Block a user