From 2b7ee2a760e7fcc70f4970a3bbee6fbf8f2ccb9d Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Mon, 7 Jan 2013 23:33:45 -0500 Subject: Add domain argument to sysdb_search_groups() --- src/db/sysdb.h | 1 + src/db/sysdb_ops.c | 6 ++++-- src/providers/ipa/ipa_hbac_users.c | 2 +- src/providers/ldap/ldap_id_cleanup.c | 11 +++++++---- src/providers/ldap/sdap_async_groups.c | 3 ++- src/providers/ldap/sdap_reinit.c | 5 +++-- src/tools/sss_cache.c | 3 ++- src/tools/sss_groupshow.c | 3 ++- 8 files changed, 22 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/db/sysdb.h b/src/db/sysdb.h index 5f406e31..8ccf637a 100644 --- a/src/db/sysdb.h +++ b/src/db/sysdb.h @@ -762,6 +762,7 @@ int sysdb_delete_user(struct sysdb_ctx *sysdb, int sysdb_search_groups(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb, + struct sss_domain_info *domain, const char *sub_filter, const char **attrs, size_t *msgs_count, diff --git a/src/db/sysdb_ops.c b/src/db/sysdb_ops.c index 4b885d67..37e6b682 100644 --- a/src/db/sysdb_ops.c +++ b/src/db/sysdb_ops.c @@ -2460,7 +2460,8 @@ int sysdb_delete_user(struct sysdb_ctx *sysdb, goto fail; } - ret = sysdb_search_groups(tmp_ctx, sysdb, filter, attrs, &msg_count, &msgs); + ret = sysdb_search_groups(tmp_ctx, sysdb, domain, + filter, attrs, &msg_count, &msgs); if (ret != EOK) { goto fail; } @@ -2503,6 +2504,7 @@ fail: int sysdb_search_groups(TALLOC_CTX *mem_ctx, struct sysdb_ctx *sysdb, + struct sss_domain_info *domain, const char *sub_filter, const char **attrs, size_t *msgs_count, @@ -2519,7 +2521,7 @@ int sysdb_search_groups(TALLOC_CTX *mem_ctx, } basedn = ldb_dn_new_fmt(tmp_ctx, sysdb->ldb, - SYSDB_TMPL_GROUP_BASE, sysdb->domain->name); + SYSDB_TMPL_GROUP_BASE, domain->name); if (!basedn) { DEBUG(2, ("Failed to build base dn\n")); ret = ENOMEM; diff --git a/src/providers/ipa/ipa_hbac_users.c b/src/providers/ipa/ipa_hbac_users.c index 7b59c321..2b27b1f7 100644 --- a/src/providers/ipa/ipa_hbac_users.c +++ b/src/providers/ipa/ipa_hbac_users.c @@ -265,7 +265,7 @@ hbac_user_attrs_to_rule(TALLOC_CTX *mem_ctx, num_users++; } else { /* Check if it is a group instead */ - ret = sysdb_search_groups(tmp_ctx, sysdb, + ret = sysdb_search_groups(tmp_ctx, sysdb, domain, filter, attrs, &count, &msgs); if (ret != EOK && ret != ENOENT) goto done; if (ret == EOK && count == 0) { diff --git a/src/providers/ldap/ldap_id_cleanup.c b/src/providers/ldap/ldap_id_cleanup.c index 77c4d94e..103cca97 100644 --- a/src/providers/ldap/ldap_id_cleanup.c +++ b/src/providers/ldap/ldap_id_cleanup.c @@ -171,7 +171,8 @@ struct global_cleanup_state { static int cleanup_users(TALLOC_CTX *memctx, struct sdap_id_ctx *ctx); static int cleanup_groups(TALLOC_CTX *memctx, - struct sysdb_ctx *sysdb); + struct sysdb_ctx *sysdb, + struct sss_domain_info *domain); struct tevent_req *ldap_id_cleanup_send(TALLOC_CTX *memctx, struct tevent_context *ev, @@ -203,7 +204,8 @@ struct tevent_req *ldap_id_cleanup_send(TALLOC_CTX *memctx, } ret = cleanup_groups(state, - state->ctx->be->sysdb); + state->ctx->be->sysdb, + state->ctx->be->domain); if (ret) { goto fail; } @@ -380,7 +382,8 @@ static int cleanup_users_logged_in(hash_table_t *table, /* ==Group-Cleanup-Process================================================ */ static int cleanup_groups(TALLOC_CTX *memctx, - struct sysdb_ctx *sysdb) + struct sysdb_ctx *sysdb, + struct sss_domain_info *domain) { TALLOC_CTX *tmpctx; const char *attrs[] = { SYSDB_NAME, SYSDB_GIDNUM, NULL }; @@ -411,7 +414,7 @@ static int cleanup_groups(TALLOC_CTX *memctx, goto done; } - ret = sysdb_search_groups(tmpctx, sysdb, + ret = sysdb_search_groups(tmpctx, sysdb, domain, subfilter, attrs, &count, &msgs); if (ret) { if (ret == ENOENT) { diff --git a/src/providers/ldap/sdap_async_groups.c b/src/providers/ldap/sdap_async_groups.c index fde83ee8..96cc7c0c 100644 --- a/src/providers/ldap/sdap_async_groups.c +++ b/src/providers/ldap/sdap_async_groups.c @@ -3025,7 +3025,8 @@ sdap_nested_group_check_cache(TALLOC_CTX *mem_ctx, /* It wasn't a user. Check whether it's a group */ if (ret == EOK) talloc_zfree(msgs); - ret = sysdb_search_groups(tmp_ctx, sysdb, filter, attrs, &count, &msgs); + ret = sysdb_search_groups(tmp_ctx, sysdb, dom, + filter, attrs, &count, &msgs); if (ret != EOK && ret != ENOENT) { ret = EIO; goto fail; diff --git a/src/providers/ldap/sdap_reinit.c b/src/providers/ldap/sdap_reinit.c index cc836ae5..41d10249 100644 --- a/src/providers/ldap/sdap_reinit.c +++ b/src/providers/ldap/sdap_reinit.c @@ -153,7 +153,8 @@ static errno_t sdap_reinit_clear_usn(struct sysdb_ctx *sysdb, msgs_num = 0; /* reset groups' usn */ - ret = sysdb_search_groups(tmp_ctx, sysdb, "", attrs, &msgs_num, &msgs); + ret = sysdb_search_groups(tmp_ctx, sysdb, domain, + "", attrs, &msgs_num, &msgs); if (ret != EOK) { goto done; } @@ -279,7 +280,7 @@ static errno_t sdap_reinit_delete_records(struct sysdb_ctx *sysdb, msgs_num = 0; /* purge untouched groups */ - ret = sysdb_search_groups(tmp_ctx, sysdb, "(!("SYSDB_USN"=*))", + ret = sysdb_search_groups(tmp_ctx, sysdb, domain, "(!("SYSDB_USN"=*))", attrs, &msgs_num, &msgs); if (ret != EOK) { goto done; diff --git a/src/tools/sss_cache.c b/src/tools/sss_cache.c index 0c6112cc..c974a28b 100644 --- a/src/tools/sss_cache.c +++ b/src/tools/sss_cache.c @@ -297,7 +297,8 @@ static bool invalidate_entries(TALLOC_CTX *ctx, break; case TYPE_GROUP: type_string = "group"; - ret = sysdb_search_groups(ctx, sysdb, filter, attrs, &msg_count, &msgs); + ret = sysdb_search_groups(ctx, sysdb, dinfo, + filter, attrs, &msg_count, &msgs); break; case TYPE_NETGROUP: type_string = "netgroup"; diff --git a/src/tools/sss_groupshow.c b/src/tools/sss_groupshow.c index 93e0acba..56adf2a0 100644 --- a/src/tools/sss_groupshow.c +++ b/src/tools/sss_groupshow.c @@ -437,7 +437,8 @@ static int group_show_trim_memberof(TALLOC_CTX *mem_ctx, return ENOMEM; } - ret = sysdb_search_groups(mem_ctx, sysdb, filter, NULL, &count, &msgs); + ret = sysdb_search_groups(mem_ctx, sysdb, domain, + filter, NULL, &count, &msgs); /* ENOENT is OK, the group is just not a direct parent */ if (ret != EOK && ret != ENOENT) { return ret; -- cgit