Blame SOURCES/0070-LDAP-Only-run-the-POSIX-check-with-a-GC-connection.patch

9f2ebf
From 405f08eabf5017cc00891fb2090be80306c8aeae Mon Sep 17 00:00:00 2001
9f2ebf
From: Jakub Hrozek <jhrozek@redhat.com>
9f2ebf
Date: Thu, 30 Nov 2017 12:01:51 +0100
9f2ebf
Subject: [PATCH 70/83] LDAP: Only run the POSIX check with a GC connection
9f2ebf
MIME-Version: 1.0
9f2ebf
Content-Type: text/plain; charset=UTF-8
9f2ebf
Content-Transfer-Encoding: 8bit
9f2ebf
9f2ebf
Previously, we used to run the POSIX check also with an LDAP connection.
9f2ebf
This was wasteful, but worked, so the waste wasn't the biggest problem
9f2ebf
-- the approach would only cause problems with the following patch which
9f2ebf
uses a NULL search base to search the Global Catalog, because searching
9f2ebf
with a SUBTREE scope and a NULL base returns a referral with an LDAP
9f2ebf
connection.
9f2ebf
9f2ebf
Instead, this patch uses a heuristics (whether the connection ignores
9f2ebf
the offline state) to check if the connection is a POSIX one and if it
9f2ebf
is NOT, then skips the POSIX check.
9f2ebf
9f2ebf
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
9f2ebf
Reviewed-by: Sumit Bose <sbose@redhat.com>
9f2ebf
(cherry picked from commit dacfe74113dde62ddaaa7f9abf9d2b6448d89db6)
9f2ebf
---
9f2ebf
 src/providers/ldap/ldap_common.c     | 2 ++
9f2ebf
 src/providers/ldap/ldap_common.h     | 1 +
9f2ebf
 src/providers/ldap/ldap_id.c         | 2 ++
9f2ebf
 src/providers/ldap/sdap_async_enum.c | 1 +
9f2ebf
 4 files changed, 6 insertions(+)
9f2ebf
9f2ebf
diff --git a/src/providers/ldap/ldap_common.c b/src/providers/ldap/ldap_common.c
9f2ebf
index 3eff3515d95043d4b59cb0d9953cf050355a0ca5..36e79b9d6ca23ef5e21a8b0bedc7f05db8f4fc98 100644
9f2ebf
--- a/src/providers/ldap/ldap_common.c
9f2ebf
+++ b/src/providers/ldap/ldap_common.c
9f2ebf
@@ -973,12 +973,14 @@ sdap_id_ctx_new(TALLOC_CTX *mem_ctx, struct be_ctx *bectx,
9f2ebf
 }
9f2ebf
 
9f2ebf
 bool should_run_posix_check(struct sdap_id_ctx *ctx,
9f2ebf
+                            struct sdap_id_conn_ctx *conn,
9f2ebf
                             bool use_id_mapping,
9f2ebf
                             bool posix_request)
9f2ebf
 {
9f2ebf
     if (use_id_mapping == false &&
9f2ebf
             posix_request == true &&
9f2ebf
             ctx->opts->schema_type == SDAP_SCHEMA_AD &&
9f2ebf
+            conn->ignore_mark_offline == true &&
9f2ebf
             ctx->srv_opts &&
9f2ebf
             ctx->srv_opts->posix_checked == false) {
9f2ebf
         return true;
9f2ebf
diff --git a/src/providers/ldap/ldap_common.h b/src/providers/ldap/ldap_common.h
9f2ebf
index fa7cda4df9d7334f6f0f5baccae0cba0478bfbea..44dbc3fb0678412f46366321e0be836313380949 100644
9f2ebf
--- a/src/providers/ldap/ldap_common.h
9f2ebf
+++ b/src/providers/ldap/ldap_common.h
9f2ebf
@@ -305,6 +305,7 @@ char *get_enterprise_principal_string_filter(TALLOC_CTX *mem_ctx,
9f2ebf
                                              struct dp_option *sdap_basic_opts);
9f2ebf
 
9f2ebf
 bool should_run_posix_check(struct sdap_id_ctx *ctx,
9f2ebf
+                            struct sdap_id_conn_ctx *conn,
9f2ebf
                             bool id_mapping,
9f2ebf
                             bool posix_request);
9f2ebf
 
9f2ebf
diff --git a/src/providers/ldap/ldap_id.c b/src/providers/ldap/ldap_id.c
9f2ebf
index 6ab9e0aa1db3eed32deb75211ded30a4cb48ca30..47969a9749253721334a20f46230f7aecea64882 100644
9f2ebf
--- a/src/providers/ldap/ldap_id.c
9f2ebf
+++ b/src/providers/ldap/ldap_id.c
9f2ebf
@@ -412,6 +412,7 @@ static void users_get_connect_done(struct tevent_req *subreq)
9f2ebf
      * have no idea about POSIX attributes support, run a one-time check
9f2ebf
      */
9f2ebf
     if (should_run_posix_check(state->ctx,
9f2ebf
+                               state->conn,
9f2ebf
                                state->use_id_mapping,
9f2ebf
                                !state->non_posix)) {
9f2ebf
         subreq = sdap_posix_check_send(state, state->ev, state->ctx->opts,
9f2ebf
@@ -957,6 +958,7 @@ static void groups_get_connect_done(struct tevent_req *subreq)
9f2ebf
      * have no idea about POSIX attributes support, run a one-time check
9f2ebf
      */
9f2ebf
     if (should_run_posix_check(state->ctx,
9f2ebf
+                               state->conn,
9f2ebf
                                state->use_id_mapping,
9f2ebf
                                !state->non_posix)) {
9f2ebf
         subreq = sdap_posix_check_send(state, state->ev, state->ctx->opts,
9f2ebf
diff --git a/src/providers/ldap/sdap_async_enum.c b/src/providers/ldap/sdap_async_enum.c
9f2ebf
index 2cef4eb886f982ba388a34955bdd38468fe68200..baa039d63c71cc5054e6af6538d34d04cde6b858 100644
9f2ebf
--- a/src/providers/ldap/sdap_async_enum.c
9f2ebf
+++ b/src/providers/ldap/sdap_async_enum.c
9f2ebf
@@ -197,6 +197,7 @@ static void sdap_dom_enum_ex_get_users(struct tevent_req *subreq)
9f2ebf
      * have no idea about POSIX attributes support, run a one-time check
9f2ebf
      */
9f2ebf
     if (should_run_posix_check(state->ctx,
9f2ebf
+                               state->user_conn,
9f2ebf
                                use_id_mapping,
9f2ebf
                                true)) {
9f2ebf
         subreq = sdap_posix_check_send(state, state->ev, state->ctx->opts,
9f2ebf
-- 
9f2ebf
2.14.3
9f2ebf