|
|
905b4d |
From 2dfd383413d1c5bfc031f8396eccd1108c899e68 Mon Sep 17 00:00:00 2001
|
|
|
905b4d |
From: Sumit Bose <sbose@redhat.com>
|
|
|
905b4d |
Date: Wed, 5 Nov 2014 15:58:04 +0100
|
|
|
905b4d |
Subject: [PATCH 101/104] IPA: check overrrides for IPA users as well
|
|
|
905b4d |
|
|
|
905b4d |
Currently overrides were only available for sub-domains, e.g. trusted AD
|
|
|
905b4d |
domains. With this patch overrides can be used for IPA users as well.
|
|
|
905b4d |
|
|
|
905b4d |
Related to https://fedorahosted.org/sssd/ticket/2481
|
|
|
905b4d |
|
|
|
905b4d |
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
905b4d |
---
|
|
|
905b4d |
src/providers/ipa/ipa_id.c | 405 +++++++++++++++++++++++++++++++++-
|
|
|
905b4d |
src/providers/ipa/ipa_subdomains_id.c | 16 +-
|
|
|
905b4d |
src/providers/ipa/ipa_views.c | 15 ++
|
|
|
905b4d |
3 files changed, 432 insertions(+), 4 deletions(-)
|
|
|
905b4d |
|
|
|
905b4d |
diff --git a/src/providers/ipa/ipa_id.c b/src/providers/ipa/ipa_id.c
|
|
|
905b4d |
index cd65f5b462c102ed502a014789a7232a93389b68..5665a1835e8b0ab18325bfc68a8d8b5650730943 100644
|
|
|
905b4d |
--- a/src/providers/ipa/ipa_id.c
|
|
|
905b4d |
+++ b/src/providers/ipa/ipa_id.c
|
|
|
905b4d |
@@ -56,6 +56,13 @@ static const char *ipa_account_info_error_text(int ret, int *dp_error,
|
|
|
905b4d |
return default_text;
|
|
|
905b4d |
}
|
|
|
905b4d |
|
|
|
905b4d |
+static struct tevent_req *
|
|
|
905b4d |
+ipa_id_get_account_info_send(TALLOC_CTX *memctx, struct tevent_context *ev,
|
|
|
905b4d |
+ struct ipa_id_ctx *ipa_ctx, struct be_req *be_req,
|
|
|
905b4d |
+ struct be_acct_req *ar);
|
|
|
905b4d |
+
|
|
|
905b4d |
+static int ipa_id_get_account_info_recv(struct tevent_req *req, int *dp_error);
|
|
|
905b4d |
+
|
|
|
905b4d |
static struct tevent_req *ipa_id_get_netgroup_send(TALLOC_CTX *memctx,
|
|
|
905b4d |
struct tevent_context *ev,
|
|
|
905b4d |
struct ipa_id_ctx *ipa_ctx,
|
|
|
905b4d |
@@ -100,7 +107,9 @@ void ipa_account_info_handler(struct be_req *breq)
|
|
|
905b4d |
} else {
|
|
|
905b4d |
/* any account request is handled by sdap,
|
|
|
905b4d |
* any invalid request is caught there. */
|
|
|
905b4d |
- return sdap_handle_account_info(breq, ctx, ctx->conn);
|
|
|
905b4d |
+
|
|
|
905b4d |
+ req = ipa_id_get_account_info_send(breq, be_ctx->ev, ipa_ctx, breq,
|
|
|
905b4d |
+ ar);
|
|
|
905b4d |
}
|
|
|
905b4d |
|
|
|
905b4d |
if (!req) {
|
|
|
905b4d |
@@ -115,13 +124,18 @@ static void ipa_account_info_done(struct tevent_req *req)
|
|
|
905b4d |
struct be_req *breq = tevent_req_callback_data(req, struct be_req);
|
|
|
905b4d |
struct be_acct_req *ar = talloc_get_type(be_req_get_data(breq),
|
|
|
905b4d |
struct be_acct_req);
|
|
|
905b4d |
+ struct be_ctx *be_ctx = be_req_get_be_ctx(breq);
|
|
|
905b4d |
const char *error_text;
|
|
|
905b4d |
int ret, dp_error;
|
|
|
905b4d |
|
|
|
905b4d |
if ((ar->entry_type & BE_REQ_TYPE_MASK) == BE_REQ_NETGROUP) {
|
|
|
905b4d |
ret = ipa_id_get_netgroup_recv(req, &dp_error);
|
|
|
905b4d |
} else {
|
|
|
905b4d |
- ret = ipa_subdomain_account_recv(req, &dp_error);
|
|
|
905b4d |
+ if (strcasecmp(ar->domain, be_ctx->domain->name) != 0) {
|
|
|
905b4d |
+ ret = ipa_subdomain_account_recv(req, &dp_error);
|
|
|
905b4d |
+ } else {
|
|
|
905b4d |
+ ret = ipa_id_get_account_info_recv(req, &dp_error);
|
|
|
905b4d |
+ }
|
|
|
905b4d |
}
|
|
|
905b4d |
talloc_zfree(req);
|
|
|
905b4d |
|
|
|
905b4d |
@@ -130,6 +144,393 @@ static void ipa_account_info_done(struct tevent_req *req)
|
|
|
905b4d |
sdap_handler_done(breq, dp_error, ret, error_text);
|
|
|
905b4d |
}
|
|
|
905b4d |
|
|
|
905b4d |
+struct ipa_id_get_account_info_state {
|
|
|
905b4d |
+ struct tevent_context *ev;
|
|
|
905b4d |
+ struct ipa_id_ctx *ipa_ctx;
|
|
|
905b4d |
+ struct sdap_id_ctx *ctx;
|
|
|
905b4d |
+ struct sdap_id_op *op;
|
|
|
905b4d |
+ struct sysdb_ctx *sysdb;
|
|
|
905b4d |
+ struct sss_domain_info *domain;
|
|
|
905b4d |
+ struct be_req *be_req;
|
|
|
905b4d |
+ struct be_acct_req *ar;
|
|
|
905b4d |
+ const char *realm;
|
|
|
905b4d |
+
|
|
|
905b4d |
+ struct sysdb_attrs *override_attrs;
|
|
|
905b4d |
+ struct ldb_message *obj_msg;
|
|
|
905b4d |
+ int dp_error;
|
|
|
905b4d |
+};
|
|
|
905b4d |
+
|
|
|
905b4d |
+static void ipa_id_get_account_info_connected(struct tevent_req *subreq);
|
|
|
905b4d |
+static void ipa_id_get_account_info_got_override(struct tevent_req *subreq);
|
|
|
905b4d |
+static errno_t ipa_id_get_account_info_get_original_step(struct tevent_req *req,
|
|
|
905b4d |
+ struct be_acct_req *ar);
|
|
|
905b4d |
+static void ipa_id_get_account_info_orig_done(struct tevent_req *subreq);
|
|
|
905b4d |
+static void ipa_id_get_account_info_done(struct tevent_req *subreq);
|
|
|
905b4d |
+
|
|
|
905b4d |
+static struct tevent_req *
|
|
|
905b4d |
+ipa_id_get_account_info_send(TALLOC_CTX *memctx, struct tevent_context *ev,
|
|
|
905b4d |
+ struct ipa_id_ctx *ipa_ctx, struct be_req *be_req,
|
|
|
905b4d |
+ struct be_acct_req *ar)
|
|
|
905b4d |
+{
|
|
|
905b4d |
+ int ret;
|
|
|
905b4d |
+ struct tevent_req *req;
|
|
|
905b4d |
+ struct tevent_req *subreq;
|
|
|
905b4d |
+ struct ipa_id_get_account_info_state *state;
|
|
|
905b4d |
+
|
|
|
905b4d |
+ req = tevent_req_create(memctx, &state,
|
|
|
905b4d |
+ struct ipa_id_get_account_info_state);
|
|
|
905b4d |
+ if (req == NULL) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE, "tevent_req_create failed.\n");
|
|
|
905b4d |
+ return NULL;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ state->ev = ev;
|
|
|
905b4d |
+ state->ipa_ctx = ipa_ctx;
|
|
|
905b4d |
+ state->ctx = ipa_ctx->sdap_id_ctx;
|
|
|
905b4d |
+ state->dp_error = DP_ERR_FATAL;
|
|
|
905b4d |
+
|
|
|
905b4d |
+ state->op = sdap_id_op_create(state, state->ctx->conn->conn_cache);
|
|
|
905b4d |
+ if (state->op == NULL) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE, "sdap_id_op_create failed.\n");
|
|
|
905b4d |
+ ret = ENOMEM;
|
|
|
905b4d |
+ goto fail;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ state->domain = find_domain_by_name(state->ctx->be->domain,
|
|
|
905b4d |
+ ar->domain, true);
|
|
|
905b4d |
+ if (state->domain == NULL) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE, "find_domain_by_name failed.\n");
|
|
|
905b4d |
+ ret = ENOMEM;
|
|
|
905b4d |
+ goto fail;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+ state->sysdb = state->domain->sysdb;
|
|
|
905b4d |
+ state->be_req = be_req;
|
|
|
905b4d |
+ state->ar = ar;
|
|
|
905b4d |
+ state->realm = dp_opt_get_string(state->ipa_ctx->ipa_options->basic,
|
|
|
905b4d |
+ IPA_KRB5_REALM);
|
|
|
905b4d |
+ if (state->realm == NULL) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_CRIT_FAILURE, "No Kerberos realm for IPA?\n");
|
|
|
905b4d |
+ ret = EINVAL;
|
|
|
905b4d |
+ goto fail;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ /* We can skip the override lookup and go directly to the original object
|
|
|
905b4d |
+ * if
|
|
|
905b4d |
+ * - the lookup is by SID
|
|
|
905b4d |
+ * - there is no view set of it is the default view
|
|
|
905b4d |
+ * - if the EXTRA_INPUT_MAYBE_WITH_VIEW flag is not set
|
|
|
905b4d |
+ */
|
|
|
905b4d |
+ if (state->ipa_ctx->view_name == NULL
|
|
|
905b4d |
+ || state->ar->filter_type == BE_FILTER_SECID
|
|
|
905b4d |
+ || strcmp(state->ipa_ctx->view_name,
|
|
|
905b4d |
+ SYSDB_DEFAULT_VIEW_NAME) == 0
|
|
|
905b4d |
+ || state->ar->extra_value == NULL
|
|
|
905b4d |
+ || strcmp(state->ar->extra_value,
|
|
|
905b4d |
+ EXTRA_INPUT_MAYBE_WITH_VIEW) != 0 ) {
|
|
|
905b4d |
+ ret = ipa_id_get_account_info_get_original_step(req, ar);
|
|
|
905b4d |
+ if (ret != EOK) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE,
|
|
|
905b4d |
+ "ipa_subdomain_account_get_original_step failed.\n");
|
|
|
905b4d |
+ goto fail;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+ } else {
|
|
|
905b4d |
+ subreq = sdap_id_op_connect_send(state->op, state, &ret;;
|
|
|
905b4d |
+ if (subreq == NULL) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE, "sdap_id_op_connect_send failed.\n");
|
|
|
905b4d |
+ goto fail;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+ tevent_req_set_callback(subreq, ipa_id_get_account_info_connected, req);
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ return req;
|
|
|
905b4d |
+
|
|
|
905b4d |
+fail:
|
|
|
905b4d |
+ tevent_req_error(req, ret);
|
|
|
905b4d |
+ tevent_req_post(req, ev);
|
|
|
905b4d |
+ return req;
|
|
|
905b4d |
+}
|
|
|
905b4d |
+
|
|
|
905b4d |
+static void ipa_id_get_account_info_connected(struct tevent_req *subreq)
|
|
|
905b4d |
+{
|
|
|
905b4d |
+ struct tevent_req *req = tevent_req_callback_data(subreq,
|
|
|
905b4d |
+ struct tevent_req);
|
|
|
905b4d |
+ struct ipa_id_get_account_info_state *state = tevent_req_data(req,
|
|
|
905b4d |
+ struct ipa_id_get_account_info_state);
|
|
|
905b4d |
+ int dp_error = DP_ERR_FATAL;
|
|
|
905b4d |
+ int ret;
|
|
|
905b4d |
+
|
|
|
905b4d |
+ ret = sdap_id_op_connect_recv(subreq, &dp_error);
|
|
|
905b4d |
+ talloc_zfree(subreq);
|
|
|
905b4d |
+ if (ret != EOK) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE, "sdap_id_op_connect request failed.\n");
|
|
|
905b4d |
+ goto fail;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ subreq = ipa_get_ad_override_send(state, state->ev, state->ctx,
|
|
|
905b4d |
+ state->ipa_ctx->ipa_options, state->realm,
|
|
|
905b4d |
+ state->ipa_ctx->view_name, state->ar);
|
|
|
905b4d |
+ if (subreq == NULL) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE, "ipa_get_ad_override_send failed.\n");
|
|
|
905b4d |
+ ret = ENOMEM;
|
|
|
905b4d |
+ goto fail;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ tevent_req_set_callback(subreq, ipa_id_get_account_info_got_override, req);
|
|
|
905b4d |
+
|
|
|
905b4d |
+ return;
|
|
|
905b4d |
+
|
|
|
905b4d |
+fail:
|
|
|
905b4d |
+ state->dp_error = dp_error;
|
|
|
905b4d |
+ tevent_req_error(req, ret);
|
|
|
905b4d |
+ return;
|
|
|
905b4d |
+}
|
|
|
905b4d |
+
|
|
|
905b4d |
+static void ipa_id_get_account_info_got_override(struct tevent_req *subreq)
|
|
|
905b4d |
+{
|
|
|
905b4d |
+ struct tevent_req *req = tevent_req_callback_data(subreq,
|
|
|
905b4d |
+ struct tevent_req);
|
|
|
905b4d |
+ struct ipa_id_get_account_info_state *state = tevent_req_data(req,
|
|
|
905b4d |
+ struct ipa_id_get_account_info_state);
|
|
|
905b4d |
+ int dp_error = DP_ERR_FATAL;
|
|
|
905b4d |
+ int ret;
|
|
|
905b4d |
+ const char *anchor = NULL;
|
|
|
905b4d |
+ char *anchor_domain;
|
|
|
905b4d |
+ char *ipa_uuid;
|
|
|
905b4d |
+
|
|
|
905b4d |
+ ret = ipa_get_ad_override_recv(subreq, &dp_error, state,
|
|
|
905b4d |
+ &state->override_attrs);
|
|
|
905b4d |
+ talloc_zfree(subreq);
|
|
|
905b4d |
+ if (ret != EOK) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE, "IPA override lookup failed: %d\n", ret);
|
|
|
905b4d |
+ goto fail;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ if (state->override_attrs != NULL) {
|
|
|
905b4d |
+ ret = sysdb_attrs_get_string(state->override_attrs,
|
|
|
905b4d |
+ SYSDB_OVERRIDE_ANCHOR_UUID,
|
|
|
905b4d |
+ &anchor);
|
|
|
905b4d |
+ if (ret != EOK) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE, "sysdb_attrs_get_string failed.\n");
|
|
|
905b4d |
+ goto fail;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ ret = split_ipa_anchor(state, anchor, &anchor_domain, &ipa_uuid);
|
|
|
905b4d |
+ if (ret != EOK) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
905b4d |
+ "Unsupported override anchor [%s].\n", anchor);
|
|
|
905b4d |
+ ret = EINVAL;
|
|
|
905b4d |
+ goto fail;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ if (strcmp(state->ar->domain, anchor_domain) == 0) {
|
|
|
905b4d |
+
|
|
|
905b4d |
+ ret = get_be_acct_req_for_uuid(state, ipa_uuid,
|
|
|
905b4d |
+ state->ar->domain,
|
|
|
905b4d |
+ &state->ar);
|
|
|
905b4d |
+ if (ret != EOK) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE, "get_be_acct_req_for_sid failed.\n");
|
|
|
905b4d |
+ goto fail;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+ } else {
|
|
|
905b4d |
+ DEBUG(SSSDBG_MINOR_FAILURE,
|
|
|
905b4d |
+ "Anchor from a different domain [%s], expected [%s]. " \
|
|
|
905b4d |
+ "This is currently not supported, continue lookup in " \
|
|
|
905b4d |
+ "local IPA domain.\n",
|
|
|
905b4d |
+ anchor_domain, state->ar->domain);
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ ret = ipa_id_get_account_info_get_original_step(req, state->ar);
|
|
|
905b4d |
+ if (ret != EOK) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE,
|
|
|
905b4d |
+ "ipa_subdomain_account_get_original_step failed.\n");
|
|
|
905b4d |
+ goto fail;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ return;
|
|
|
905b4d |
+
|
|
|
905b4d |
+fail:
|
|
|
905b4d |
+ state->dp_error = dp_error;
|
|
|
905b4d |
+ tevent_req_error(req, ret);
|
|
|
905b4d |
+ return;
|
|
|
905b4d |
+}
|
|
|
905b4d |
+
|
|
|
905b4d |
+static errno_t ipa_id_get_account_info_get_original_step(struct tevent_req *req,
|
|
|
905b4d |
+ struct be_acct_req *ar)
|
|
|
905b4d |
+{
|
|
|
905b4d |
+ struct ipa_id_get_account_info_state *state = tevent_req_data(req,
|
|
|
905b4d |
+ struct ipa_id_get_account_info_state);
|
|
|
905b4d |
+ struct tevent_req *subreq;
|
|
|
905b4d |
+
|
|
|
905b4d |
+ subreq = sdap_handle_acct_req_send(state, state->be_req, ar,
|
|
|
905b4d |
+ state->ipa_ctx->sdap_id_ctx,
|
|
|
905b4d |
+ state->ipa_ctx->sdap_id_ctx->opts->sdom,
|
|
|
905b4d |
+ state->ipa_ctx->sdap_id_ctx->conn, true);
|
|
|
905b4d |
+ if (subreq == NULL) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE, "sdap_handle_acct_req_send failed.\n");
|
|
|
905b4d |
+ return ENOMEM;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+ tevent_req_set_callback(subreq, ipa_id_get_account_info_orig_done, req);
|
|
|
905b4d |
+
|
|
|
905b4d |
+ return EOK;
|
|
|
905b4d |
+}
|
|
|
905b4d |
+
|
|
|
905b4d |
+static void ipa_id_get_account_info_orig_done(struct tevent_req *subreq)
|
|
|
905b4d |
+{
|
|
|
905b4d |
+ struct tevent_req *req = tevent_req_callback_data(subreq,
|
|
|
905b4d |
+ struct tevent_req);
|
|
|
905b4d |
+ struct ipa_id_get_account_info_state *state = tevent_req_data(req,
|
|
|
905b4d |
+ struct ipa_id_get_account_info_state);
|
|
|
905b4d |
+ int dp_error = DP_ERR_FATAL;
|
|
|
905b4d |
+ int ret;
|
|
|
905b4d |
+ const char *uuid;
|
|
|
905b4d |
+ const char *class;
|
|
|
905b4d |
+ enum sysdb_member_type type;
|
|
|
905b4d |
+
|
|
|
905b4d |
+ ret = sdap_handle_acct_req_recv(subreq, &dp_error, NULL, NULL);
|
|
|
905b4d |
+ talloc_zfree(subreq);
|
|
|
905b4d |
+ if (ret != EOK) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE, "sdap_handle_acct request failed: %d\n", ret);
|
|
|
905b4d |
+ goto fail;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ ret = get_object_from_cache(state, state->domain, state->ar,
|
|
|
905b4d |
+ &state->obj_msg);
|
|
|
905b4d |
+ if (ret == ENOENT) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_MINOR_FAILURE, "Object not found, ending request\n");
|
|
|
905b4d |
+ tevent_req_done(req);
|
|
|
905b4d |
+ return;
|
|
|
905b4d |
+ } else if (ret != EOK) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE, "get_object_from_cache failed.\n");
|
|
|
905b4d |
+ goto fail;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ if (state->override_attrs == NULL) {
|
|
|
905b4d |
+ uuid = ldb_msg_find_attr_as_string(state->obj_msg, SYSDB_UUID, NULL);
|
|
|
905b4d |
+ if (uuid == NULL) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_CRIT_FAILURE, "Cannot find a UUID.\n");
|
|
|
905b4d |
+ ret = EINVAL;
|
|
|
905b4d |
+ goto fail;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ ret = get_be_acct_req_for_uuid(state, uuid, state->domain->name,
|
|
|
905b4d |
+ &state->ar);
|
|
|
905b4d |
+ if (ret != EOK) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE, "get_be_acct_req_for_sid failed.\n");
|
|
|
905b4d |
+ goto fail;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ subreq = ipa_get_ad_override_send(state, state->ev,
|
|
|
905b4d |
+ state->ipa_ctx->sdap_id_ctx,
|
|
|
905b4d |
+ state->ipa_ctx->ipa_options,
|
|
|
905b4d |
+ state->realm,
|
|
|
905b4d |
+ state->ipa_ctx->view_name,
|
|
|
905b4d |
+ state->ar);
|
|
|
905b4d |
+ if (subreq == NULL) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE, "ipa_get_ad_override_send failed.\n");
|
|
|
905b4d |
+ ret = ENOMEM;
|
|
|
905b4d |
+ goto fail;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+ tevent_req_set_callback(subreq, ipa_id_get_account_info_done, req);
|
|
|
905b4d |
+ return;
|
|
|
905b4d |
+ } else {
|
|
|
905b4d |
+ class = ldb_msg_find_attr_as_string(state->obj_msg, SYSDB_OBJECTCLASS,
|
|
|
905b4d |
+ NULL);
|
|
|
905b4d |
+ if (class == NULL) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_CRIT_FAILURE, "Cannot find an objectclass.\n");
|
|
|
905b4d |
+ ret = EINVAL;
|
|
|
905b4d |
+ goto fail;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ if (strcmp(class, SYSDB_USER_CLASS) == 0) {
|
|
|
905b4d |
+ type = SYSDB_MEMBER_USER;
|
|
|
905b4d |
+ } else {
|
|
|
905b4d |
+ type = SYSDB_MEMBER_GROUP;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ ret = sysdb_store_override(state->domain, state->ipa_ctx->view_name,
|
|
|
905b4d |
+ type,
|
|
|
905b4d |
+ state->override_attrs, state->obj_msg->dn);
|
|
|
905b4d |
+ if (ret != EOK) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE, "sysdb_store_override failed.\n");
|
|
|
905b4d |
+ goto fail;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ state->dp_error = DP_ERR_OK;
|
|
|
905b4d |
+ tevent_req_done(req);
|
|
|
905b4d |
+ return;
|
|
|
905b4d |
+
|
|
|
905b4d |
+fail:
|
|
|
905b4d |
+ state->dp_error = dp_error;
|
|
|
905b4d |
+ tevent_req_error(req, ret);
|
|
|
905b4d |
+ return;
|
|
|
905b4d |
+}
|
|
|
905b4d |
+
|
|
|
905b4d |
+static void ipa_id_get_account_info_done(struct tevent_req *subreq)
|
|
|
905b4d |
+{
|
|
|
905b4d |
+ struct tevent_req *req = tevent_req_callback_data(subreq,
|
|
|
905b4d |
+ struct tevent_req);
|
|
|
905b4d |
+ struct ipa_id_get_account_info_state *state = tevent_req_data(req,
|
|
|
905b4d |
+ struct ipa_id_get_account_info_state);
|
|
|
905b4d |
+ int dp_error = DP_ERR_FATAL;
|
|
|
905b4d |
+ int ret;
|
|
|
905b4d |
+ const char *class;
|
|
|
905b4d |
+ enum sysdb_member_type type;
|
|
|
905b4d |
+
|
|
|
905b4d |
+ ret = ipa_get_ad_override_recv(subreq, &dp_error, state,
|
|
|
905b4d |
+ &state->override_attrs);
|
|
|
905b4d |
+ talloc_zfree(subreq);
|
|
|
905b4d |
+ if (ret != EOK) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE, "IPA override lookup failed: %d\n", ret);
|
|
|
905b4d |
+ goto fail;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ class = ldb_msg_find_attr_as_string(state->obj_msg, SYSDB_OBJECTCLASS,
|
|
|
905b4d |
+ NULL);
|
|
|
905b4d |
+ if (class == NULL) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_CRIT_FAILURE, "Cannot find an objectclass.\n");
|
|
|
905b4d |
+ ret = EINVAL;
|
|
|
905b4d |
+ goto fail;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ if (strcmp(class, SYSDB_USER_CLASS) == 0) {
|
|
|
905b4d |
+ type = SYSDB_MEMBER_USER;
|
|
|
905b4d |
+ } else {
|
|
|
905b4d |
+ type = SYSDB_MEMBER_GROUP;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ ret = sysdb_store_override(state->domain, state->ipa_ctx->view_name,
|
|
|
905b4d |
+ type,
|
|
|
905b4d |
+ state->override_attrs, state->obj_msg->dn);
|
|
|
905b4d |
+ if (ret != EOK) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE, "sysdb_store_override failed.\n");
|
|
|
905b4d |
+ goto fail;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ state->dp_error = DP_ERR_OK;
|
|
|
905b4d |
+ tevent_req_done(req);
|
|
|
905b4d |
+ return;
|
|
|
905b4d |
+
|
|
|
905b4d |
+fail:
|
|
|
905b4d |
+ state->dp_error = dp_error;
|
|
|
905b4d |
+ tevent_req_error(req, ret);
|
|
|
905b4d |
+ return;
|
|
|
905b4d |
+}
|
|
|
905b4d |
+
|
|
|
905b4d |
+static int ipa_id_get_account_info_recv(struct tevent_req *req, int *dp_error)
|
|
|
905b4d |
+{
|
|
|
905b4d |
+ struct ipa_id_get_account_info_state *state = tevent_req_data(req,
|
|
|
905b4d |
+ struct ipa_id_get_account_info_state);
|
|
|
905b4d |
+
|
|
|
905b4d |
+ if (dp_error) {
|
|
|
905b4d |
+ *dp_error = state->dp_error;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+
|
|
|
905b4d |
+ TEVENT_REQ_RETURN_ON_ERROR(req);
|
|
|
905b4d |
+
|
|
|
905b4d |
+ return EOK;
|
|
|
905b4d |
+}
|
|
|
905b4d |
|
|
|
905b4d |
/* Request for netgroups
|
|
|
905b4d |
* - first start here and then go to ipa_netgroups.c
|
|
|
905b4d |
diff --git a/src/providers/ipa/ipa_subdomains_id.c b/src/providers/ipa/ipa_subdomains_id.c
|
|
|
905b4d |
index 891fc336483b507fd284b0c84b118534910ed9fc..ce5a6d1a1048eda4d8b7017bd92bc7ee76e66ef9 100644
|
|
|
905b4d |
--- a/src/providers/ipa/ipa_subdomains_id.c
|
|
|
905b4d |
+++ b/src/providers/ipa/ipa_subdomains_id.c
|
|
|
905b4d |
@@ -879,9 +879,21 @@ errno_t get_object_from_cache(TALLOC_CTX *mem_ctx,
|
|
|
905b4d |
|
|
|
905b4d |
ret = EOK;
|
|
|
905b4d |
goto done;
|
|
|
905b4d |
- }
|
|
|
905b4d |
+ } else if (ar->filter_type == BE_FILTER_UUID) {
|
|
|
905b4d |
+ ret = sysdb_search_object_by_uuid(mem_ctx, dom, ar->filter_value, attrs,
|
|
|
905b4d |
+ &res;;
|
|
|
905b4d |
+ if (ret != EOK) {
|
|
|
905b4d |
+ DEBUG(SSSDBG_OP_FAILURE,
|
|
|
905b4d |
+ "Failed to make request to our cache: [%d]: [%s]\n",
|
|
|
905b4d |
+ ret, sss_strerror(ret));
|
|
|
905b4d |
+ goto done;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
|
|
|
905b4d |
- if (ar->filter_type == BE_FILTER_IDNUM) {
|
|
|
905b4d |
+ *_msg = res->msgs[0];
|
|
|
905b4d |
+
|
|
|
905b4d |
+ ret = EOK;
|
|
|
905b4d |
+ goto done;
|
|
|
905b4d |
+ } else if (ar->filter_type == BE_FILTER_IDNUM) {
|
|
|
905b4d |
errno = 0;
|
|
|
905b4d |
id = strtouint32(ar->filter_value, NULL, 10);
|
|
|
905b4d |
if (errno != 0) {
|
|
|
905b4d |
diff --git a/src/providers/ipa/ipa_views.c b/src/providers/ipa/ipa_views.c
|
|
|
905b4d |
index ee586894ec61b1b1330816c628bbc9617d58e31e..c768186d7cf5e5a997e2ca27a167b62c8dc99b3f 100644
|
|
|
905b4d |
--- a/src/providers/ipa/ipa_views.c
|
|
|
905b4d |
+++ b/src/providers/ipa/ipa_views.c
|
|
|
905b4d |
@@ -125,6 +125,21 @@ static errno_t be_acct_req_to_override_filter(TALLOC_CTX *mem_ctx,
|
|
|
905b4d |
}
|
|
|
905b4d |
break;
|
|
|
905b4d |
|
|
|
905b4d |
+ case BE_FILTER_UUID:
|
|
|
905b4d |
+ if ((ar->entry_type & BE_REQ_TYPE_MASK) == BE_REQ_BY_UUID) {
|
|
|
905b4d |
+ filter = talloc_asprintf(mem_ctx, "(&(objectClass=%s)(%s=:IPA:%s:%s))",
|
|
|
905b4d |
+ ipa_opts->override_map[IPA_OC_OVERRIDE].name,
|
|
|
905b4d |
+ ipa_opts->override_map[IPA_AT_OVERRIDE_ANCHOR_UUID].name,
|
|
|
905b4d |
+ dp_opt_get_string(ipa_opts->basic, IPA_DOMAIN),
|
|
|
905b4d |
+ ar->filter_value);
|
|
|
905b4d |
+ } else {
|
|
|
905b4d |
+ DEBUG(SSSDBG_CRIT_FAILURE,
|
|
|
905b4d |
+ "Unexpected entry type [%d] for UUID filter.\n",
|
|
|
905b4d |
+ ar->entry_type);
|
|
|
905b4d |
+ return EINVAL;
|
|
|
905b4d |
+ }
|
|
|
905b4d |
+ break;
|
|
|
905b4d |
+
|
|
|
905b4d |
default:
|
|
|
905b4d |
DEBUG(SSSDBG_OP_FAILURE, "Invalid sub-domain filter type.\n");
|
|
|
905b4d |
return EINVAL;
|
|
|
905b4d |
--
|
|
|
905b4d |
1.9.3
|
|
|
905b4d |
|