remove password from command line

This commit is contained in:
Pierangelo Masarati 2006-07-01 18:22:43 +00:00
parent a9c7c243c1
commit b6693c3632
7 changed files with 31 additions and 3 deletions

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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 */

View File

@ -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':

View File

@ -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 );