|
|
5fca41 |
From fb9a42d952924b5ff084a103d43b6192c4ff0c1f Mon Sep 17 00:00:00 2001
|
|
|
5fca41 |
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
|
|
|
5fca41 |
Date: Thu, 15 Aug 2019 13:51:59 +0200
|
|
|
5fca41 |
Subject: [PATCH 83/90] ldap: add base_dn to sdap_search_bases
|
|
|
5fca41 |
MIME-Version: 1.0
|
|
|
5fca41 |
Content-Type: text/plain; charset=UTF-8
|
|
|
5fca41 |
Content-Transfer-Encoding: 8bit
|
|
|
5fca41 |
|
|
|
5fca41 |
To implement cases where we need to search a specific dn but we need
|
|
|
5fca41 |
to filter the result with configured filters.
|
|
|
5fca41 |
|
|
|
5fca41 |
Resolves:
|
|
|
5fca41 |
https://pagure.io/SSSD/sssd/issue/2607
|
|
|
5fca41 |
|
|
|
5fca41 |
Reviewed-by: Tomáš Halman <thalman@redhat.com>
|
|
|
5fca41 |
---
|
|
|
5fca41 |
src/providers/ad/ad_subdomains.c | 5 ++--
|
|
|
5fca41 |
src/providers/ipa/ipa_subdomains.c | 6 ++---
|
|
|
5fca41 |
src/providers/ipa/ipa_subdomains_ext_groups.c | 2 +-
|
|
|
5fca41 |
src/providers/ipa/ipa_sudo_async.c | 8 +++----
|
|
|
5fca41 |
src/providers/ldap/sdap_async_sudo.c | 2 +-
|
|
|
5fca41 |
src/providers/ldap/sdap_ops.c | 24 ++++++++++++-------
|
|
|
5fca41 |
src/providers/ldap/sdap_ops.h | 6 +++--
|
|
|
5fca41 |
7 files changed, 31 insertions(+), 22 deletions(-)
|
|
|
5fca41 |
|
|
|
5fca41 |
diff --git a/src/providers/ad/ad_subdomains.c b/src/providers/ad/ad_subdomains.c
|
|
|
5fca41 |
index 45a8fe0fc..f0b5d59d2 100644
|
|
|
5fca41 |
--- a/src/providers/ad/ad_subdomains.c
|
|
|
5fca41 |
+++ b/src/providers/ad/ad_subdomains.c
|
|
|
5fca41 |
@@ -1110,7 +1110,7 @@ static void ad_get_slave_domain_connect_done(struct tevent_req *subreq)
|
|
|
5fca41 |
sdap_id_op_handle(state->sdap_op),
|
|
|
5fca41 |
state->root_sdom->search_bases,
|
|
|
5fca41 |
NULL, false, 0,
|
|
|
5fca41 |
- SLAVE_DOMAIN_FILTER, attrs);
|
|
|
5fca41 |
+ SLAVE_DOMAIN_FILTER, attrs, NULL);
|
|
|
5fca41 |
if (subreq == NULL) {
|
|
|
5fca41 |
tevent_req_error(req, ret);
|
|
|
5fca41 |
return;
|
|
|
5fca41 |
@@ -1304,7 +1304,8 @@ ad_get_root_domain_send(TALLOC_CTX *mem_ctx,
|
|
|
5fca41 |
|
|
|
5fca41 |
subreq = sdap_search_bases_return_first_send(state, ev, opts, sh,
|
|
|
5fca41 |
opts->sdom->search_bases,
|
|
|
5fca41 |
- NULL, false, 0, filter, attrs);
|
|
|
5fca41 |
+ NULL, false, 0, filter, attrs,
|
|
|
5fca41 |
+ NULL);
|
|
|
5fca41 |
if (subreq == NULL) {
|
|
|
5fca41 |
ret = ENOMEM;
|
|
|
5fca41 |
goto immediately;
|
|
|
5fca41 |
diff --git a/src/providers/ipa/ipa_subdomains.c b/src/providers/ipa/ipa_subdomains.c
|
|
|
5fca41 |
index 3a17c851d..322420264 100644
|
|
|
5fca41 |
--- a/src/providers/ipa/ipa_subdomains.c
|
|
|
5fca41 |
+++ b/src/providers/ipa/ipa_subdomains.c
|
|
|
5fca41 |
@@ -1005,7 +1005,7 @@ ipa_subdomains_ranges_send(TALLOC_CTX *mem_ctx,
|
|
|
5fca41 |
|
|
|
5fca41 |
subreq = sdap_search_bases_send(state, ev, sd_ctx->sdap_id_ctx->opts, sh,
|
|
|
5fca41 |
sd_ctx->ranges_search_bases, NULL, false,
|
|
|
5fca41 |
- 0, RANGE_FILTER, attrs);
|
|
|
5fca41 |
+ 0, RANGE_FILTER, attrs, NULL);
|
|
|
5fca41 |
if (subreq == NULL) {
|
|
|
5fca41 |
ret = ENOMEM;
|
|
|
5fca41 |
goto immediately;
|
|
|
5fca41 |
@@ -1251,7 +1251,7 @@ ipa_subdomains_master_send(TALLOC_CTX *mem_ctx,
|
|
|
5fca41 |
subreq = sdap_search_bases_return_first_send(state, ev,
|
|
|
5fca41 |
sd_ctx->sdap_id_ctx->opts, sh,
|
|
|
5fca41 |
sd_ctx->master_search_bases, NULL, false,
|
|
|
5fca41 |
- 0, MASTER_DOMAIN_FILTER, attrs);
|
|
|
5fca41 |
+ 0, MASTER_DOMAIN_FILTER, attrs, NULL);
|
|
|
5fca41 |
if (subreq == NULL) {
|
|
|
5fca41 |
ret = ENOMEM;
|
|
|
5fca41 |
goto immediately;
|
|
|
5fca41 |
@@ -1397,7 +1397,7 @@ ipa_subdomains_slave_send(TALLOC_CTX *mem_ctx,
|
|
|
5fca41 |
|
|
|
5fca41 |
subreq = sdap_search_bases_send(state, ev, sd_ctx->sdap_id_ctx->opts, sh,
|
|
|
5fca41 |
sd_ctx->search_bases, NULL, false,
|
|
|
5fca41 |
- 0, SUBDOMAINS_FILTER, attrs);
|
|
|
5fca41 |
+ 0, SUBDOMAINS_FILTER, attrs, NULL);
|
|
|
5fca41 |
if (subreq == NULL) {
|
|
|
5fca41 |
ret = ENOMEM;
|
|
|
5fca41 |
goto immediately;
|
|
|
5fca41 |
diff --git a/src/providers/ipa/ipa_subdomains_ext_groups.c b/src/providers/ipa/ipa_subdomains_ext_groups.c
|
|
|
5fca41 |
index 75963bef1..cd80048b3 100644
|
|
|
5fca41 |
--- a/src/providers/ipa/ipa_subdomains_ext_groups.c
|
|
|
5fca41 |
+++ b/src/providers/ipa/ipa_subdomains_ext_groups.c
|
|
|
5fca41 |
@@ -545,7 +545,7 @@ static void ipa_get_ad_memberships_connect_done(struct tevent_req *subreq)
|
|
|
5fca41 |
dp_opt_get_int(state->sdap_id_ctx->opts->basic,
|
|
|
5fca41 |
SDAP_ENUM_SEARCH_TIMEOUT),
|
|
|
5fca41 |
IPA_EXT_GROUPS_FILTER,
|
|
|
5fca41 |
- NULL);
|
|
|
5fca41 |
+ NULL, NULL);
|
|
|
5fca41 |
if (subreq == NULL) {
|
|
|
5fca41 |
DEBUG(SSSDBG_OP_FAILURE, "sdap_get_generic_send failed.\n");
|
|
|
5fca41 |
ret = ENOMEM;
|
|
|
5fca41 |
diff --git a/src/providers/ipa/ipa_sudo_async.c b/src/providers/ipa/ipa_sudo_async.c
|
|
|
5fca41 |
index 060687c77..19bcd94c9 100644
|
|
|
5fca41 |
--- a/src/providers/ipa/ipa_sudo_async.c
|
|
|
5fca41 |
+++ b/src/providers/ipa/ipa_sudo_async.c
|
|
|
5fca41 |
@@ -492,7 +492,7 @@ ipa_sudo_fetch_addtl_cmdgroups(struct tevent_req *req)
|
|
|
5fca41 |
|
|
|
5fca41 |
subreq = sdap_search_bases_send(state, state->ev, state->sdap_opts,
|
|
|
5fca41 |
state->sh, state->sudo_sb, map, true, 0,
|
|
|
5fca41 |
- filter, NULL);
|
|
|
5fca41 |
+ filter, NULL, NULL);
|
|
|
5fca41 |
if (subreq == NULL) {
|
|
|
5fca41 |
return ENOMEM;
|
|
|
5fca41 |
}
|
|
|
5fca41 |
@@ -582,7 +582,7 @@ ipa_sudo_fetch_rules(struct tevent_req *req)
|
|
|
5fca41 |
|
|
|
5fca41 |
subreq = sdap_search_bases_send(state, state->ev, state->sdap_opts,
|
|
|
5fca41 |
state->sh, state->sudo_sb, map, true, 0,
|
|
|
5fca41 |
- filter, NULL);
|
|
|
5fca41 |
+ filter, NULL, NULL);
|
|
|
5fca41 |
if (subreq == NULL) {
|
|
|
5fca41 |
return ENOMEM;
|
|
|
5fca41 |
}
|
|
|
5fca41 |
@@ -662,7 +662,7 @@ ipa_sudo_fetch_cmdgroups(struct tevent_req *req)
|
|
|
5fca41 |
subreq = sdap_search_bases_send(state, state->ev, state->sdap_opts,
|
|
|
5fca41 |
state->sh, state->sudo_sb,
|
|
|
5fca41 |
state->map_cmdgroup, true, 0,
|
|
|
5fca41 |
- filter, NULL);
|
|
|
5fca41 |
+ filter, NULL, NULL);
|
|
|
5fca41 |
if (subreq == NULL) {
|
|
|
5fca41 |
return ENOMEM;
|
|
|
5fca41 |
}
|
|
|
5fca41 |
@@ -742,7 +742,7 @@ ipa_sudo_fetch_cmds(struct tevent_req *req)
|
|
|
5fca41 |
subreq = sdap_search_bases_send(state, state->ev, state->sdap_opts,
|
|
|
5fca41 |
state->sh, state->sudo_sb,
|
|
|
5fca41 |
state->map_cmd, true, 0,
|
|
|
5fca41 |
- filter, NULL);
|
|
|
5fca41 |
+ filter, NULL, NULL);
|
|
|
5fca41 |
if (subreq == NULL) {
|
|
|
5fca41 |
return ENOMEM;
|
|
|
5fca41 |
}
|
|
|
5fca41 |
diff --git a/src/providers/ldap/sdap_async_sudo.c b/src/providers/ldap/sdap_async_sudo.c
|
|
|
5fca41 |
index 5ccfad61f..c19ee87c2 100644
|
|
|
5fca41 |
--- a/src/providers/ldap/sdap_async_sudo.c
|
|
|
5fca41 |
+++ b/src/providers/ldap/sdap_async_sudo.c
|
|
|
5fca41 |
@@ -75,7 +75,7 @@ sdap_sudo_load_sudoers_send(TALLOC_CTX *mem_ctx,
|
|
|
5fca41 |
|
|
|
5fca41 |
subreq = sdap_search_bases_send(state, ev, opts, sh, sb,
|
|
|
5fca41 |
opts->sudorule_map, true, 0,
|
|
|
5fca41 |
- ldap_filter, NULL);
|
|
|
5fca41 |
+ ldap_filter, NULL, NULL);
|
|
|
5fca41 |
if (subreq == NULL) {
|
|
|
5fca41 |
ret = ENOMEM;
|
|
|
5fca41 |
goto immediately;
|
|
|
5fca41 |
diff --git a/src/providers/ldap/sdap_ops.c b/src/providers/ldap/sdap_ops.c
|
|
|
5fca41 |
index a90857469..2125b21aa 100644
|
|
|
5fca41 |
--- a/src/providers/ldap/sdap_ops.c
|
|
|
5fca41 |
+++ b/src/providers/ldap/sdap_ops.c
|
|
|
5fca41 |
@@ -37,6 +37,7 @@ struct sdap_search_bases_ex_state {
|
|
|
5fca41 |
int timeout;
|
|
|
5fca41 |
bool allow_paging;
|
|
|
5fca41 |
bool return_first_reply;
|
|
|
5fca41 |
+ const char *base_dn;
|
|
|
5fca41 |
|
|
|
5fca41 |
size_t base_iter;
|
|
|
5fca41 |
struct sdap_search_base *cur_base;
|
|
|
5fca41 |
@@ -60,7 +61,8 @@ sdap_search_bases_ex_send(TALLOC_CTX *mem_ctx,
|
|
|
5fca41 |
bool return_first_reply,
|
|
|
5fca41 |
int timeout,
|
|
|
5fca41 |
const char *filter,
|
|
|
5fca41 |
- const char **attrs)
|
|
|
5fca41 |
+ const char **attrs,
|
|
|
5fca41 |
+ const char *base_dn)
|
|
|
5fca41 |
{
|
|
|
5fca41 |
struct tevent_req *req;
|
|
|
5fca41 |
struct sdap_search_bases_ex_state *state;
|
|
|
5fca41 |
@@ -86,6 +88,7 @@ sdap_search_bases_ex_send(TALLOC_CTX *mem_ctx,
|
|
|
5fca41 |
state->attrs = attrs;
|
|
|
5fca41 |
state->allow_paging = allow_paging;
|
|
|
5fca41 |
state->return_first_reply = return_first_reply;
|
|
|
5fca41 |
+ state->base_dn = base_dn;
|
|
|
5fca41 |
|
|
|
5fca41 |
state->timeout = timeout == 0
|
|
|
5fca41 |
? dp_opt_get_int(opts->basic, SDAP_SEARCH_TIMEOUT)
|
|
|
5fca41 |
@@ -133,6 +136,7 @@ static errno_t sdap_search_bases_ex_next_base(struct tevent_req *req)
|
|
|
5fca41 |
{
|
|
|
5fca41 |
struct sdap_search_bases_ex_state *state;
|
|
|
5fca41 |
struct tevent_req *subreq;
|
|
|
5fca41 |
+ const char *base_dn;
|
|
|
5fca41 |
char *filter;
|
|
|
5fca41 |
|
|
|
5fca41 |
state = tevent_req_data(req, struct sdap_search_bases_ex_state);
|
|
|
5fca41 |
@@ -148,12 +152,12 @@ static errno_t sdap_search_bases_ex_next_base(struct tevent_req *req)
|
|
|
5fca41 |
return ENOMEM;
|
|
|
5fca41 |
}
|
|
|
5fca41 |
|
|
|
5fca41 |
- DEBUG(SSSDBG_TRACE_FUNC, "Issuing LDAP lookup with base [%s]\n",
|
|
|
5fca41 |
- state->cur_base->basedn);
|
|
|
5fca41 |
+ base_dn = state->base_dn != NULL ? state->base_dn : state->cur_base->basedn;
|
|
|
5fca41 |
+
|
|
|
5fca41 |
+ DEBUG(SSSDBG_TRACE_FUNC, "Issuing LDAP lookup with base [%s]\n", base_dn);
|
|
|
5fca41 |
|
|
|
5fca41 |
subreq = sdap_get_generic_send(state, state->ev, state->opts, state->sh,
|
|
|
5fca41 |
- state->cur_base->basedn,
|
|
|
5fca41 |
- state->cur_base->scope, filter,
|
|
|
5fca41 |
+ base_dn, state->cur_base->scope, filter,
|
|
|
5fca41 |
state->attrs, state->map,
|
|
|
5fca41 |
state->map_num_attrs, state->timeout,
|
|
|
5fca41 |
state->allow_paging);
|
|
|
5fca41 |
@@ -253,11 +257,12 @@ sdap_search_bases_send(TALLOC_CTX *mem_ctx,
|
|
|
5fca41 |
bool allow_paging,
|
|
|
5fca41 |
int timeout,
|
|
|
5fca41 |
const char *filter,
|
|
|
5fca41 |
- const char **attrs)
|
|
|
5fca41 |
+ const char **attrs,
|
|
|
5fca41 |
+ const char *base_dn)
|
|
|
5fca41 |
{
|
|
|
5fca41 |
return sdap_search_bases_ex_send(mem_ctx, ev, opts, sh, bases, map,
|
|
|
5fca41 |
allow_paging, false, timeout,
|
|
|
5fca41 |
- filter, attrs);
|
|
|
5fca41 |
+ filter, attrs, base_dn);
|
|
|
5fca41 |
}
|
|
|
5fca41 |
|
|
|
5fca41 |
int sdap_search_bases_recv(struct tevent_req *req,
|
|
|
5fca41 |
@@ -278,11 +283,12 @@ sdap_search_bases_return_first_send(TALLOC_CTX *mem_ctx,
|
|
|
5fca41 |
bool allow_paging,
|
|
|
5fca41 |
int timeout,
|
|
|
5fca41 |
const char *filter,
|
|
|
5fca41 |
- const char **attrs)
|
|
|
5fca41 |
+ const char **attrs,
|
|
|
5fca41 |
+ const char *base_dn)
|
|
|
5fca41 |
{
|
|
|
5fca41 |
return sdap_search_bases_ex_send(mem_ctx, ev, opts, sh, bases, map,
|
|
|
5fca41 |
allow_paging, true, timeout,
|
|
|
5fca41 |
- filter, attrs);
|
|
|
5fca41 |
+ filter, attrs, base_dn);
|
|
|
5fca41 |
}
|
|
|
5fca41 |
|
|
|
5fca41 |
int sdap_search_bases_return_first_recv(struct tevent_req *req,
|
|
|
5fca41 |
diff --git a/src/providers/ldap/sdap_ops.h b/src/providers/ldap/sdap_ops.h
|
|
|
5fca41 |
index cc9de00d2..648a2b68c 100644
|
|
|
5fca41 |
--- a/src/providers/ldap/sdap_ops.h
|
|
|
5fca41 |
+++ b/src/providers/ldap/sdap_ops.h
|
|
|
5fca41 |
@@ -34,7 +34,8 @@ struct tevent_req *sdap_search_bases_send(TALLOC_CTX *mem_ctx,
|
|
|
5fca41 |
bool allow_paging,
|
|
|
5fca41 |
int timeout,
|
|
|
5fca41 |
const char *filter,
|
|
|
5fca41 |
- const char **attrs);
|
|
|
5fca41 |
+ const char **attrs,
|
|
|
5fca41 |
+ const char *base_dn);
|
|
|
5fca41 |
|
|
|
5fca41 |
int sdap_search_bases_recv(struct tevent_req *req,
|
|
|
5fca41 |
TALLOC_CTX *mem_ctx,
|
|
|
5fca41 |
@@ -51,7 +52,8 @@ sdap_search_bases_return_first_send(TALLOC_CTX *mem_ctx,
|
|
|
5fca41 |
bool allow_paging,
|
|
|
5fca41 |
int timeout,
|
|
|
5fca41 |
const char *filter,
|
|
|
5fca41 |
- const char **attrs);
|
|
|
5fca41 |
+ const char **attrs,
|
|
|
5fca41 |
+ const char *base_dn);
|
|
|
5fca41 |
|
|
|
5fca41 |
int sdap_search_bases_return_first_recv(struct tevent_req *req,
|
|
|
5fca41 |
TALLOC_CTX *mem_ctx,
|
|
|
5fca41 |
--
|
|
|
5fca41 |
2.20.1
|
|
|
5fca41 |
|