diff options
author | Sumit Bose <sbose@redhat.com> | 2013-04-24 10:49:22 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2013-05-02 19:33:56 +0200 |
commit | 2962b3d1e072ff2ebbe343095812dad697d6bf1d (patch) | |
tree | b3f6752176c99221fee6585596c613ad002a9da9 /src/providers/ipa/ipa_subdomains_id.c | |
parent | 44c379a27a2d8de0ad933ebb2558b5e82b05fd56 (diff) | |
download | sssd-2962b3d1e072ff2ebbe343095812dad697d6bf1d.tar.gz sssd-2962b3d1e072ff2ebbe343095812dad697d6bf1d.tar.xz sssd-2962b3d1e072ff2ebbe343095812dad697d6bf1d.zip |
Use struct to hold different types of request parameters
Currently the POSIX ID or the user name are passed in different
parameters to some calls. The method will get cumbersome and error-prone
if new parameters like, e.g. the SID, are added. This patch adds a union
to hold the different kind of parameters.
Diffstat (limited to 'src/providers/ipa/ipa_subdomains_id.c')
-rw-r--r-- | src/providers/ipa/ipa_subdomains_id.c | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/providers/ipa/ipa_subdomains_id.c b/src/providers/ipa/ipa_subdomains_id.c index 9c4187b64..061948376 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; |