From b6693c36324f0a8439b466898128af45e4541c8d Mon Sep 17 00:00:00 2001 From: Pierangelo Masarati Date: Sat, 1 Jul 2006 18:22:43 +0000 Subject: [PATCH] remove password from command line --- tests/progs/slapd-addel.c | 1 + tests/progs/slapd-bind.c | 1 + tests/progs/slapd-modify.c | 1 + tests/progs/slapd-modrdn.c | 1 + tests/progs/slapd-read.c | 1 + tests/progs/slapd-search.c | 1 + tests/progs/slapd-tester.c | 28 +++++++++++++++++++++++++--- 7 files changed, 31 insertions(+), 3 deletions(-) diff --git a/tests/progs/slapd-addel.c b/tests/progs/slapd-addel.c index 5414fc8337..5e9fd13e31 100644 --- a/tests/progs/slapd-addel.c +++ b/tests/progs/slapd-addel.c @@ -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 */ diff --git a/tests/progs/slapd-bind.c b/tests/progs/slapd-bind.c index 7557aa5f12..6bce98bad0 100644 --- a/tests/progs/slapd-bind.c +++ b/tests/progs/slapd-bind.c @@ -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 */ diff --git a/tests/progs/slapd-modify.c b/tests/progs/slapd-modify.c index 04cfef116c..cb416d8611 100644 --- a/tests/progs/slapd-modify.c +++ b/tests/progs/slapd-modify.c @@ -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 */ diff --git a/tests/progs/slapd-modrdn.c b/tests/progs/slapd-modrdn.c index 4bfec61203..f2e7ad82f3 100644 --- a/tests/progs/slapd-modrdn.c +++ b/tests/progs/slapd-modrdn.c @@ -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 */ diff --git a/tests/progs/slapd-read.c b/tests/progs/slapd-read.c index 0863a1b2c9..0de1b109f6 100644 --- a/tests/progs/slapd-read.c +++ b/tests/progs/slapd-read.c @@ -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 */ diff --git a/tests/progs/slapd-search.c b/tests/progs/slapd-search.c index 945f8c9f2f..1b7795cca7 100644 --- a/tests/progs/slapd-search.c +++ b/tests/progs/slapd-search.c @@ -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': diff --git a/tests/progs/slapd-tester.c b/tests/progs/slapd-tester.c index 350b5f66d1..fdca62f204 100644 --- a/tests/progs/slapd-tester.c +++ b/tests/progs/slapd-tester.c @@ -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 ); -- 2.39.5