summaryrefslogtreecommitdiff
path: root/src/db
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2010-03-14 18:31:56 -0400
committerStephen Gallagher <sgallagh@redhat.com>2010-04-12 09:22:15 -0400
commita298e5b4050a69238593017ccc774336eb332e16 (patch)
tree0cd8c51c177ac44a78926e2aec20f5096dda3a8f /src/db
parent7ffaa2afb9e03a6f0b9c602c0f03b2074ea33eac (diff)
downloadsssd-a298e5b4050a69238593017ccc774336eb332e16.tar.gz
sssd-a298e5b4050a69238593017ccc774336eb332e16.tar.bz2
sssd-a298e5b4050a69238593017ccc774336eb332e16.zip
sysdb: convert sysdb_getpwuid
Diffstat (limited to 'src/db')
-rw-r--r--src/db/sysdb.h2
-rw-r--r--src/db/sysdb_search.c40
2 files changed, 23 insertions, 19 deletions
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index 365e6adf..cb5cbba1 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -259,7 +259,7 @@ int sysdb_getpwuid(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
struct sss_domain_info *domain,
uid_t uid,
- sysdb_callback_t fn, void *ptr);
+ struct ldb_result **res);
int sysdb_enumpwent(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
diff --git a/src/db/sysdb_search.c b/src/db/sysdb_search.c
index 2403917b..3d375214 100644
--- a/src/db/sysdb_search.c
+++ b/src/db/sysdb_search.c
@@ -257,39 +257,43 @@ int sysdb_getpwuid(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
struct sss_domain_info *domain,
uid_t uid,
- sysdb_callback_t fn, void *ptr)
+ struct ldb_result **_res)
{
+ TALLOC_CTX *tmpctx;
+ unsigned long int ul_uid = uid;
static const char *attrs[] = SYSDB_PW_ATTRS;
- struct sysdb_search_ctx *sctx;
- unsigned long int filter_uid = uid;
- struct tevent_req *req;
+ struct ldb_dn *base_dn;
+ struct ldb_result *res;
+ int ret;
if (!domain) {
return EINVAL;
}
- sctx = init_src_ctx(mem_ctx, domain, ctx, fn, ptr);
- if (!sctx) {
+ tmpctx = talloc_new(mem_ctx);
+ if (!tmpctx) {
return ENOMEM;
}
- sctx->expression = talloc_asprintf(sctx, SYSDB_PWUID_FILTER, filter_uid);
- if (!sctx->expression) {
- talloc_free(sctx);
- return ENOMEM;
+ base_dn = ldb_dn_new_fmt(tmpctx, ctx->ldb,
+ SYSDB_TMPL_USER_BASE, domain->name);
+ if (!base_dn) {
+ ret = ENOMEM;
+ goto done;
}
- sctx->attrs = attrs;
-
- req = sysdb_operation_send(mem_ctx, ctx->ev, ctx);
- if (!req) {
- talloc_free(sctx);
- return ENOMEM;
+ ret = ldb_search(ctx->ldb, tmpctx, &res, base_dn,
+ LDB_SCOPE_SUBTREE, attrs, SYSDB_PWUID_FILTER, ul_uid);
+ if (ret) {
+ ret = sysdb_error_to_errno(ret);
+ goto done;
}
- tevent_req_set_callback(req, user_search, sctx);
+ *_res = talloc_steal(mem_ctx, res);
- return EOK;
+done:
+ talloc_zfree(tmpctx);
+ return ret;
}
int sysdb_enumpwent(TALLOC_CTX *mem_ctx,