dpward / rpms / sssd

Forked from rpms/sssd 3 years ago
Clone

Blame SOURCES/0063-ipa-handle-users-from-different-domains-in-ipa_resol.patch

9f2ebf
From d8d4e9fb842444eb3bd4e1a116fce00aba557707 Mon Sep 17 00:00:00 2001
9f2ebf
From: Sumit Bose <sbose@redhat.com>
9f2ebf
Date: Mon, 20 Nov 2017 12:04:50 +0100
9f2ebf
Subject: [PATCH 63/67] ipa: handle users from different domains in
9f2ebf
 ipa_resolve_user_list_send()
9f2ebf
MIME-Version: 1.0
9f2ebf
Content-Type: text/plain; charset=UTF-8
9f2ebf
Content-Transfer-Encoding: 8bit
9f2ebf
9f2ebf
Instead of assuming that all users in the list can be found in the
9f2ebf
provided domain with this patch the domain name part of the user name is
9f2ebf
preferred. The provided domain name is used as a fallback.
9f2ebf
9f2ebf
Related to https://pagure.io/SSSD/sssd/issue/3579
9f2ebf
9f2ebf
Reviewed-by: Fabiano FidĂȘncio <fidencio@redhat.com>
9f2ebf
(cherry picked from commit 7988988aab5bd0249476671b850eb3909aa753f8)
9f2ebf
---
9f2ebf
 src/providers/ipa/ipa_id.c | 20 ++++++++++++++++----
9f2ebf
 1 file changed, 16 insertions(+), 4 deletions(-)
9f2ebf
9f2ebf
diff --git a/src/providers/ipa/ipa_id.c b/src/providers/ipa/ipa_id.c
9f2ebf
index 8f8759f64b758aae7e45c88588e97a1bcf16ad79..2b4386584192d6b5ef0372099292ed73b77177bd 100644
9f2ebf
--- a/src/providers/ipa/ipa_id.c
9f2ebf
+++ b/src/providers/ipa/ipa_id.c
9f2ebf
@@ -63,6 +63,8 @@ struct ipa_resolve_user_list_state {
9f2ebf
     struct ipa_id_ctx *ipa_ctx;
9f2ebf
     struct ldb_message_element *users;
9f2ebf
     const char *domain_name;
9f2ebf
+    struct sss_domain_info *domain;
9f2ebf
+    struct sss_domain_info *user_domain;
9f2ebf
     size_t user_idx;
9f2ebf
 
9f2ebf
     int dp_error;
9f2ebf
@@ -91,6 +93,8 @@ ipa_resolve_user_list_send(TALLOC_CTX *memctx, struct tevent_context *ev,
9f2ebf
     state->ev = ev;
9f2ebf
     state->ipa_ctx = ipa_ctx;
9f2ebf
     state->domain_name = domain_name;
9f2ebf
+    state->domain = find_domain_by_name(state->ipa_ctx->sdap_id_ctx->be->domain,
9f2ebf
+                                        state->domain_name, true);
9f2ebf
     state->users = users;
9f2ebf
     state->user_idx = 0;
9f2ebf
     state->dp_error = DP_ERR_FATAL;
9f2ebf
@@ -132,8 +136,17 @@ static errno_t ipa_resolve_user_list_get_user_step(struct tevent_req *req)
9f2ebf
 
9f2ebf
     DEBUG(SSSDBG_TRACE_ALL, "Trying to resolve user [%s].\n", ar->filter_value);
9f2ebf
 
9f2ebf
-    if (strcasecmp(state->domain_name,
9f2ebf
-                   state->ipa_ctx->sdap_id_ctx->be->domain->name) != 0) {
9f2ebf
+    state->user_domain = find_domain_by_object_name_ex(
9f2ebf
+                                        state->ipa_ctx->sdap_id_ctx->be->domain,
9f2ebf
+                                        ar->filter_value, true);
9f2ebf
+    /* Use provided domain as as fallback is no known domain was found in the
9f2ebf
+     * user name. */
9f2ebf
+    if (state->user_domain == NULL) {
9f2ebf
+        state->user_domain = state->domain;
9f2ebf
+    }
9f2ebf
+    ar->domain = state->user_domain->name;
9f2ebf
+
9f2ebf
+    if (state->user_domain != state->ipa_ctx->sdap_id_ctx->be->domain) {
9f2ebf
         subreq = ipa_subdomain_account_send(state, state->ev, state->ipa_ctx,
9f2ebf
                                             ar);
9f2ebf
     } else {
9f2ebf
@@ -158,8 +171,7 @@ static void ipa_resolve_user_list_get_user_done(struct tevent_req *subreq)
9f2ebf
                                             struct ipa_resolve_user_list_state);
9f2ebf
     int ret;
9f2ebf
 
9f2ebf
-    if (strcasecmp(state->domain_name,
9f2ebf
-                   state->ipa_ctx->sdap_id_ctx->be->domain->name) != 0) {
9f2ebf
+    if (state->user_domain != state->ipa_ctx->sdap_id_ctx->be->domain) {
9f2ebf
         ret = ipa_subdomain_account_recv(subreq, &state->dp_error);
9f2ebf
     } else {
9f2ebf
         ret = ipa_id_get_account_info_recv(subreq, &state->dp_error);
9f2ebf
-- 
9f2ebf
2.14.3
9f2ebf