summaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
authorSimo Sorce <ssorce@redhat.com>2010-03-20 19:55:15 -0400
committerStephen Gallagher <sgallagh@redhat.com>2010-04-12 09:22:16 -0400
commit88e7576d8bf00bfd0eaed8731b7eee1d6b6e05a1 (patch)
tree425d71e756b90a12358662e1f36c0b7d311b3545 /src/db
parentfa362558a3f89644dab60debfbc423fe31a39f00 (diff)
downloadsssd-88e7576d8bf00bfd0eaed8731b7eee1d6b6e05a1.tar.gz
sssd-88e7576d8bf00bfd0eaed8731b7eee1d6b6e05a1.tar.xz
sssd-88e7576d8bf00bfd0eaed8731b7eee1d6b6e05a1.zip
sysdb: convert sysdb_enumgrent
Diffstat (limited to 'src/db')
-rw-r--r--src/db/sysdb.h2
-rw-r--r--src/db/sysdb_search.c88
2 files changed, 34 insertions, 56 deletions
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index 7d4b25819..969413be4 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -281,7 +281,7 @@ int sysdb_getgrgid(TALLOC_CTX *mem_ctx,
int sysdb_enumgrent(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
struct sss_domain_info *domain,
- sysdb_callback_t fn, void *ptr);
+ struct ldb_result **res);
int sysdb_initgroups(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
diff --git a/src/db/sysdb_search.c b/src/db/sysdb_search.c
index 2ac794987..b874f0d07 100644
--- a/src/db/sysdb_search.c
+++ b/src/db/sysdb_search.c
@@ -346,47 +346,6 @@ static int mpg_res_convert(struct ldb_result *res)
return EOK;
}
-static void grp_search(struct tevent_req *treq)
-{
- struct sysdb_search_ctx *sctx;
- static const char *attrs[] = SYSDB_GRSRC_ATTRS;
- struct ldb_request *req;
- struct ldb_dn *base_dn;
- int ret;
-
- sctx = tevent_req_callback_data(treq, struct sysdb_search_ctx);
-
- ret = sysdb_operation_recv(treq, sctx, &sctx->handle);
- if (ret) {
- return request_error(sctx, ret);
- }
-
- if (sctx->gen_conv_mpg_users) {
- base_dn = ldb_dn_new_fmt(sctx, sctx->ctx->ldb,
- SYSDB_DOM_BASE, sctx->domain->name);
- } else {
- base_dn = ldb_dn_new_fmt(sctx, sctx->ctx->ldb,
- SYSDB_TMPL_GROUP_BASE, sctx->domain->name);
- }
- if (!base_dn) {
- return request_error(sctx, ENOMEM);
- }
-
- ret = ldb_build_search_req(&req, sctx->ctx->ldb, sctx,
- base_dn, LDB_SCOPE_SUBTREE,
- sctx->expression, attrs, NULL,
- sctx, get_gen_callback,
- NULL);
- if (ret != LDB_SUCCESS) {
- return request_ldberror(sctx, ret);
- }
-
- ret = ldb_request(sctx->ctx->ldb, req);
- if (ret != LDB_SUCCESS) {
- return request_ldberror(sctx, ret);
- }
-}
-
int sysdb_getgrnam(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
struct sss_domain_info *domain,
@@ -501,36 +460,55 @@ done:
int sysdb_enumgrent(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
struct sss_domain_info *domain,
- sysdb_callback_t fn, void *ptr)
+ struct ldb_result **_res)
{
- struct sysdb_search_ctx *sctx;
- struct tevent_req *req;
+ TALLOC_CTX *tmpctx;
+ static const char *attrs[] = SYSDB_GRSRC_ATTRS;
+ const char *fmt_filter;
+ 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;
}
if (ctx->mpg) {
- sctx->gen_conv_mpg_users = true;
- sctx->expression = SYSDB_GRENT_MPG_FILTER;
+ fmt_filter = SYSDB_GRENT_MPG_FILTER;
+ base_dn = ldb_dn_new_fmt(tmpctx, ctx->ldb,
+ SYSDB_DOM_BASE, domain->name);
} else {
- sctx->expression = SYSDB_GRENT_FILTER;
+ fmt_filter = SYSDB_GRENT_FILTER;
+ base_dn = ldb_dn_new_fmt(tmpctx, ctx->ldb,
+ SYSDB_TMPL_GROUP_BASE, domain->name);
+ }
+ if (!base_dn) {
+ ret = ENOMEM;
+ goto done;
}
- 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, fmt_filter);
+ if (ret) {
+ ret = sysdb_error_to_errno(ret);
+ goto done;
+ }
+
+ ret = mpg_res_convert(res);
+ if (ret) {
+ goto done;
}
- tevent_req_set_callback(req, grp_search, sctx);
+ *_res = talloc_steal(mem_ctx, res);
- return EOK;
+done:
+ talloc_zfree(tmpctx);
+ return ret;
}
static void initgr_mem_search(struct sysdb_search_ctx *sctx)