зеркало из https://github.com/mozilla/pjs.git
Fix bug 281140 - patch submitted by ulf@loop.to
The getpass() function on HP-UX only allows 8 characters. Since there is not (yet?) a better function, this fix allows up to 256 character passwords using the raw tty interfaces for no echo.
This commit is contained in:
Родитель
8455c603db
Коммит
ca8dac8b85
|
@ -51,6 +51,10 @@
|
|||
#include <stdlib.h>
|
||||
#include <time.h> /* for time() and ctime() */
|
||||
|
||||
#if defined(HPUX)
|
||||
#include <sys/termios.h> /* for tcgetattr and tcsetattr */
|
||||
#endif /* HPUX */
|
||||
|
||||
static LDAP_REBINDPROC_CALLBACK get_rebind_credentials;
|
||||
static void print_library_info( const LDAPAPIInfo *aip, FILE *fp );
|
||||
static int wait4result( LDAP *ld, int msgid, struct berval **servercredp,
|
||||
|
@ -689,10 +693,48 @@ ldaptool_process_args( int argc, char **argv, char *extra_opts,
|
|||
#if defined(SOLARIS)
|
||||
/* 256 characters on Solaris */
|
||||
passwd = getpassphrase(password_string);
|
||||
#else
|
||||
#if defined(HPUX)
|
||||
/* HP-UX has deprecated their password asking function, so we have
|
||||
* to resort to doing it the hard way . . . */
|
||||
char pbuf[257];
|
||||
struct termios termstat;
|
||||
tcflag_t savestat;
|
||||
|
||||
fputs(password_string, stdout);
|
||||
fflush(stdout);
|
||||
|
||||
if(tcgetattr(fileno(stdin), &termstat) < 0) {
|
||||
perror( "tcgetattr" );
|
||||
exit( LDAP_LOCAL_ERROR );
|
||||
}
|
||||
savestat = termstat.c_lflag;
|
||||
termstat.c_lflag &= ~(ECHO | ECHOE | ECHOK);
|
||||
termstat.c_lflag |= (ICANON | ECHONL);
|
||||
if(tcsetattr(fileno(stdin), TCSANOW, &termstat) < 0) {
|
||||
perror( "tcgetattr" );
|
||||
exit( LDAP_LOCAL_ERROR );
|
||||
}
|
||||
if (fgets(pbuf,256,stdin) == NULL) {
|
||||
passwd = NULL;
|
||||
} else {
|
||||
char *tmp;
|
||||
passwd = NULL;
|
||||
tmp = strchr(pbuf,'\n');
|
||||
if (tmp)
|
||||
*tmp = '\0';
|
||||
passwd = strdup(pbuf);
|
||||
}
|
||||
termstat.c_lflag = savestat;
|
||||
if(tcsetattr(fileno(stdin), TCSANOW, &termstat) < 0) {
|
||||
perror( "tcgetattr" );
|
||||
exit( LDAP_LOCAL_ERROR );
|
||||
}
|
||||
#else
|
||||
/* limited to 16 chars on Tru64, 32 on AIX */
|
||||
passwd = getpass(password_string);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
} else if (password_fp != NULL) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче