X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=libraries%2Flibldap%2Ftest.c;h=15b188d3327b9d9228a3bb8170c8c80655596363;hb=6c1d48aa8d066ff85809b8a544952ad2d1dc3400;hp=1d24586a5d556dee3c2ecab90f17e6354420a837;hpb=32a9ad1be8aa9608509fb027aa6791fe102bdc8e;p=openldap
diff --git a/libraries/libldap/test.c b/libraries/libldap/test.c
index 1d24586a5d..15b188d332 100644
--- a/libraries/libldap/test.c
+++ b/libraries/libldap/test.c
@@ -1,7 +1,16 @@
/* $OpenLDAP$ */
-/*
- * Copyright 1998-2003 The OpenLDAP Foundation, All Rights Reserved.
- * COPYING RESTRICTIONS APPLY, see COPYRIGHT file
+/* This work is part of OpenLDAP Software .
+ *
+ * Copyright 1998-2010 The OpenLDAP Foundation.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted only as authorized by the OpenLDAP
+ * Public License.
+ *
+ * A copy of this license is available in the file LICENSE in the
+ * top-level directory of the distribution or, alternatively, at
+ * .
*/
#include "portable.h"
@@ -50,7 +59,7 @@ static char *dnsuffix;
static char *
get_line( char *line, int len, FILE *fp, const char *prompt )
{
- printf(prompt);
+ fputs(prompt, stdout);
if ( fgets( line, len, fp ) == NULL )
return( NULL );
@@ -160,7 +169,7 @@ get_modlist(
{
static char buf[256];
int num;
- LDAPMod tmp;
+ LDAPMod tmp = { 0 };
LDAPMod **result;
struct berval **bvals;
@@ -196,6 +205,10 @@ get_modlist(
6 ) == 0 ) {
if ( file_read( tmp.mod_values[i] + 6,
bvals[i] ) < 0 ) {
+ free( bvals );
+ for ( i = 0; isimple, 1->krbv41, 2->krbv42, 3->krbv41&2)? " );
- if (( authmethod = atoi( dn )) == 3 ) {
- authmethod = LDAP_AUTH_KRBV4;
- } else {
- authmethod |= 0x80;
- }
-#else /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */
authmethod = LDAP_AUTH_SIMPLE;
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */
get_line( dn, sizeof(dn), stdin, "re-bind dn? " );
strcat( dn, dnsuffix );
@@ -274,7 +277,8 @@ main( int argc, char **argv )
char passwd[64], dn[256], rdn[64], attr[64], value[256];
char filter[256], *host, **types;
char **exdn;
- char *usage = "usage: %s [-u] [-h host] [-d level] [-s dnsuffix] [-p port] [-t file] [-T file]\n";
+ static const char usage[] =
+ "usage: %s [-u] [-h host] [-d level] [-s dnsuffix] [-p port] [-t file] [-T file]\n";
int bound, all, scope, attrsonly;
LDAPMessage *res;
LDAPMod **mods, **attrs;
@@ -399,13 +403,7 @@ main( int argc, char **argv )
break;
case 'b': /* asynch bind */
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
- get_line( line, sizeof(line), stdin,
- "method (0->simple, 1->krbv41, 2->krbv42)? " );
- method = atoi( line ) | 0x80;
-#else /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */
method = LDAP_AUTH_SIMPLE;
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */
get_line( dn, sizeof(dn), stdin, "dn? " );
strcat( dn, dnsuffix );
@@ -425,17 +423,7 @@ main( int argc, char **argv )
break;
case 'B': /* synch bind */
-#ifdef LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND
- get_line( line, sizeof(line), stdin,
- "method 0->simple 1->krbv41 2->krbv42 3->krb? " );
- method = atoi( line );
- if ( method == 3 )
- method = LDAP_AUTH_KRBV4;
- else
- method = method | 0x80;
-#else /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */
method = LDAP_AUTH_SIMPLE;
-#endif /* LDAP_API_FEATURE_X_OPENLDAP_V2_KBIND */
get_line( dn, sizeof(dn), stdin, "dn? " );
strcat( dn, dnsuffix );
@@ -578,7 +566,7 @@ main( int argc, char **argv )
get_line( dn, sizeof(dn), stdin, "searchbase? " );
strcat( dn, dnsuffix );
get_line( line, sizeof(line), stdin,
- "scope (0=Base, 1=One Level, 2=Subtree)? " );
+ "scope (0=baseObject, 1=oneLevel, 2=subtree, 3=children)? " );
scope = atoi( line );
get_line( filter, sizeof(filter), stdin,
"search filter (e.g. sn=jones)? " );
@@ -627,9 +615,14 @@ main( int argc, char **argv )
printf( " <%s>", ludp->lud_attrs[ i ] );
}
}
- printf( "\n\t scope: %s\n", ludp->lud_scope == LDAP_SCOPE_ONELEVEL ?
- "ONE" : ludp->lud_scope == LDAP_SCOPE_BASE ? "BASE" :
- ludp->lud_scope == LDAP_SCOPE_SUBTREE ? "SUB" : "**invalid**" );
+ printf( "\n\t scope: %s\n",
+ ludp->lud_scope == LDAP_SCOPE_BASE ? "baseObject"
+ : ludp->lud_scope == LDAP_SCOPE_ONELEVEL ? "oneLevel"
+ : ludp->lud_scope == LDAP_SCOPE_SUBTREE ? "subtree"
+#ifdef LDAP_SCOPE_SUBORDINATE
+ : ludp->lud_scope == LDAP_SCOPE_SUBORDINATE ? "children"
+#endif
+ : "**invalid**" );
printf( "\tfilter: <%s>\n", ludp->lud_filter );
ldap_free_urldesc( ludp );
}