]> git.ipfire.org Git - thirdparty/openldap.git/commitdiff
Import password prompting from -devel.
authorKurt Zeilenga <kurt@openldap.org>
Wed, 20 Jan 1999 00:50:56 +0000 (00:50 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Wed, 20 Jan 1999 00:50:56 +0000 (00:50 +0000)
CHANGES
clients/tools/ldapdelete.c
clients/tools/ldapmodify.c
clients/tools/ldapmodrdn.c
clients/tools/ldapsearch.c

diff --git a/CHANGES b/CHANGES
index a987e4c2665e227352443c12094892e7de1e61bd..2943800d8b56dddc8779074be0641cb420d49cbb 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -3,6 +3,8 @@ OpenLDAP Change Log
 Changes included in OpenLDAP 1.2
        CVS Tag: OPENLDAP_REL_ENG_1_2
        Add ldappasswd() tool
+       Add client/tools password prompting
+       Update client/tools Kerberos option handling
 
 Changes included in OpenLDAP 1.1.3
        CVS Tag: OPENLDAP_REL_ENG_1_1_3
index 9ac662fd123c751516d798dc254bad0e28234591..a9ca7f6b0ce061bb89346243250cae29823770a9 100644 (file)
@@ -33,16 +33,16 @@ static int dodelete LDAP_P((
 int
 main( int argc, char **argv )
 {
-    char               *usage = "usage: %s [-n] [-v] [-k] [-d debug-level] [-f file] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [dn]...\n";
+    char               *usage = "usage: %s [-n] [-v] [-k] [-W] [-d debug-level] [-f file] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [dn]...\n";
     char               buf[ 4096 ];
     FILE               *fp;
-    int                        i, rc, authmethod;
+    int                        i, rc, authmethod, want_bindpw;
 
-    not = verbose = contoper = 0;
+    not = verbose = contoper = want_bindpw = 0;
     fp = NULL;
     authmethod = LDAP_AUTH_SIMPLE;
 
-    while (( i = getopt( argc, argv, "nvkKch:p:D:w:d:f:" )) != EOF ) {
+    while (( i = getopt( argc, argv, "WnvkKch:p:D:w:d:f:" )) != EOF ) {
        switch( i ) {
        case 'k':       /* kerberos bind */
 #ifdef HAVE_KERBEROS
@@ -92,6 +92,9 @@ main( int argc, char **argv )
        case 'v':       /* verbose mode */
            verbose++;
            break;
+       case 'W':
+               want_bindpw++;
+               break;
        default:
            fprintf( stderr, usage, argv[0] );
            exit( 1 );
@@ -111,6 +114,9 @@ main( int argc, char **argv )
 
     ld->ld_deref = LDAP_DEREF_NEVER;   /* prudent, but probably unnecessary */
 
+       if (want_bindpw)
+               passwd = getpass("Enter LDAP Password: ");
+
     if ( ldap_bind_s( ld, binddn, passwd, authmethod ) != LDAP_SUCCESS ) {
        ldap_perror( ld, "ldap_bind" );
        exit( 1 );
index 2b3074ccd8038616cb4e6d78654060cfae1a552a..02280642a6f8098ae577db32bdc1418eebb6eed2 100644 (file)
@@ -71,8 +71,8 @@ main( int argc, char **argv )
 {
     char               *infile, *rbuf, *start, *p, *q;
     FILE               *fp;
-    int                        rc, i, use_ldif, authmethod;
-    char               *usage = "usage: %s [-abcknrvF] [-d debug-level] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [ -f file | < entryfile ]\n";
+    int                        rc, i, use_ldif, authmethod, want_bindpw;
+    char               *usage = "usage: %s [-abcknrvWF] [-d debug-level] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [ -f file | < entryfile ]\n";
 
     if (( prog = strrchr( argv[ 0 ], '/' )) == NULL ) {
        prog = argv[ 0 ];
@@ -82,10 +82,10 @@ main( int argc, char **argv )
     new = ( strcmp( prog, "ldapadd" ) == 0 );
 
     infile = NULL;
-    not = verbose = valsfromfiles = 0;
+    not = verbose = valsfromfiles = want_bindpw = 0;
     authmethod = LDAP_AUTH_SIMPLE;
 
-    while (( i = getopt( argc, argv, "FabckKnrtvh:p:D:w:d:f:" )) != EOF ) {
+    while (( i = getopt( argc, argv, "WFabckKnrtvh:p:D:w:d:f:" )) != EOF ) {
        switch( i ) {
        case 'a':       /* add */
            new = 1;
@@ -145,6 +145,9 @@ main( int argc, char **argv )
        case 'v':       /* verbose mode */
            verbose++;
            break;
+       case 'W':
+               want_bindpw++;
+               break;
        default:
            fprintf( stderr, usage, prog );
            exit( 1 );
@@ -174,6 +177,9 @@ main( int argc, char **argv )
 
        ld->ld_deref = LDAP_DEREF_NEVER;        /* this seems prudent */
 
+       if (want_bindpw)
+               passwd = getpass("Enter LDAP Password: ");
+
        if ( ldap_bind_s( ld, binddn, passwd, authmethod ) != LDAP_SUCCESS ) {
            ldap_perror( ld, "ldap_bind" );
            exit( 1 );
index 332691bdd512aebafa2eda134496aee5e4d07349..d3fa7db56442cf18e1dcc42c203a47887b334289 100644 (file)
@@ -35,18 +35,18 @@ static int domodrdn LDAP_P((
 int
 main(int argc, char **argv)
 {
-    char               *usage = "usage: %s [-nvkc] [-d debug-level] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [ -f file | < entryfile | dn newrdn ]\n";
+    char               *usage = "usage: %s [-nvkWc] [-d debug-level] [-h ldaphost] [-p ldapport] [-D binddn] [-w passwd] [ -f file | < entryfile | dn newrdn ]\n";
     char               *myname,*infile, *entrydn, *rdn, buf[ 4096 ];
     FILE               *fp;
-    int                        rc, i, remove, havedn, authmethod;
+    int                        rc, i, remove, havedn, authmethod, want_bindpw;
 
     infile = NULL;
-    not = contoper = verbose = remove = 0;
+    not = contoper = verbose = remove = want_bindpw = 0;
     authmethod = LDAP_AUTH_SIMPLE;
 
     myname = (myname = strrchr(argv[0], '/')) == NULL ? argv[0] : ++myname;
 
-    while (( i = getopt( argc, argv, "kKcnvrh:p:D:w:d:f:" )) != EOF ) {
+    while (( i = getopt( argc, argv, "WkKcnvrh:p:D:w:d:f:" )) != EOF ) {
        switch( i ) {
        case 'k':       /* kerberos bind */
 #ifdef HAVE_KERBEROS
@@ -96,6 +96,9 @@ main(int argc, char **argv)
        case 'r':       /* remove old RDN */
            remove++;
            break;
+       case 'W':
+               want_bindpw++;
+               break;
        default:
            fprintf( stderr, usage, argv[0] );
            exit( 1 );
@@ -135,6 +138,9 @@ main(int argc, char **argv)
 
     ld->ld_deref = LDAP_DEREF_NEVER;   /* this seems prudent */
 
+       if (want_bindpw)
+               passwd = getpass("Enter LDAP Password: ");
+
     if ( ldap_bind_s( ld, binddn, passwd, authmethod ) != LDAP_SUCCESS ) {
        ldap_perror( ld, "ldap_bind" );
        exit( 1 );
index a6ab61426de613249ea1ff81ed70110926197d2a..79e63c33baaa6e749b887ff17b7b4add8141e3ba 100644 (file)
@@ -17,9 +17,8 @@
 
 #define DEFSEP         "="
 
-
-static void
-usage( char *s )
+static void usage( s )
+char   *s;
 {
     fprintf( stderr, "usage: %s [options] filter [attributes...]\nwhere:\n", s );
     fprintf( stderr, "    filter\tRFC-1558 compliant LDAP search filter\n" );
@@ -85,16 +84,18 @@ static int  skipsortattr = 0;
 static int     verbose, not, includeufn, allow_binary, vals2tmp, ldif;
 
 int
-main( int argc, char **argv )
+main( argc, argv )
+int    argc;
+char   **argv;
 {
     char               *infile, *filtpattern, **attrs, line[ BUFSIZ ];
     FILE               *fp;
-    int                        rc, i, first, scope, deref, attrsonly;
+    int                        rc, i, first, scope, kerberos, deref, attrsonly;
     int                        ldap_options, timelimit, sizelimit, authmethod;
     LDAP               *ld;
 
     infile = NULL;
-    verbose = allow_binary = not = vals2tmp =
+    deref = verbose = allow_binary = not = kerberos = vals2tmp =
            attrsonly = ldif = 0;
 
 #ifdef LDAP_REFERRALS
@@ -106,8 +107,15 @@ main( int argc, char **argv )
     deref = sizelimit = timelimit = -1;
        scope = LDAP_SCOPE_SUBTREE;
     authmethod = LDAP_AUTH_SIMPLE;
+    scope = LDAP_SCOPE_SUBTREE;
 
-    while (( i = getopt( argc, argv, "KknuvtRABLD:s:f:h:b:d:p:F:a:w:l:z:S:")) != EOF ) {
+    while (( i = getopt( argc, argv,
+#ifdef HAVE_KERBEROS
+           "KknuvtRABLD:s:f:h:b:d:p:F:a:w:l:z:S:"
+#else
+           "nuvtRABLD:s:f:h:b:d:p:F:a:w:l:z:S:"
+#endif
+           )) != EOF ) {
        switch( i ) {
        case 'n':       /* do Not do any searches */
            ++not;
@@ -122,20 +130,14 @@ main( int argc, char **argv )
            fprintf( stderr, "compile with -DLDAP_DEBUG for debugging\n" );
 #endif /* LDAP_DEBUG */
            break;
-       case 'k':       /* use kerberos bind */
 #ifdef HAVE_KERBEROS
-               authmethod = LDAP_AUTH_KRBV4;
-#else
-               fprintf (stderr, "%s was not compiled with Kerberos support\n", argv[0]);
-#endif
+       case 'k':       /* use kerberos bind */
+           kerberos = 2;
            break;
        case 'K':       /* use kerberos bind, 1st part only */
-#ifdef HAVE_KERBEROS
-               authmethod = LDAP_AUTH_KRBV41;
-#else
-               fprintf (stderr, "%s was not compiled with Kerberos support\n", argv[0]);
-#endif
+           kerberos = 1;
            break;
+#endif
        case 'u':       /* include UFN */
            ++includeufn;
            break;
@@ -274,6 +276,13 @@ main( int argc, char **argv )
        }
     ld->ld_options = ldap_options;
 
+    if ( !kerberos ) {
+       authmethod = LDAP_AUTH_SIMPLE;
+    } else if ( kerberos == 1 ) {
+       authmethod = LDAP_AUTH_KRBV41;
+    } else {
+       authmethod =  LDAP_AUTH_KRBV4;
+    }
     if ( ldap_bind_s( ld, binddn, passwd, authmethod ) != LDAP_SUCCESS ) {
        ldap_perror( ld, "ldap_bind" );
        exit( 1 );
@@ -313,9 +322,6 @@ main( int argc, char **argv )
 
     ldap_unbind( ld );
     exit( rc );
-
-       /* UNREACHABLE */
-       return(0);
 }