svn commit: samba r7615 - in branches/SAMBA_4_0/source: dsdb/samdb lib lib/ldb/tests

idra at samba.org idra at samba.org
Wed Jun 15 17:15:02 GMT 2005


Author: idra
Date: 2005-06-15 17:15:01 +0000 (Wed, 15 Jun 2005)
New Revision: 7615

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

Log:

fix the build and simplify gendb_search_dn


Modified:
   branches/SAMBA_4_0/source/dsdb/samdb/samdb.c
   branches/SAMBA_4_0/source/lib/gendb.c
   branches/SAMBA_4_0/source/lib/ldb/tests/test-generic.sh


Changeset:
Modified: branches/SAMBA_4_0/source/dsdb/samdb/samdb.c
===================================================================
--- branches/SAMBA_4_0/source/dsdb/samdb/samdb.c	2005-06-15 17:03:34 UTC (rev 7614)
+++ branches/SAMBA_4_0/source/dsdb/samdb/samdb.c	2005-06-15 17:15:01 UTC (rev 7615)
@@ -52,8 +52,8 @@
 	int i, count;
 
 	va_start(ap, format);
-	count = gendb_search_v(sam_ldb, mem_ctx, basedn, res, attrs,
-			       format, ap);
+	count = gendb_search_v(sam_ldb, mem_ctx, basedn,
+			       res, attrs, format, ap);
 	va_end(ap);
 
 	i=0;

Modified: branches/SAMBA_4_0/source/lib/gendb.c
===================================================================
--- branches/SAMBA_4_0/source/lib/gendb.c	2005-06-15 17:03:34 UTC (rev 7614)
+++ branches/SAMBA_4_0/source/lib/gendb.c	2005-06-15 17:15:01 UTC (rev 7615)
@@ -35,22 +35,27 @@
 		   const char *format, 
 		   va_list ap)  _PRINTF_ATTRIBUTE(6,0)
 {
+	enum ldb_scope scope = LDB_SCOPE_SUBTREE;
 	char *expr = NULL;
 	int count;
 
-	vasprintf(&expr, format, ap);
-	if (expr == NULL) {
-		return -1;
+	if (format) {
+		vasprintf(&expr, format, ap);
+		if (expr == NULL) {
+			return -1;
+		}
+	} else {
+		scope = LDB_SCOPE_BASE;
 	}
 
 	*res = NULL;
 
-	count = ldb_search(ldb, basedn, LDB_SCOPE_SUBTREE, expr, attrs, res);
+	count = ldb_search(ldb, basedn, scope, expr, attrs, res);
 
 	if (*res) talloc_steal(mem_ctx, *res);
 
 	DEBUG(4,("gendb_search_v: %s %s -> %d  (%s)\n", 
-		 basedn?basedn:"NULL", expr, count,
+		 basedn?basedn:"NULL", expr?expr:"NULL", count,
 		 count==-1?ldb_errstring(ldb):"OK"));
 
 	free(expr);
@@ -79,31 +84,13 @@
 }
 
 int gendb_search_dn(struct ldb_context *ldb,
-		    TALLOC_CTX *mem_ctx,
-		    const char *dn,
-		    struct ldb_message ***res,
-		    const char * const *attrs)
+		 TALLOC_CTX *mem_ctx, 
+		 const char *dn,
+		 struct ldb_message ***res,
+		 const char * const *attrs)
 {
-	va_list ap;
-	int count;
-
-	*res = NULL;
-
-	count = ldb_search(ldb, dn, LDB_SCOPE_BASE, "", attrs, res);
-
-	if (count > 1) {
-		DEBUG(1, ("DB Corruption ? - Found more then one entry for dn: %s", dn));
-		return -1;
-	}
-
-	if (*res) talloc_steal(mem_ctx, *res);
-
-	DEBUG(4,("gendb_search_dn: %s -> %d (%s)\n",
-		 dn, count, count==-1?ldb_errstring(ldb):"OK"));
-
-	return count;
+	return gendb_search(ldb, mem_ctx, dn, res, attrs, NULL);
 }
-		    
 
 /*
   setup some initial ldif in a ldb

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-15 17:03:34 UTC (rev 7614)
+++ branches/SAMBA_4_0/source/lib/ldb/tests/test-generic.sh	2005-06-15 17:15:01 UTC (rev 7615)
@@ -39,7 +39,7 @@
 $VALGRIND bin/ldbsearch '(&(uid=uham)(uid=uha*)(title=*))' uid || exit 1
 $VALGRIND bin/ldbsearch '((' uid && exit 1
 $VALGRIND bin/ldbsearch '(objectclass=)' uid || exit 1
-$VALGRIND bin/ldbsearch 'dn=cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=US' uid || exit 1
+$VALGRIND bin/ldbsearch -b 'cn=Hampster Ursula,ou=Alumni Association,ou=People,o=University of Michigan,c=US' -s base "" sn || exit 1
 
 echo "Starting ldbtest indexed"
 time $VALGRIND bin/ldbtest -r 1000 -s 5000  || exit 1



More information about the samba-cvs mailing list