svn commit: samba r7833 - in branches/SAMBA_4_0/source/lib/ldb: tests tools

tridge at samba.org tridge at samba.org
Wed Jun 22 03:10:41 GMT 2005


Author: tridge
Date: 2005-06-22 03:10:40 +0000 (Wed, 22 Jun 2005)
New Revision: 7833

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=7833

Log:
changed ldbsearch and ldbedit to have command line syntax closer to
ldapsearch. They look for an '=' in the first argument to see if it is
a search expression, and if not then it does an 'all records' search





Modified:
   branches/SAMBA_4_0/source/lib/ldb/tests/test-generic.sh
   branches/SAMBA_4_0/source/lib/ldb/tools/ldbedit.c
   branches/SAMBA_4_0/source/lib/ldb/tools/ldbsearch.c


Changeset:
Modified: branches/SAMBA_4_0/source/lib/ldb/tests/test-generic.sh
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/tests/test-generic.sh	2005-06-22 03:09:25 UTC (rev 7832)
+++ branches/SAMBA_4_0/source/lib/ldb/tests/test-generic.sh	2005-06-22 03:10:40 UTC (rev 7833)
@@ -37,7 +37,7 @@
 $VALGRIND bin/ldbsearch '(&(uid=uham)(uid=uham)(!(objectclass=xxx)))'  || exit 1
 $VALGRIND bin/ldbsearch '(&(objectclass=person)(uid=uham)(!(uid=uhamxx)))' uid \* \+ dn  || exit 1
 $VALGRIND bin/ldbsearch '(&(uid=uham)(uid=uha*)(title=*))' uid || exit 1
-$VALGRIND bin/ldbsearch '((' uid && exit 1
+$VALGRIND bin/ldbsearch '((' uid || exit 1
 $VALGRIND bin/ldbsearch '(objectclass=)' uid || exit 1
 $VALGRIND bin/ldbsearch -b 'cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=TEST' -s base "" sn || exit 1
 

Modified: branches/SAMBA_4_0/source/lib/ldb/tools/ldbedit.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/tools/ldbedit.c	2005-06-22 03:09:25 UTC (rev 7832)
+++ branches/SAMBA_4_0/source/lib/ldb/tools/ldbedit.c	2005-06-22 03:10:40 UTC (rev 7833)
@@ -278,28 +278,23 @@
 	struct ldb_context *ldb;
 	struct ldb_message **msgs;
 	int ret;
-	const char *expression = NULL;
+	const char *expression = "(|(objectclass=*)(dn=*))";
 	const char * const * attrs = NULL;
 
 	ldb = ldb_init(NULL);
 
 	options = ldb_cmdline_process(ldb, argc, argv, usage);
 
-	if (options->all_records) {
-		expression = "(|(objectclass=*)(dn=*))";
-	}
-
-	if (!expression) {
-		if (options->argc == 0) {
-			usage();
-		}
+	/* the check for '=' is for compatibility with ldapsearch */
+	if (options->argc > 0 && 
+	    strchr(options->argv[0], '=')) {
 		expression = options->argv[0];
-		options->argc--;
 		options->argv++;
+		options->argc--;
 	}
 
 	if (options->argc > 0) {
-		attrs = (const char * const *)options->argv;
+		attrs = (const char * const *)(options->argv);
 	}
 
 	ret = ldb_search(ldb, options->basedn, options->scope, expression, attrs, &msgs);

Modified: branches/SAMBA_4_0/source/lib/ldb/tools/ldbsearch.c
===================================================================
--- branches/SAMBA_4_0/source/lib/ldb/tools/ldbsearch.c	2005-06-22 03:09:25 UTC (rev 7832)
+++ branches/SAMBA_4_0/source/lib/ldb/tools/ldbsearch.c	2005-06-22 03:10:40 UTC (rev 7833)
@@ -120,18 +120,23 @@
 	const char * const * attrs = NULL;
 	struct ldb_cmdline *options;
 	int ret = -1;
+	const char *expression = "(|(objectclass=*)(dn=*))";
 
 	ldb = ldb_init(NULL);
 
 	options = ldb_cmdline_process(ldb, argc, argv, usage);
-	
-	if (options->argc < 1 && !options->interactive) {
-		usage();
-		exit(1);
+
+	/* the check for '=' is for compatibility with ldapsearch */
+	if (!options->interactive &&
+	    options->argc > 0 && 
+	    strchr(options->argv[0], '=')) {
+		expression = options->argv[0];
+		options->argv++;
+		options->argc--;
 	}
 
-	if (options->argc > 1) {
-		attrs = (const char * const *)(options->argv+1);
+	if (options->argc > 0) {
+		attrs = (const char * const *)(options->argv);
 	}
 
 	if (options->interactive) {
@@ -144,7 +149,7 @@
 		}
 	} else {
 		ret = do_search(ldb, options->basedn, options->scope, options->sorted, 
-				options->argv[0], attrs);
+				expression, attrs);
 	}
 
 	talloc_free(ldb);



More information about the samba-cvs mailing list