mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-01-12 10:54:48 +08:00
remove password from command line
This commit is contained in:
parent
a9c7c243c1
commit
b6693c3632
@ -122,6 +122,7 @@ main( int argc, char **argv )
|
||||
case 'w': /* the server managers password */
|
||||
passwd.bv_val = strdup( optarg );
|
||||
passwd.bv_len = strlen( optarg );
|
||||
memset( optarg, '*', passwd.bv_len );
|
||||
break;
|
||||
|
||||
case 'f': /* file with entry search request */
|
||||
|
@ -135,6 +135,7 @@ main( int argc, char **argv )
|
||||
|
||||
case 'w':
|
||||
ber_str2bv( optarg, 0, 0, &pass );
|
||||
memset( optarg, '*', pass.bv_len );
|
||||
break;
|
||||
|
||||
case 'l': /* the number of loops */
|
||||
|
@ -116,6 +116,7 @@ main( int argc, char **argv )
|
||||
case 'w': /* the server managers password */
|
||||
passwd.bv_val = strdup( optarg );
|
||||
passwd.bv_len = strlen( optarg );
|
||||
memset( optarg, '*', passwd.bv_len );
|
||||
break;
|
||||
|
||||
case 'e': /* entry to modify */
|
||||
|
@ -117,6 +117,7 @@ main( int argc, char **argv )
|
||||
case 'w': /* the server managers password */
|
||||
passwd.bv_val = strdup( optarg );
|
||||
passwd.bv_len = strlen( optarg );
|
||||
memset( optarg, '*', passwd.bv_len );
|
||||
break;
|
||||
|
||||
case 'e': /* entry to rename */
|
||||
|
@ -129,6 +129,7 @@ main( int argc, char **argv )
|
||||
case 'w': /* the server managers password */
|
||||
passwd.bv_val = strdup( optarg );
|
||||
passwd.bv_len = strlen( optarg );
|
||||
memset( optarg, '*', passwd.bv_len );
|
||||
break;
|
||||
|
||||
case 'e': /* DN to search for */
|
||||
|
@ -131,6 +131,7 @@ main( int argc, char **argv )
|
||||
case 'w': /* the server managers password */
|
||||
passwd.bv_val = strdup( optarg );
|
||||
passwd.bv_len = strlen( optarg );
|
||||
memset( optarg, '*', passwd.bv_len );
|
||||
break;
|
||||
|
||||
case 'a':
|
||||
|
@ -172,10 +172,12 @@ main( int argc, char **argv )
|
||||
char bloops[] = "18446744073709551615UL";
|
||||
|
||||
char *friendlyOpt = NULL;
|
||||
int pw_ask = 0;
|
||||
char *pw_file = NULL;
|
||||
|
||||
tester_init( "slapd-tester", TESTER_TESTER );
|
||||
|
||||
while ( (i = getopt( argc, argv, "ACD:d:FH:h:i:j:l:L:P:p:r:t:w:" )) != EOF ) {
|
||||
while ( (i = getopt( argc, argv, "ACD:d:FH:h:i:j:l:L:P:p:r:t:w:Wy:" )) != EOF ) {
|
||||
switch( i ) {
|
||||
case 'A':
|
||||
noattrs++;
|
||||
@ -243,6 +245,15 @@ main( int argc, char **argv )
|
||||
|
||||
case 'w': /* the managers passwd */
|
||||
passwd = ArgDup( optarg );
|
||||
memset( optarg, '*', strlen( optarg ) );
|
||||
break;
|
||||
|
||||
case 'W':
|
||||
pw_ask++;
|
||||
break;
|
||||
|
||||
case 'y':
|
||||
pw_file = optarg;
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -260,11 +271,9 @@ main( int argc, char **argv )
|
||||
#endif
|
||||
/* get the file list */
|
||||
if ( ( datadir = opendir( dirname )) == NULL ) {
|
||||
|
||||
fprintf( stderr, "%s: couldn't open data directory \"%s\".\n",
|
||||
argv[0], dirname );
|
||||
exit( EXIT_FAILURE );
|
||||
|
||||
}
|
||||
|
||||
/* look for search, read, modrdn, and add/delete files */
|
||||
@ -294,6 +303,19 @@ main( int argc, char **argv )
|
||||
|
||||
closedir( datadir );
|
||||
|
||||
if ( pw_ask ) {
|
||||
passwd = getpassphrase( _("Enter LDAP Password: ") );
|
||||
|
||||
} else if ( pw_file ) {
|
||||
struct berval pw;
|
||||
|
||||
if ( lutil_get_filed_password( pw_file, &pw ) ) {
|
||||
exit( EXIT_FAILURE );
|
||||
}
|
||||
|
||||
passwd = pw.bv_val;
|
||||
}
|
||||
|
||||
/* look for search requests */
|
||||
if ( sfile ) {
|
||||
snum = get_search_filters( sfile, sreqs, sattrs, sbase );
|
||||
|
Loading…
Reference in New Issue
Block a user