diff options
-rw-r--r-- | src/providers/ipa/ipa_id.h | 4 | ||||
-rw-r--r-- | src/providers/ipa/ipa_s2n_exop.c | 31 | ||||
-rw-r--r-- | src/providers/ipa/ipa_subdomains.h | 14 | ||||
-rw-r--r-- | src/providers/ipa/ipa_subdomains_id.c | 25 |
4 files changed, 48 insertions, 26 deletions
diff --git a/src/providers/ipa/ipa_id.h b/src/providers/ipa/ipa_id.h index e4464062..7fa25e92 100644 --- a/src/providers/ipa/ipa_id.h +++ b/src/providers/ipa/ipa_id.h @@ -29,6 +29,7 @@ #include "providers/ldap/ldap_common.h" #include "providers/ipa/ipa_common.h" #include "providers/ldap/sdap.h" +#include "providers/ipa/ipa_subdomains.h" void ipa_account_info_handler(struct be_req *breq); struct tevent_req *ipa_get_netgroups_send(TALLOC_CTX *memctx, @@ -55,8 +56,7 @@ struct tevent_req *ipa_s2n_get_acct_info_send(TALLOC_CTX *mem_ctx, struct sss_domain_info *dom, struct sdap_handle *sh, int entry_type, - const char *user_name, - uid_t uid); + struct req_input *req_input); int ipa_s2n_get_acct_info_recv(struct tevent_req *req); struct tevent_req *ipa_get_subdom_acct_send(TALLOC_CTX *memctx, diff --git a/src/providers/ipa/ipa_s2n_exop.c b/src/providers/ipa/ipa_s2n_exop.c index 9421c865..c668598a 100644 --- a/src/providers/ipa/ipa_s2n_exop.c +++ b/src/providers/ipa/ipa_s2n_exop.c @@ -24,6 +24,7 @@ #include "db/sysdb.h" #include "providers/ldap/sdap_async_private.h" #include "providers/ldap/ldap_common.h" +#include "providers/ipa/ipa_subdomains.h" enum input_types { INP_SID = 1, @@ -279,8 +280,7 @@ done: static errno_t s2n_encode_request(TALLOC_CTX *mem_ctx, const char *domain_name, int entry_type, - const char *name, - uint32_t id, + struct req_input *req_input, struct berval **_bv) { BerElement *ber = NULL; @@ -293,21 +293,25 @@ static errno_t s2n_encode_request(TALLOC_CTX *mem_ctx, switch (entry_type) { case BE_REQ_USER: - if (name != NULL) { + if (req_input->type == REQ_INP_NAME) { ret = ber_printf(ber, "{ee{ss}}", INP_NAME, REQ_FULL, - domain_name, name); + domain_name, + req_input->inp.name); } else { ret = ber_printf(ber, "{ee{si}}", INP_POSIX_UID, REQ_FULL, - domain_name, id); + domain_name, + req_input->inp.id); } break; case BE_REQ_GROUP: - if (name != NULL) { + if (req_input->type == REQ_INP_NAME) { ret = ber_printf(ber, "{ee{ss}}", INP_NAME, REQ_FULL, - domain_name, name); + domain_name, + req_input->inp.name); } else { ret = ber_printf(ber, "{ee{si}}", INP_POSIX_GID, REQ_FULL, - domain_name, id); + domain_name, + req_input->inp.id); } break; default: @@ -521,8 +525,7 @@ struct tevent_req *ipa_s2n_get_acct_info_send(TALLOC_CTX *mem_ctx, struct sss_domain_info *dom, struct sdap_handle *sh, int entry_type, - const char *name, - uint32_t id) + struct req_input *req_input) { struct ipa_s2n_get_user_state *state; struct tevent_req *req; @@ -530,12 +533,6 @@ struct tevent_req *ipa_s2n_get_acct_info_send(TALLOC_CTX *mem_ctx, struct berval *bv_req = NULL; int ret = EFAULT; - if ((name == NULL && id == 0) || (name != NULL && id != 0)) { - DEBUG(SSSDBG_OP_FAILURE, ("Either a user name or a uid expected, " - "not both or nothing.\n")); - return NULL; - } - req = tevent_req_create(mem_ctx, &state, struct ipa_s2n_get_user_state); if (req == NULL) { return NULL; @@ -546,7 +543,7 @@ struct tevent_req *ipa_s2n_get_acct_info_send(TALLOC_CTX *mem_ctx, state->dom = dom; state->sh = sh; - ret = s2n_encode_request(state, dom->name, entry_type, name, id, &bv_req); + ret = s2n_encode_request(state, dom->name, entry_type, req_input, &bv_req); if (ret != EOK) { goto fail; } diff --git a/src/providers/ipa/ipa_subdomains.h b/src/providers/ipa/ipa_subdomains.h index df7f994d..c9ab82a2 100644 --- a/src/providers/ipa/ipa_subdomains.h +++ b/src/providers/ipa/ipa_subdomains.h @@ -38,4 +38,18 @@ int ipa_subdom_init(struct be_ctx *be_ctx, struct bet_ops **ops, void **pvt_data); +enum req_input_type { + REQ_INP_NAME, + REQ_INP_ID, + REQ_INP_SECID +}; + +struct req_input { + enum req_input_type type; + union { + const char *name; + uint32_t id; + const char *secid; + } inp; +}; #endif /* _IPA_SUBDOMAINS_H_ */ diff --git a/src/providers/ipa/ipa_subdomains_id.c b/src/providers/ipa/ipa_subdomains_id.c index 9c4187b6..06194837 100644 --- a/src/providers/ipa/ipa_subdomains_id.c +++ b/src/providers/ipa/ipa_subdomains_id.c @@ -128,9 +128,8 @@ static void ipa_get_subdom_acct_connected(struct tevent_req *subreq) struct ipa_get_subdom_acct); int dp_error = DP_ERR_FATAL; int ret; - const char *name; - uint32_t id; char *endptr; + struct req_input *req_input; ret = sdap_id_op_connect_recv(subreq, &dp_error); talloc_zfree(subreq); @@ -140,14 +139,26 @@ static void ipa_get_subdom_acct_connected(struct tevent_req *subreq) return; } + req_input = talloc(state, struct req_input); + if (req_input == NULL) { + DEBUG(SSSDBG_OP_FAILURE, ("talloc failed.\n")); + tevent_req_error(req, ENOMEM); + return; + } + switch (state->filter_type) { case BE_FILTER_NAME: - name = state->filter; - id = 0; + req_input->type = REQ_INP_NAME; + req_input->inp.name = talloc_strdup(req_input, state->filter); + if (req_input->inp.name == NULL) { + DEBUG(SSSDBG_OP_FAILURE, ("talloc_strdup failed.\n")); + tevent_req_error(req, ENOMEM); + return; + } break; case BE_FILTER_IDNUM: - name = NULL; - id = strtouint32(state->filter, &endptr, 10); + req_input->type = REQ_INP_ID; + req_input->inp.id = strtouint32(state->filter, &endptr, 10); if (errno || *endptr || (state->filter == endptr)) { tevent_req_error(req, errno ? errno : EINVAL); return; @@ -166,7 +177,7 @@ static void ipa_get_subdom_acct_connected(struct tevent_req *subreq) state->domain, sdap_id_op_handle(state->op), state->entry_type, - name, id); + req_input); if (!subreq) { tevent_req_error(req, ENOMEM); return; |