ipa_subdomains_id.c revision ed4a9bd4d0f7fb359bed66a8d63a92e7be633aae
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina IPA Identity Backend Module for sub-domains
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina Sumit Bose <sbose@redhat.com>
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina Copyright (C) 2012 Red Hat
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina This program is free software; you can redistribute it and/or modify
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina it under the terms of the GNU General Public License as published by
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina the Free Software Foundation; either version 3 of the License, or
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina (at your option) any later version.
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina This program is distributed in the hope that it will be useful,
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina but WITHOUT ANY WARRANTY; without even the implied warranty of
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina GNU General Public License for more details.
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina You should have received a copy of the GNU General Public License
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina along with this program. If not, see <http://www.gnu.org/licenses/>.
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březinastatic void ipa_subdomain_account_connected(struct tevent_req *subreq);
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březinastatic void ipa_subdomain_account_got_override(struct tevent_req *subreq);
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březinastatic void ipa_subdomain_account_done(struct tevent_req *subreq);
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březinastatic errno_t ipa_subdomain_account_get_original_step(struct tevent_req *req,
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březinastruct tevent_req *ipa_subdomain_account_send(TALLOC_CTX *memctx,
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina req = tevent_req_create(memctx, &state, struct ipa_subdomain_account_state);
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "tevent_req_create failed.\n");
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina state->op = sdap_id_op_create(state, state->ctx->conn->conn_cache);
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "sdap_id_op_create failed\n");
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina state->domain = find_domain_by_name(state->ctx->be->domain,
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "find_domain_by_name failed.\n");
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina state->ipa_server_mode = dp_opt_get_bool(state->ipa_ctx->ipa_options->basic,
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina /* With views we cannot got directly to the look up the AD objects but
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina * have to check first if the request matches an override in the given
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina * view. But there are cases where this can be skipped and the AD object
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina * can be searched directly:
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina * - searches by SID: because we do not override the SID
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina * - if the responder does not send the EXTRA_INPUT_MAYBE_WITH_VIEW flags,
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina * because in this case the entry was found in the cache and the
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina * original value is used for the search (e.g. during cache updates) */
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina ret = ipa_subdomain_account_get_original_step(req, state->ar);
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina "ipa_subdomain_account_get_original_step failed.\n");
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina subreq = sdap_id_op_connect_send(state->op, state, &ret);
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina tevent_req_set_callback(subreq, ipa_subdomain_account_connected, req);
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březinastatic void ipa_subdomain_account_connected(struct tevent_req *subreq)
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina struct tevent_req *req = tevent_req_callback_data(subreq,
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina struct ipa_subdomain_account_state *state = tevent_req_data(req,
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina ret = sdap_id_op_connect_recv(subreq, &dp_error);
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "sdap_id_op_connect request failed.\n");
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina subreq = ipa_get_ad_override_send(state, state->ev, state->ctx,
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina dp_opt_get_string(state->ipa_ctx->ipa_options->basic,
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "ipa_get_ad_override_send failed.\n");
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina tevent_req_set_callback(subreq, ipa_subdomain_account_got_override, req);
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina#define OVERRIDE_ANCHOR_SID_PREFIX_LEN (sizeof(OVERRIDE_ANCHOR_SID_PREFIX) -1 )
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březinastatic void ipa_subdomain_account_got_override(struct tevent_req *subreq)
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina struct tevent_req *req = tevent_req_callback_data(subreq,
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina struct ipa_subdomain_account_state *state = tevent_req_data(req,
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina ret = ipa_get_ad_override_recv(subreq, &dp_error, state,
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "IPA override lookup failed: %d\n", ret);
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina ret = sysdb_attrs_get_string(state->override_attrs,
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "sysdb_attrs_get_string failed.\n");
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina if (anchor != NULL && strncmp(OVERRIDE_ANCHOR_SID_PREFIX, anchor,
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "get_be_acct_req_for_sid failed.\n");
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina "Unsupported override anchor type [%s].\n", anchor);
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina ret = ipa_subdomain_account_get_original_step(req, ar);
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina "ipa_subdomain_account_get_original_step failed.\n");
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březinastatic errno_t ipa_subdomain_account_get_original_step(struct tevent_req *req,
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina struct ipa_subdomain_account_state *state = tevent_req_data(req,
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina subreq = ipa_get_ad_acct_send(state, state->ev, state->ipa_ctx,
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina subreq = ipa_get_subdom_acct_send(state, state->ev, state->ipa_ctx,
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "ipa_get_*_acct_send failed.\n");
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina tevent_req_set_callback(subreq, ipa_subdomain_account_done, req);
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březinastatic void ipa_subdomain_account_done(struct tevent_req *subreq)
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina struct tevent_req *req = tevent_req_callback_data(subreq,
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina struct ipa_subdomain_account_state *state = tevent_req_data(req,
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina ret = ipa_get_ad_acct_recv(subreq, &dp_error);
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina ret = ipa_get_subdom_acct_recv(subreq, &dp_error);
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "ipa_get_*_acct request failed: %d\n", ret);
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březinaerrno_t ipa_subdomain_account_recv(struct tevent_req *req, int *dp_error_out)
a76f63544533f0404f7711a10c1a621c6045df17Pavel Březina struct ipa_subdomain_account_state *state = tevent_req_data(req,
return EOK;
struct ipa_get_subdom_acct {
int entry_type;
const char *filter;
int filter_type;
int dp_error;
int ret;
goto fail;
goto fail;
case BE_REQ_USER:
case BE_REQ_GROUP:
case BE_REQ_BY_SECID:
case BE_REQ_USER_AND_GROUP:
case BE_REQ_INITGROUPS:
if (!subreq) {
goto fail;
return req;
fail:
return req;
struct tevent_req);
struct ipa_get_subdom_acct);
int ret;
char *endptr;
case BE_FILTER_NAME:
case BE_FILTER_IDNUM:
case BE_FILTER_SECID:
if (!subreq) {
struct tevent_req);
struct ipa_get_subdom_acct);
int ret;
if (!subreq) {
struct ipa_get_subdom_acct);
if (dp_error_out) {
return EOK;
struct ipa_get_ad_acct_state {
int dp_error;
char *object_sid;
struct tevent_req *
goto fail;
goto fail;
case BE_REQ_INITGROUPS:
case BE_REQ_GROUP:
goto fail;
goto fail;
goto fail;
goto fail;
return req;
fail:
return req;
static struct ad_id_ctx *
static errno_t
const char **_homedir)
const char *name;
const char *homedir;
goto done;
goto done;
goto done;
&homedir_ctx);
goto done;
goto done;
done:
return ret;
static errno_t
bool in_transaction = false;
goto done;
goto done;
goto done;
goto done;
in_transaction = true;
goto done;
goto done;
in_transaction = false;
done:
if (in_transaction) {
return ret;
static errno_t
const char *fqname;
size_t c;
goto done;
goto done;
goto done;
if (uid == 0) {
fqname);
goto done;
goto done;
goto done;
done:
return ret;
NULL };
char *name;
&res);
goto done;
goto done;
errno = 0;
if (errno != 0) {
goto done;
case BE_REQ_GROUP:
case BE_REQ_INITGROUPS:
case BE_REQ_USER:
case BE_REQ_USER_AND_GROUP:
== BE_REQ_USER_AND_GROUP) {
goto done;
goto done;
case BE_REQ_GROUP:
case BE_REQ_INITGROUPS:
case BE_REQ_USER:
case BE_REQ_USER_AND_GROUP:
== BE_REQ_USER_AND_GROUP) {
goto done;
goto done;
goto done;
done:
return ret;
struct tevent_req);
struct ipa_get_ad_acct_state);
const char *sid;
goto fail;
goto fail;
goto fail;
goto fail;
goto fail;
ar);
goto fail;
goto fail;
fail:
struct tevent_req);
struct ipa_get_ad_acct_state);
goto fail;
fail:
struct ipa_get_ad_acct_state);
return ret;
return EOK;
return ENOMEM;
return EOK;
struct tevent_req);
struct ipa_get_ad_acct_state);
ret);
struct ipa_get_ad_acct_state);
if (dp_error_out) {
return EOK;