Blame SOURCES/0072-SDAP-Rename-sdap_posix_check-to-sdap_gc_posix_check.patch

ced1f5
From ada45cd38a73b1b196db459849fcc19781bc06fc Mon Sep 17 00:00:00 2001
ced1f5
From: Jakub Hrozek <jhrozek@redhat.com>
ced1f5
Date: Wed, 6 Dec 2017 16:26:15 +0100
ced1f5
Subject: [PATCH 72/83] SDAP: Rename sdap_posix_check to sdap_gc_posix_check
ced1f5
MIME-Version: 1.0
ced1f5
Content-Type: text/plain; charset=UTF-8
ced1f5
Content-Transfer-Encoding: 8bit
ced1f5
ced1f5
Because searching the LDAP port of Active Directory server with a NULL
ced1f5
search base yields an error:
ced1f5
    https://technet.microsoft.com/en-us/library/cc755809(v=ws.10).aspx
ced1f5
we changed the POSIX check request to only run against a GC connection
ced1f5
in a previous patch. To make it clearer to the caller that this request
ced1f5
should only be used with a GC connection, this patch renames the
ced1f5
request.
ced1f5
ced1f5
There are no functional changes in this patch.
ced1f5
ced1f5
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
ced1f5
Reviewed-by: Sumit Bose <sbose@redhat.com>
ced1f5
(cherry picked from commit ba8a92bbd59f189bd1323dd0c4010cdfc694be35)
ced1f5
---
ced1f5
 src/providers/ldap/ldap_id.c         | 20 +++++++--------
ced1f5
 src/providers/ldap/sdap_async.c      | 48 ++++++++++++++++++------------------
ced1f5
 src/providers/ldap/sdap_async.h      | 16 ++++++++----
ced1f5
 src/providers/ldap/sdap_async_enum.c | 10 ++++----
ced1f5
 4 files changed, 50 insertions(+), 44 deletions(-)
ced1f5
ced1f5
diff --git a/src/providers/ldap/ldap_id.c b/src/providers/ldap/ldap_id.c
ced1f5
index b5ac3a749113a281fe8a5564ac341ced0570eded..3824f8f9aa8d2892664f1182376bedf6fb8627f6 100644
ced1f5
--- a/src/providers/ldap/ldap_id.c
ced1f5
+++ b/src/providers/ldap/ldap_id.c
ced1f5
@@ -415,10 +415,10 @@ static void users_get_connect_done(struct tevent_req *subreq)
ced1f5
                                state->conn,
ced1f5
                                state->use_id_mapping,
