]> git.sur5r.net Git - openldap/commitdiff
remove password from command line
authorPierangelo Masarati <ando@openldap.org>
Sat, 1 Jul 2006 18:22:43 +0000 (18:22 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 1 Jul 2006 18:22:43 +0000 (18:22 +0000)
tests/progs/slapd-addel.c
tests/progs/slapd-bind.c
tests/progs/slapd-modify.c
tests/progs/slapd-modrdn.c
tests/progs/slapd-read.c
tests/progs/slapd-search.c
tests/progs/slapd-tester.c

index 5414fc8337d8542641c6bb129f65fba9d05c25c7..5e9fd13e31e1d094443de83eb623314748a3b1d9 100644 (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 */
index 7557aa5f120f37e5b1c64e3bd3b18116bd680f05..6bce98bad08305eb7bf1dd2fa52e02eccb431dc7 100644 (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 */
index 04cfef116c68845493721b846cf03cc044b35cf7..cb416d861180984e3df3edaac42d4dcb98a21454 100644 (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 */
index 4bfec6120361d845c40c781fe2bc2230323cb000..f2e7ad82f3f53f4671138836d214ce8a5e86350d 100644 (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 */
index 0863a1b2c943ac503a97b8e7473d4bdb0c7cb083..0de1b109f642f0cf7ec12479a0026663da9de0bf 100644 (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 */
index 945f8c9f2f55bf9bcb8a436c30ae8aa3b1bb2ce4..1b7795cca771821a302a97ae683f7882eafc92b3 100644 (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':
index 350b5f66d1875233f0a55132812bd5e7dc4a8263..fdca62f2044f0cfae33ff3dbea2001e0c157858b 100644 (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 );