diff options
-rw-r--r-- | src/db/sysdb.h | 4 | ||||
-rw-r--r-- | src/db/sysdb_ops.c | 29 |
2 files changed, 22 insertions, 11 deletions
diff --git a/src/db/sysdb.h b/src/db/sysdb.h index dd14190bf..1057090e6 100644 --- a/src/db/sysdb.h +++ b/src/db/sysdb.h @@ -505,8 +505,8 @@ int sysdb_search_entry(TALLOC_CTX *mem_ctx, int scope, const char *filter, const char **attrs, - size_t *msgs_count, - struct ldb_message ***msgs); + size_t *_msgs_count, + struct ldb_message ***_msgs); /* Search User (by uid, sid or name) */ int sysdb_search_user_by_name(TALLOC_CTX *mem_ctx, diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c index 1f51b9682..500860f48 100644 --- a/src/db/sysdb_ops.c +++ b/src/db/sysdb_ops.c @@ -211,27 +211,38 @@ int sysdb_search_entry(TALLOC_CTX *mem_ctx, int scope, const char *filter, const char **attrs, - size_t *msgs_count, - struct ldb_message ***msgs) + size_t *_msgs_count, + struct ldb_message ***_msgs) { + TALLOC_CTX *tmp_ctx; struct ldb_result *res; int ret; - ret = ldb_search(sysdb->ldb, mem_ctx, &res, + tmp_ctx = talloc_new(NULL); + if (tmp_ctx == NULL) { + ret = ENOMEM; + goto done; + } + + ret = ldb_search(sysdb->ldb, tmp_ctx, &res, base_dn, scope, attrs, filter?"%s":NULL, filter); - if (ret) { - return sysdb_error_to_errno(ret); + if (ret != EOK) { + ret = sysdb_error_to_errno(ret); + goto done; } - *msgs_count = res->count; - *msgs = talloc_steal(mem_ctx, res->msgs); + *_msgs_count = res->count; + *_msgs = talloc_steal(mem_ctx, res->msgs); if (res->count == 0) { - return ENOENT; + ret = ENOENT; + goto done; } - return EOK; +done: + talloc_zfree(tmp_ctx); + return ret; } /* =Search-Entry-by-SID-string============================================ */ |