ced1f5
                                !state->non_posix)) {
ced1f5
-        subreq = sdap_posix_check_send(state, state->ev, state->ctx->opts,
ced1f5
-                                       sdap_id_op_handle(state->op),
ced1f5
-                                       dp_opt_get_int(state->ctx->opts->basic,
ced1f5
-                                                      SDAP_SEARCH_TIMEOUT));
ced1f5
+        subreq = sdap_gc_posix_check_send(state, state->ev, state->ctx->opts,
ced1f5
+                                          sdap_id_op_handle(state->op),
ced1f5
+                                          dp_opt_get_int(state->ctx->opts->basic,
ced1f5
+                                                         SDAP_SEARCH_TIMEOUT));
ced1f5
         if (subreq == NULL) {
ced1f5
             tevent_req_error(req, ENOMEM);
ced1f5
             return;
ced1f5
@@ -441,7 +441,7 @@ static void users_get_posix_check_done(struct tevent_req *subreq)
ced1f5
     struct users_get_state *state = tevent_req_data(req,
ced1f5
                                                     struct users_get_state);
ced1f5
 
ced1f5
-    ret = sdap_posix_check_recv(subreq, &has_posix);
ced1f5
+    ret = sdap_gc_posix_check_recv(subreq, &has_posix);
ced1f5
     talloc_zfree(subreq);
ced1f5
     if (ret != EOK) {
ced1f5
         /* We can only finish the id_op on error as the connection
ced1f5
@@ -960,10 +960,10 @@ static void groups_get_connect_done(struct tevent_req *subreq)
ced1f5
                                state->conn,
ced1f5
                                state->use_id_mapping,
ced1f5
                                !state->non_posix)) {
ced1f5
-        subreq = sdap_posix_check_send(state, state->ev, state->ctx->opts,
ced1f5
-                                       sdap_id_op_handle(state->op),
ced1f5
-                                       dp_opt_get_int(state->ctx->opts->basic,
ced1f5
-                                                      SDAP_SEARCH_TIMEOUT));
ced1f5
+        subreq = sdap_gc_posix_check_send(state, state->ev, state->ctx->opts,
ced1f5
+                                          sdap_id_op_handle(state->op),
ced1f5
+                                          dp_opt_get_int(state->ctx->opts->basic,
ced1f5
+                                                         SDAP_SEARCH_TIMEOUT));
ced1f5
         if (subreq == NULL) {
ced1f5
             tevent_req_error(req, ENOMEM);
ced1f5
             return;
ced1f5
@@ -985,7 +985,7 @@ static void groups_get_posix_check_done(struct tevent_req *subreq)
ced1f5
     struct groups_get_state *state = tevent_req_data(req,
ced1f5
                                                      struct groups_get_state);
ced1f5
 
ced1f5
-    ret = sdap_posix_check_recv(subreq, &has_posix);
ced1f5
+    ret = sdap_gc_posix_check_recv(subreq, &has_posix);
ced1f5
     talloc_zfree(subreq);
ced1f5
     if (ret != EOK) {
ced1f5
         /* We can only finish the id_op on error as the connection
ced1f5
diff --git a/src/providers/ldap/sdap_async.c b/src/providers/ldap/sdap_async.c
ced1f5
index 1df0b85f4bda6442d8da66784ad7424306b1f051..a9bea4f80903aeb9d0fdb4d2b8f2acb36d81d6fe 100644
ced1f5
--- a/src/providers/ldap/sdap_async.c
ced1f5
+++ b/src/providers/ldap/sdap_async.c
ced1f5
@@ -2573,12 +2573,12 @@ int sdap_asq_search_recv(struct tevent_req *req,
ced1f5
 }
ced1f5
 
ced1f5
 /* ==Posix attribute presence test================================= */
ced1f5
-static void sdap_posix_check_done(struct tevent_req *subreq);
ced1f5
-static errno_t sdap_posix_check_parse(struct sdap_handle *sh,
ced1f5
-                                      struct sdap_msg *msg,
ced1f5
-                                      void *pvt);
ced1f5
+static void sdap_gc_posix_check_done(struct tevent_req *subreq);
ced1f5
+static errno_t sdap_gc_posix_check_parse(struct sdap_handle *sh,
ced1f5
+                                         struct sdap_msg *msg,
ced1f5
+                                         void *pvt);
ced1f5
 
ced1f5
-struct sdap_posix_check_state {
ced1f5
+struct sdap_gc_posix_check_state {
ced1f5
     struct tevent_context *ev;
ced1f5
     struct sdap_options *opts;
ced1f5
     struct sdap_handle *sh;
ced1f5
@@ -2591,16 +2591,16 @@ struct sdap_posix_check_state {
ced1f5
 };
ced1f5
 
ced1f5
 struct tevent_req *
ced1f5
-sdap_posix_check_send(TALLOC_CTX *memctx, struct tevent_context *ev,
ced1f5
-                      struct sdap_options *opts, struct sdap_handle *sh,
ced1f5
-                      int timeout)
ced1f5
+sdap_gc_posix_check_send(TALLOC_CTX *memctx, struct tevent_context *ev,
ced1f5
+                         struct sdap_options *opts, struct sdap_handle *sh,
ced1f5
+                         int timeout)
ced1f5
 {
ced1f5
     struct tevent_req *req = NULL;
ced1f5
     struct tevent_req *subreq = NULL;
ced1f5
-    struct sdap_posix_check_state *state;
ced1f5
+    struct sdap_gc_posix_check_state *state;
ced1f5
     errno_t ret;
ced1f5
 
ced1f5
-    req = tevent_req_create(memctx, &state, struct sdap_posix_check_state);
ced1f5
+    req = tevent_req_create(memctx, &state, struct sdap_gc_posix_check_state);
ced1f5
     if (req == NULL) {
ced1f5
         return NULL;
ced1f5
     }
ced1f5
@@ -2636,13 +2636,13 @@ sdap_posix_check_send(TALLOC_CTX *memctx, struct tevent_context *ev,
ced1f5
                                  LDAP_SCOPE_SUBTREE, state->filter,
ced1f5
                                  state->attrs,
ced1f5
                                  NULL, NULL, 1, state->timeout,
ced1f5
-                                 sdap_posix_check_parse, state,
ced1f5
+                                 sdap_gc_posix_check_parse, state,
ced1f5
                                  SDAP_SRCH_FLG_SIZELIMIT_SILENT);
ced1f5
     if (subreq == NULL) {
ced1f5
         ret = ENOMEM;
ced1f5
         goto fail;
ced1f5
     }
ced1f5
-    tevent_req_set_callback(subreq, sdap_posix_check_done, req);
ced1f5
+    tevent_req_set_callback(subreq, sdap_gc_posix_check_done, req);
ced1f5
 
ced1f5
     return req;
ced1f5
 
ced1f5
@@ -2652,13 +2652,13 @@ fail:
ced1f5
     return req;
ced1f5
 }
ced1f5
 
ced1f5
-static errno_t sdap_posix_check_parse(struct sdap_handle *sh,
ced1f5
-                                      struct sdap_msg *msg,
ced1f5
-                                      void *pvt)
ced1f5
+static errno_t sdap_gc_posix_check_parse(struct sdap_handle *sh,
ced1f5
+                                         struct sdap_msg *msg,
ced1f5
+                                         void *pvt)
ced1f5
 {
ced1f5
     struct berval **vals = NULL;
ced1f5
-    struct sdap_posix_check_state *state =
ced1f5
-        talloc_get_type(pvt, struct sdap_posix_check_state);
ced1f5
+    struct sdap_gc_posix_check_state *state =
ced1f5
+        talloc_get_type(pvt, struct sdap_gc_posix_check_state);
ced1f5
     char *dn;
ced1f5
     char *endptr;
ced1f5
 
ced1f5
@@ -2700,12 +2700,12 @@ done:
ced1f5
     return EOK;
ced1f5
 }
ced1f5
 
ced1f5
-static void sdap_posix_check_done(struct tevent_req *subreq)
ced1f5
+static void sdap_gc_posix_check_done(struct tevent_req *subreq)
ced1f5
 {
ced1f5
     struct tevent_req *req = tevent_req_callback_data(subreq,
ced1f5
                                                       struct tevent_req);
ced1f5
-    struct sdap_posix_check_state *state =
ced1f5
-        tevent_req_data(req, struct sdap_posix_check_state);
ced1f5
+    struct sdap_gc_posix_check_state *state =
ced1f5
+        tevent_req_data(req, struct sdap_gc_posix_check_state);
ced1f5
     errno_t ret;
ced1f5
 
ced1f5
     ret = sdap_get_generic_ext_recv(subreq, NULL, NULL, NULL);
ced1f5
@@ -2730,11 +2730,11 @@ static void sdap_posix_check_done(struct tevent_req *subreq)
ced1f5
     tevent_req_done(req);
ced1f5
 }
ced1f5
 
ced1f5
-int sdap_posix_check_recv(struct tevent_req *req,
ced1f5
-                          bool *_has_posix)
ced1f5
+int sdap_gc_posix_check_recv(struct tevent_req *req,
ced1f5
+                             bool *_has_posix)
ced1f5
 {
ced1f5
-    struct sdap_posix_check_state *state = tevent_req_data(req,
ced1f5
-                                            struct sdap_posix_check_state);
ced1f5
+    struct sdap_gc_posix_check_state *state = tevent_req_data(req,
ced1f5
+                                            struct sdap_gc_posix_check_state);
ced1f5
 
ced1f5
     TEVENT_REQ_RETURN_ON_ERROR(req);
ced1f5
 
ced1f5
diff --git a/src/providers/ldap/sdap_async.h b/src/providers/ldap/sdap_async.h
ced1f5
index 7216ba032e551196cf5258b4e58fbfc8cfe417ea..26f13e38bf6dff08a8cd0e6b3b5282effda80c9e 100644
ced1f5
--- a/src/providers/ldap/sdap_async.h
ced1f5
+++ b/src/providers/ldap/sdap_async.h
ced1f5
@@ -266,13 +266,19 @@ int sdap_deref_search_recv(struct tevent_req *req,
ced1f5
                            size_t *reply_count,
ced1f5
                            struct sdap_deref_attrs ***reply);
ced1f5
 
ced1f5
+/*
ced1f5
+ * This request should only be ran against a Global Catalog connection
ced1f5
+ * because it uses a NULL search base to search all domains in the forest,
ced1f5
+ * which would return an error with an LDAP port:
ced1f5
+ *  https://technet.microsoft.com/en-us/library/cc755809(v=ws.10).aspx
ced1f5
+ */
ced1f5
 struct tevent_req *
ced1f5
-sdap_posix_check_send(TALLOC_CTX *memctx, struct tevent_context *ev,
ced1f5
-                      struct sdap_options *opts, struct sdap_handle *sh,
ced1f5
-                      int timeout);
ced1f5
+sdap_gc_posix_check_send(TALLOC_CTX *memctx, struct tevent_context *ev,
ced1f5
+                         struct sdap_options *opts, struct sdap_handle *sh,
ced1f5
+                         int timeout);
ced1f5
 
ced1f5
-int sdap_posix_check_recv(struct tevent_req *req,
ced1f5
-                          bool *_has_posix);
ced1f5
+int sdap_gc_posix_check_recv(struct tevent_req *req,
ced1f5
+                             bool *_has_posix);
ced1f5
 
ced1f5
 struct tevent_req *
ced1f5
 sdap_sd_search_send(TALLOC_CTX *memctx,
ced1f5
diff --git a/src/providers/ldap/sdap_async_enum.c b/src/providers/ldap/sdap_async_enum.c
ced1f5
index ec0c679823a8cd9820bb978f77799a3f86621271..ea9d51adc7f94145cd7e689893bf7fd81028c5bb 100644
ced1f5
--- a/src/providers/ldap/sdap_async_enum.c
ced1f5
+++ b/src/providers/ldap/sdap_async_enum.c
ced1f5
@@ -200,10 +200,10 @@ static void sdap_dom_enum_ex_get_users(struct tevent_req *subreq)
ced1f5
                                state->user_conn,
ced1f5
                                use_id_mapping,
ced1f5
                                true)) {
ced1f5
-        subreq = sdap_posix_check_send(state, state->ev, state->ctx->opts,
ced1f5
-                                       sdap_id_op_handle(state->user_op),
ced1f5
-                                       dp_opt_get_int(state->ctx->opts->basic,
ced1f5
-                                                      SDAP_SEARCH_TIMEOUT));
ced1f5
+        subreq = sdap_gc_posix_check_send(state, state->ev, state->ctx->opts,
ced1f5
+                                          sdap_id_op_handle(state->user_op),
ced1f5
+                                          dp_opt_get_int(state->ctx->opts->basic,
ced1f5
+                                                         SDAP_SEARCH_TIMEOUT));
ced1f5
         if (subreq == NULL) {
ced1f5
             tevent_req_error(req, ENOMEM);
ced1f5
             return;
ced1f5
@@ -233,7 +233,7 @@ static void sdap_dom_enum_ex_posix_check_done(struct tevent_req *subreq)
ced1f5
     struct sdap_dom_enum_ex_state *state = tevent_req_data(req,
ced1f5
                                                 struct sdap_dom_enum_ex_state);
ced1f5
 
ced1f5
-    ret = sdap_posix_check_recv(subreq, &has_posix);
ced1f5
+    ret = sdap_gc_posix_check_recv(subreq, &has_posix);
ced1f5
     talloc_zfree(subreq);
ced1f5
     if (ret != EOK && ret != ERR_NO_POSIX) {
ced1f5
         /* We can only finish the id_op on error as the connection
ced1f5
-- 
ced1f5
2.14.3
ced1f5