Blame SOURCES/0011-ipa-fix-issues-with-older-servers-not-supporting-vie.patch

905b4d
From d384cf52b5753c2409625eca906474b95edcbe9d Mon Sep 17 00:00:00 2001
905b4d
From: Sumit Bose <sbose@redhat.com>
905b4d
Date: Wed, 22 Oct 2014 10:03:09 +0200
905b4d
Subject: [PATCH 11/22] ipa: fix issues with older servers not supporting views
905b4d
905b4d
Older FreeIPA servers which do not know about the ipaAssignedIDView
905b4d
attribute will return an error during the LDAP dereference request
905b4d
because SSSD marks LDAP extensions as critical. In this case we keep the
905b4d
view name empty and skip override lookups.
905b4d
905b4d
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
905b4d
---
905b4d
 src/providers/ipa/ipa_subdomains.c    | 14 +++++++++++++-
905b4d
 src/providers/ipa/ipa_subdomains_id.c |  4 +++-
905b4d
 src/providers/ipa/ipa_views.c         | 17 ++++++++++++-----
905b4d
 3 files changed, 28 insertions(+), 7 deletions(-)
905b4d
905b4d
diff --git a/src/providers/ipa/ipa_subdomains.c b/src/providers/ipa/ipa_subdomains.c
905b4d
index bedc0f1a50e8a35ea65de45247b1814c9abc0bcd..eb172fdfc05ac4e482174f01d89ad28db1498fc1 100644
905b4d
--- a/src/providers/ipa/ipa_subdomains.c
905b4d
+++ b/src/providers/ipa/ipa_subdomains.c
905b4d
@@ -1002,7 +1002,19 @@ static void ipa_get_view_name_done(struct tevent_req *req)
905b4d
     ret = sdap_deref_search_with_filter_recv(req, ctx, &reply_count, &reply);
905b4d
     talloc_zfree(req);
905b4d
     if (ret != EOK) {
905b4d
-        DEBUG(SSSDBG_OP_FAILURE, "get_view_name request failed.\n");
905b4d
+        if (ret == EOPNOTSUPP) {
905b4d
+            DEBUG(SSSDBG_TRACE_FUNC, "get_view_name request failed, looks " \
905b4d
+                                     "like server does not support views.\n");
905b4d
+            ret = ipa_check_master(ctx);
905b4d
+            if (ret == EAGAIN) {
905b4d
+                return;
905b4d
+            } else if (ret != EOK) {
905b4d
+                goto done;
905b4d
+            }
905b4d
+
905b4d
+        } else {
905b4d
+            DEBUG(SSSDBG_OP_FAILURE, "get_view_name request failed.\n");
905b4d
+        }
905b4d
         goto done;
905b4d
     }
905b4d
 
905b4d
diff --git a/src/providers/ipa/ipa_subdomains_id.c b/src/providers/ipa/ipa_subdomains_id.c
905b4d
index 36f8b239249e5f0146610cfab148be20c39c66c2..b67006ce6e0b4bf9c794016c1dfc923ac6da3624 100644
905b4d
--- a/src/providers/ipa/ipa_subdomains_id.c
905b4d
+++ b/src/providers/ipa/ipa_subdomains_id.c
905b4d
@@ -106,11 +106,13 @@ struct tevent_req *ipa_subdomain_account_send(TALLOC_CTX *memctx,
905b4d
      * have to check first if the request matches an override in the given
905b4d
      * view. But there are cases where this can be skipped and the AD object
905b4d
      * can be searched directly:
905b4d
+     * - if no view is defined, i.e. the server does not supprt views yet
905b4d
      * - searches by SID: because we do not override the SID
905b4d
      * - if the responder does not send the EXTRA_INPUT_MAYBE_WITH_VIEW flags,
905b4d
      *   because in this case the entry was found in the cache and the
905b4d
      *   original value is used for the search (e.g. during cache updates) */
905b4d
-    if (state->ar->filter_type == BE_FILTER_SECID
905b4d
+    if (state->ipa_ctx->view_name == NULL
905b4d
+            || state->ar->filter_type == BE_FILTER_SECID
905b4d
             || (!state->ipa_server_mode
905b4d
                 && state->ar->extra_value != NULL
905b4d
                 && strcmp(state->ar->extra_value,
905b4d
diff --git a/src/providers/ipa/ipa_views.c b/src/providers/ipa/ipa_views.c
905b4d
index 33dbf7b1c17f188924ee7b50a77ab699f03392be..2eb77216ab9759d8b1d66fbdf0b2e90cd07a4604 100644
905b4d
--- a/src/providers/ipa/ipa_views.c
905b4d
+++ b/src/providers/ipa/ipa_views.c
905b4d
@@ -208,16 +208,23 @@ struct tevent_req *ipa_get_ad_override_send(TALLOC_CTX *mem_ctx,
905b4d
     state->sdap_id_ctx = sdap_id_ctx;
905b4d
     state->ipa_options = ipa_options;
905b4d
     state->ipa_realm = ipa_realm;
905b4d
-    if (strcmp(view_name, SYSDB_DEFAULT_VIEW_NAME) == 0) {
905b4d
-        state->ipa_view_name = IPA_DEFAULT_VIEW_NAME;
905b4d
-    } else {
905b4d
-        state->ipa_view_name = view_name;
905b4d
-    }
905b4d
     state->ar = ar;
905b4d
     state->dp_error = -1;
905b4d
     state->override_attrs = NULL;
905b4d
     state->filter = NULL;
905b4d
 
905b4d
+    if (view_name == NULL) {
905b4d
+        DEBUG(SSSDBG_TRACE_ALL, "View not defined, nothing to do.\n");
905b4d
+        ret = EOK;
905b4d
+        goto done;
905b4d
+    }
905b4d
+
905b4d
+    if (strcmp(view_name, SYSDB_DEFAULT_VIEW_NAME) == 0) {
905b4d
+        state->ipa_view_name = IPA_DEFAULT_VIEW_NAME;
905b4d
+    } else {
905b4d
+        state->ipa_view_name = view_name;
905b4d
+    }
905b4d
+
905b4d
     state->sdap_op = sdap_id_op_create(state,
905b4d
                                        state->sdap_id_ctx->conn->conn_cache);
905b4d
     if (state->sdap_op == NULL) {
905b4d
-- 
905b4d
1.9.3
905b4d