1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-04 17:47:26 +03:00

r7615: fix the build and simplify gendb_search_dn

This commit is contained in:
Simo Sorce 2005-06-15 17:15:01 +00:00 committed by Gerald (Jerry) Carter
parent 0218fc678e
commit b38bb63175
3 changed files with 18 additions and 31 deletions

View File

@ -52,8 +52,8 @@ int samdb_search_domain(struct ldb_context *sam_ldb,
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;

View File

@ -35,22 +35,27 @@ int gendb_search_v(struct ldb_context *ldb,
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(struct ldb_context *ldb,
}
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

View File

@ -39,7 +39,7 @@ $VALGRIND bin/ldbsearch '(&(objectclass=person)(uid=uham)(!(uid=uhamxx)))' uid \
$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