summaryrefslogtreecommitdiffstats
path: root/src/db
diff options
context:
space:
mode:
Diffstat (limited to 'src/db')
-rw-r--r--src/db/sysdb.h2
-rw-r--r--src/db/sysdb_search.c54
2 files changed, 34 insertions, 22 deletions
diff --git a/src/db/sysdb.h b/src/db/sysdb.h
index 65b57bdfc..7b5166fea 100644
--- a/src/db/sysdb.h
+++ b/src/db/sysdb.h
@@ -277,7 +277,7 @@ int sysdb_getgrgid(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
struct sss_domain_info *domain,
gid_t gid,
- sysdb_callback_t fn, void *ptr);
+ struct ldb_result **res);
int sysdb_enumgrent(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
diff --git a/src/db/sysdb_search.c b/src/db/sysdb_search.c
index 144f6da51..cabf19f45 100644
--- a/src/db/sysdb_search.c
+++ b/src/db/sysdb_search.c
@@ -477,44 +477,56 @@ int sysdb_getgrgid(TALLOC_CTX *mem_ctx,
struct sysdb_ctx *ctx,
struct sss_domain_info *domain,
gid_t gid,
- sysdb_callback_t fn, void *ptr)
+ struct ldb_result **_res)
{
- struct sysdb_search_ctx *sctx;
- struct tevent_req *req;
+ TALLOC_CTX *tmpctx;
+ unsigned long int ul_gid = gid;
+ 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 = talloc_asprintf(sctx,
- SYSDB_GRGID_MPG_FILTER,
- (unsigned long int)gid);
+ fmt_filter = SYSDB_GRGID_MPG_FILTER;
+ base_dn = ldb_dn_new_fmt(tmpctx, ctx->ldb,
+ SYSDB_DOM_BASE, domain->name);
} else {
- sctx->expression = talloc_asprintf(sctx,
- SYSDB_GRGID_FILTER,
- (unsigned long int)gid);
+ fmt_filter = SYSDB_GRGID_FILTER;
+ base_dn = ldb_dn_new_fmt(tmpctx, ctx->ldb,
+ SYSDB_TMPL_GROUP_BASE, domain->name);
}
- if (!sctx->expression) {
- talloc_free(sctx);
- return ENOMEM;
+ 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, ul_gid);
+ if (ret) {
+ ret = sysdb_error_to_errno(ret);
+ goto done;
}
- tevent_req_set_callback(req, grp_search, sctx);
+ ret = mpg_res_convert(res);
+ if (ret) {
+ goto done;
+ }
- return EOK;
+ *_res = talloc_steal(mem_ctx, res);
+
+done:
+ talloc_zfree(tmpctx);
+ return ret;
}
int sysdb_enumgrent(TALLOC_CTX *mem_ctx,