|
|
cdf651 |
From 5fcce16c212037b5193556dc2f6bcb7e4d7f0f85 Mon Sep 17 00:00:00 2001
|
|
|
cdf651 |
From: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
cdf651 |
Date: Sat, 30 Jun 2018 13:21:18 +0200
|
|
|
cdf651 |
Subject: [PATCH] LDAP: Remove the legacy POSIX check itself
|
|
|
cdf651 |
MIME-Version: 1.0
|
|
|
cdf651 |
Content-Type: text/plain; charset=UTF-8
|
|
|
cdf651 |
Content-Transfer-Encoding: 8bit
|
|
|
cdf651 |
|
|
|
cdf651 |
This code is no longer needed now.
|
|
|
cdf651 |
|
|
|
cdf651 |
Related:
|
|
|
cdf651 |
https://pagure.io/SSSD/sssd/issue/3755
|
|
|
cdf651 |
|
|
|
cdf651 |
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
|
|
|
cdf651 |
(cherry picked from commit 5b2b6493dfb3c1f2cb945356e34c70d8c5d64185)
|
|
|
cdf651 |
|
|
|
cdf651 |
DOWNSTREAM:
|
|
|
cdf651 |
Resolves: rhbz#1582975 - The search filter for detecting POSIX attributes in global catalog is too broad and can cause a high load on the servers
|
|
|
cdf651 |
---
|
|
|
cdf651 |
src/providers/ad/ad_common.c | 2 -
|
|
|
cdf651 |
src/providers/ldap/ldap_common.c | 17 ---
|
|
|
cdf651 |
src/providers/ldap/ldap_common.h | 7 --
|
|
|
cdf651 |
src/providers/ldap/sdap.h | 1 -
|
|
|
cdf651 |
src/providers/ldap/sdap_async.c | 174 -------------------------------
|
|
|
cdf651 |
src/providers/ldap/sdap_async.h | 13 ---
|
|
|
cdf651 |
6 files changed, 214 deletions(-)
|
|
|
cdf651 |
|
|
|
cdf651 |
diff --git a/src/providers/ad/ad_common.c b/src/providers/ad/ad_common.c
|
|
|
cdf651 |
index eaf0814f1aaf51a5085e992efa633240f32c498e..6d395cfb1d4148e803a656a8f7205fe13570085b 100644
|
|
|
cdf651 |
--- a/src/providers/ad/ad_common.c
|
|
|
cdf651 |
+++ b/src/providers/ad/ad_common.c
|
|
|
cdf651 |
@@ -1388,7 +1388,6 @@ ad_gc_conn_list(TALLOC_CTX *mem_ctx, struct ad_id_ctx *ad_ctx,
|
|
|
cdf651 |
clist[cindex] = ad_ctx->gc_ctx;
|
|
|
cdf651 |
clist[cindex]->ignore_mark_offline = true;
|
|
|
cdf651 |
clist[cindex]->no_mpg_user_fallback = true;
|
|
|
cdf651 |
- clist[cindex]->check_posix_attrs = true;
|
|
|
cdf651 |
cindex++;
|
|
|
cdf651 |
}
|
|
|
cdf651 |
|
|
|
cdf651 |
@@ -1435,7 +1434,6 @@ ad_user_conn_list(TALLOC_CTX *mem_ctx,
|
|
|
cdf651 |
&& IS_SUBDOMAIN(dom)) {
|
|
|
cdf651 |
clist[cindex] = ad_ctx->gc_ctx;
|
|
|
cdf651 |
clist[cindex]->ignore_mark_offline = true;
|
|
|
cdf651 |
- clist[cindex]->check_posix_attrs = true;
|
|
|
cdf651 |
cindex++;
|
|
|
cdf651 |
}
|
|
|
cdf651 |
|
|
|
cdf651 |
diff --git a/src/providers/ldap/ldap_common.c b/src/providers/ldap/ldap_common.c
|
|
|
cdf651 |
index a0a9b8523310b2551ee992f8d0c2e369dafaa56d..9cd8ec09c7fdc6bd1c8d64da150178f483f2a5a3 100644
|
|
|
cdf651 |
--- a/src/providers/ldap/ldap_common.c
|
|
|
cdf651 |
+++ b/src/providers/ldap/ldap_common.c
|
|
|
cdf651 |
@@ -884,20 +884,3 @@ sdap_id_ctx_new(TALLOC_CTX *mem_ctx, struct be_ctx *bectx,
|
|
|
cdf651 |
|
|
|
cdf651 |
return sdap_ctx;
|
|
|
cdf651 |
}
|
|
|
cdf651 |
-
|
|
|
cdf651 |
-bool should_run_posix_check(struct sdap_id_ctx *ctx,
|
|
|
cdf651 |
- struct sdap_id_conn_ctx *conn,
|
|
|
cdf651 |
- bool use_id_mapping,
|
|
|
cdf651 |
- bool posix_request)
|
|
|
cdf651 |
-{
|
|
|
cdf651 |
- if (use_id_mapping == false &&
|
|
|
cdf651 |
- posix_request == true &&
|
|
|
cdf651 |
- ctx->opts->schema_type == SDAP_SCHEMA_AD &&
|
|
|
cdf651 |
- conn->check_posix_attrs == true &&
|
|
|
cdf651 |
- ctx->srv_opts &&
|
|
|
cdf651 |
- ctx->srv_opts->posix_checked == false) {
|
|
|
cdf651 |
- return true;
|
|
|
cdf651 |
- }
|
|
|
cdf651 |
-
|
|
|
cdf651 |
- return false;
|
|
|
cdf651 |
-}
|
|
|
cdf651 |
diff --git a/src/providers/ldap/ldap_common.h b/src/providers/ldap/ldap_common.h
|
|
|
cdf651 |
index 3de3568cb28c258c00f9b522c0b9120adca81d81..6c08d789b339424649c938b845e7118f5ea88f73 100644
|
|
|
cdf651 |
--- a/src/providers/ldap/ldap_common.h
|
|
|
cdf651 |
+++ b/src/providers/ldap/ldap_common.h
|
|
|
cdf651 |
@@ -59,8 +59,6 @@ struct sdap_id_conn_ctx {
|
|
|
cdf651 |
bool ignore_mark_offline;
|
|
|
cdf651 |
/* do not fall back to user lookups for mpg domains on this connection */
|
|
|
cdf651 |
bool no_mpg_user_fallback;
|
|
|
cdf651 |
- /* check if this connection contains POSIX attributes */
|
|
|
cdf651 |
- bool check_posix_attrs;
|
|
|
cdf651 |
};
|
|
|
cdf651 |
|
|
|
cdf651 |
struct sdap_id_ctx {
|
|
|
cdf651 |
@@ -309,11 +307,6 @@ char *get_enterprise_principal_string_filter(TALLOC_CTX *mem_ctx,
|
|
|
cdf651 |
const char *princ,
|
|
|
cdf651 |
struct dp_option *sdap_basic_opts);
|
|
|
cdf651 |
|
|
|
cdf651 |
-bool should_run_posix_check(struct sdap_id_ctx *ctx,
|
|
|
cdf651 |
- struct sdap_id_conn_ctx *conn,
|
|
|
cdf651 |
- bool id_mapping,
|
|
|
cdf651 |
- bool posix_request);
|
|
|
cdf651 |
-
|
|
|
cdf651 |
char *sdap_get_access_filter(TALLOC_CTX *mem_ctx,
|
|
|
cdf651 |
const char *base_filter);
|
|
|
cdf651 |
|
|
|
cdf651 |
diff --git a/src/providers/ldap/sdap.h b/src/providers/ldap/sdap.h
|
|
|
cdf651 |
index e892c407103b18a296ae6baaf3dcfff11ca4bf31..0790544818633e26ee5a8fbdca556b8230b1df3f 100644
|
|
|
cdf651 |
--- a/src/providers/ldap/sdap.h
|
|
|
cdf651 |
+++ b/src/providers/ldap/sdap.h
|
|
|
cdf651 |
@@ -511,7 +511,6 @@ struct sdap_server_opts {
|
|
|
cdf651 |
char *max_group_value;
|
|
|
cdf651 |
char *max_service_value;
|
|
|
cdf651 |
char *max_sudo_value;
|
|
|
cdf651 |
- bool posix_checked;
|
|
|
cdf651 |
};
|
|
|
cdf651 |
|
|
|
cdf651 |
struct sdap_id_ctx;
|
|
|
cdf651 |
diff --git a/src/providers/ldap/sdap_async.c b/src/providers/ldap/sdap_async.c
|
|
|
cdf651 |
index 1e77b1c3c612d28a7d1f7e686cbc0b094b07c89d..8fc832ae5720acac07b0e2a24255f6c5e3d6994b 100644
|
|
|
cdf651 |
--- a/src/providers/ldap/sdap_async.c
|
|
|
cdf651 |
+++ b/src/providers/ldap/sdap_async.c
|
|
|
cdf651 |
@@ -2572,180 +2572,6 @@ int sdap_asq_search_recv(struct tevent_req *req,
|
|
|
cdf651 |
return EOK;
|
|
|
cdf651 |
}
|
|
|
cdf651 |
|
|
|
cdf651 |
-/* ==POSIX attribute presence test================================= */
|
|
|
cdf651 |
-static void sdap_gc_posix_check_done(struct tevent_req *subreq);
|
|
|
cdf651 |
-static errno_t sdap_gc_posix_check_parse(struct sdap_handle *sh,
|
|
|
cdf651 |
- struct sdap_msg *msg,
|
|
|
cdf651 |
- void *pvt);
|
|
|
cdf651 |
-
|
|
|
cdf651 |
-struct sdap_gc_posix_check_state {
|
|
|
cdf651 |
- struct tevent_context *ev;
|
|
|
cdf651 |
- struct sdap_options *opts;
|
|
|
cdf651 |
- struct sdap_handle *sh;
|
|
|
cdf651 |
- int timeout;
|
|
|
cdf651 |
-
|
|
|
cdf651 |
- const char **attrs;
|
|
|
cdf651 |
- const char *filter;
|
|
|
cdf651 |
-
|
|
|
cdf651 |
- bool has_posix;
|
|
|
cdf651 |
-};
|
|
|
cdf651 |
-
|
|
|
cdf651 |
-struct tevent_req *
|
|
|
cdf651 |
-sdap_gc_posix_check_send(TALLOC_CTX *memctx, struct tevent_context *ev,
|
|
|
cdf651 |
- struct sdap_options *opts, struct sdap_handle *sh,
|
|
|
cdf651 |
- int timeout)
|
|
|
cdf651 |
-{
|
|
|
cdf651 |
- struct tevent_req *req = NULL;
|
|
|
cdf651 |
- struct tevent_req *subreq = NULL;
|
|
|
cdf651 |
- struct sdap_gc_posix_check_state *state;
|
|
|
cdf651 |
- errno_t ret;
|
|
|
cdf651 |
-
|
|
|
cdf651 |
- req = tevent_req_create(memctx, &state, struct sdap_gc_posix_check_state);
|
|
|
cdf651 |
- if (req == NULL) {
|
|
|
cdf651 |
- return NULL;
|
|
|
cdf651 |
- }
|
|
|
cdf651 |
- state->ev = ev;
|
|
|
cdf651 |
- state->sh = sh;
|
|
|
cdf651 |
- state->opts = opts;
|
|
|
cdf651 |
- state->timeout = timeout;
|
|
|
cdf651 |
-
|
|
|
cdf651 |
- state->attrs = talloc_array(state, const char *, 4);
|
|
|
cdf651 |
- if (state->attrs == NULL) {
|
|
|
cdf651 |
- ret = ENOMEM;
|
|
|
cdf651 |
- goto fail;
|
|
|
cdf651 |
- }
|
|
|
cdf651 |
- state->attrs[0] = "objectclass";
|
|
|
cdf651 |
- state->attrs[1] = opts->user_map[SDAP_AT_USER_UID].name;
|
|
|
cdf651 |
- state->attrs[2] = opts->group_map[SDAP_AT_GROUP_GID].name;
|
|
|
cdf651 |
- state->attrs[3] = NULL;
|
|
|
cdf651 |
-
|
|
|
cdf651 |
- state->filter = talloc_asprintf(state,
|
|
|
cdf651 |
- "(|(&(%s=*)(objectclass=%s))(&(%s=*)(objectclass=%s)))",
|
|
|
cdf651 |
- opts->user_map[SDAP_AT_USER_UID].name,
|
|
|
cdf651 |
- opts->user_map[SDAP_OC_USER].name,
|
|
|
cdf651 |
- opts->group_map[SDAP_AT_GROUP_GID].name,
|
|
|
cdf651 |
- opts->group_map[SDAP_OC_GROUP].name);
|
|
|
cdf651 |
- if (state->filter == NULL) {
|
|
|
cdf651 |
- ret = ENOMEM;
|
|
|
cdf651 |
- goto fail;
|
|
|
cdf651 |
- }
|
|
|
cdf651 |
-
|
|
|
cdf651 |
- subreq = sdap_get_generic_ext_send(state, state->ev, state->opts,
|
|
|
cdf651 |
- state->sh,
|
|
|
cdf651 |
- "",
|
|
|
cdf651 |
- LDAP_SCOPE_SUBTREE, state->filter,
|
|
|
cdf651 |
- state->attrs,
|
|
|
cdf651 |
- NULL, NULL, 1, state->timeout,
|
|
|
cdf651 |
- sdap_gc_posix_check_parse, state,
|
|
|
cdf651 |
- SDAP_SRCH_FLG_SIZELIMIT_SILENT);
|
|
|
cdf651 |
- if (subreq == NULL) {
|
|
|
cdf651 |
- ret = ENOMEM;
|
|
|
cdf651 |
- goto fail;
|
|
|
cdf651 |
- }
|
|
|
cdf651 |
- tevent_req_set_callback(subreq, sdap_gc_posix_check_done, req);
|
|
|
cdf651 |
-
|
|
|
cdf651 |
- return req;
|
|
|
cdf651 |
-
|
|
|
cdf651 |
-fail:
|
|
|
cdf651 |
- tevent_req_error(req, ret);
|
|
|
cdf651 |
- tevent_req_post(req, ev);
|
|
|
cdf651 |
- return req;
|
|
|
cdf651 |
-}
|
|
|
cdf651 |
-
|
|
|
cdf651 |
-static errno_t sdap_gc_posix_check_parse(struct sdap_handle *sh,
|
|
|
cdf651 |
- struct sdap_msg *msg,
|
|
|
cdf651 |
- void *pvt)
|
|
|
cdf651 |
-{
|
|
|
cdf651 |
- struct berval **vals = NULL;
|
|
|
cdf651 |
- struct sdap_gc_posix_check_state *state =
|
|
|
cdf651 |
- talloc_get_type(pvt, struct sdap_gc_posix_check_state);
|
|
|
cdf651 |
- char *dn;
|
|
|
cdf651 |
- char *endptr;
|
|
|
cdf651 |
-
|
|
|
cdf651 |
- dn = ldap_get_dn(sh->ldap, msg->msg);
|
|
|
cdf651 |
- if (dn == NULL) {
|
|
|
cdf651 |
- DEBUG(SSSDBG_TRACE_LIBS,
|
|
|
cdf651 |
- "Search did not find any entry with POSIX attributes\n");
|
|
|
cdf651 |
- goto done;
|
|
|
cdf651 |
- }
|
|
|
cdf651 |
- DEBUG(SSSDBG_TRACE_LIBS, "Found [%s] with POSIX attributes\n", dn);
|
|
|
cdf651 |
- ldap_memfree(dn);
|
|
|
cdf651 |
-
|
|
|
cdf651 |
- vals = ldap_get_values_len(sh->ldap, msg->msg,
|
|
|
cdf651 |
- state->opts->user_map[SDAP_AT_USER_UID].name);
|
|
|
cdf651 |
- if (vals == NULL) {
|
|
|
cdf651 |
- vals = ldap_get_values_len(sh->ldap, msg->msg,
|
|
|
cdf651 |
- state->opts->group_map[SDAP_AT_GROUP_GID].name);
|
|
|
cdf651 |
- if (vals == NULL) {
|
|
|
cdf651 |
- DEBUG(SSSDBG_TRACE_LIBS, "Entry does not have POSIX attrs?\n");
|
|
|
cdf651 |
- goto done;
|
|
|
cdf651 |
- }
|
|
|
cdf651 |
- }
|
|
|
cdf651 |
-
|
|
|
cdf651 |
- if (vals[0] == NULL) {
|
|
|
cdf651 |
- DEBUG(SSSDBG_TRACE_LIBS, "No value for POSIX attr\n");
|
|
|
cdf651 |
- goto done;
|
|
|
cdf651 |
- }
|
|
|
cdf651 |
-
|
|
|
cdf651 |
- errno = 0;
|
|
|
cdf651 |
- strtouint32(vals[0]->bv_val, &endptr, 10);
|
|
|
cdf651 |
- if (errno || *endptr || (vals[0]->bv_val == endptr)) {
|
|
|
cdf651 |
- DEBUG(SSSDBG_MINOR_FAILURE,
|
|
|
cdf651 |
- "POSIX attribute is not a number: %s\n", vals[0]->bv_val);
|
|
|
cdf651 |
- }
|
|
|
cdf651 |
-
|
|
|
cdf651 |
- state->has_posix = true;
|
|
|
cdf651 |
-done:
|
|
|
cdf651 |
- ldap_value_free_len(vals);
|
|
|
cdf651 |
- return EOK;
|
|
|
cdf651 |
-}
|
|
|
cdf651 |
-
|
|
|
cdf651 |
-static void sdap_gc_posix_check_done(struct tevent_req *subreq)
|
|
|
cdf651 |
-{
|
|
|
cdf651 |
- struct tevent_req *req = tevent_req_callback_data(subreq,
|
|
|
cdf651 |
- struct tevent_req);
|
|
|
cdf651 |
- struct sdap_gc_posix_check_state *state =
|
|
|
cdf651 |
- tevent_req_data(req, struct sdap_gc_posix_check_state);
|
|
|
cdf651 |
- errno_t ret;
|
|
|
cdf651 |
-
|
|
|
cdf651 |
- ret = sdap_get_generic_ext_recv(subreq, NULL, NULL, NULL);
|
|
|
cdf651 |
- talloc_zfree(subreq);
|
|
|
cdf651 |
- if (ret != EOK) {
|
|
|
cdf651 |
- DEBUG(SSSDBG_OP_FAILURE,
|
|
|
cdf651 |
- "sdap_get_generic_ext_recv failed [%d]: %s\n",
|
|
|
cdf651 |
- ret, strerror(ret));
|
|
|
cdf651 |
- tevent_req_error(req, ret);
|
|
|
cdf651 |
- return;
|
|
|
cdf651 |
- }
|
|
|
cdf651 |
-
|
|
|
cdf651 |
- /* Positive hit is definitive, no need to search other bases */
|
|
|
cdf651 |
- if (state->has_posix == true) {
|
|
|
cdf651 |
- DEBUG(SSSDBG_FUNC_DATA, "Server has POSIX attributes. Global Catalog will "
|
|
|
cdf651 |
- "be used for user and group lookups. Note that if "
|
|
|
cdf651 |
- "only a subset of POSIX attributes is present "
|
|
|
cdf651 |
- "in GC, the non-replicated attributes are "
|
|
|
cdf651 |
- "currently not read from the LDAP port\n");
|
|
|
cdf651 |
- tevent_req_done(req);
|
|
|
cdf651 |
- return;
|
|
|
cdf651 |
- }
|
|
|
cdf651 |
-
|
|
|
cdf651 |
- /* All bases done! */
|
|
|
cdf651 |
- DEBUG(SSSDBG_TRACE_LIBS, "Cycled through all bases\n");
|
|
|
cdf651 |
- tevent_req_done(req);
|
|
|
cdf651 |
-}
|
|
|
cdf651 |
-
|
|
|
cdf651 |
-int sdap_gc_posix_check_recv(struct tevent_req *req,
|
|
|
cdf651 |
- bool *_has_posix)
|
|
|
cdf651 |
-{
|
|
|
cdf651 |
- struct sdap_gc_posix_check_state *state = tevent_req_data(req,
|
|
|
cdf651 |
- struct sdap_gc_posix_check_state);
|
|
|
cdf651 |
-
|
|
|
cdf651 |
- TEVENT_REQ_RETURN_ON_ERROR(req);
|
|
|
cdf651 |
-
|
|
|
cdf651 |
- *_has_posix = state->has_posix;
|
|
|
cdf651 |
- return EOK;
|
|
|
cdf651 |
-}
|
|
|
cdf651 |
-
|
|
|
cdf651 |
/* ==Generic Deref Search============================================ */
|
|
|
cdf651 |
enum sdap_deref_type {
|
|
|
cdf651 |
SDAP_DEREF_OPENLDAP,
|
|
|
cdf651 |
diff --git a/src/providers/ldap/sdap_async.h b/src/providers/ldap/sdap_async.h
|
|
|
cdf651 |
index 6ca3ed8d82ea7e4cb049b1c65c639b2773b8c296..6d09aca7a3465df4503991f0dc82e2af3871ccd5 100644
|
|
|
cdf651 |
--- a/src/providers/ldap/sdap_async.h
|
|
|
cdf651 |
+++ b/src/providers/ldap/sdap_async.h
|
|
|
cdf651 |
@@ -281,19 +281,6 @@ int sdap_deref_search_recv(struct tevent_req *req,
|
|
|
cdf651 |
size_t *reply_count,
|
|
|
cdf651 |
struct sdap_deref_attrs ***reply);
|
|
|
cdf651 |
|
|
|
cdf651 |
-/*
|
|
|
cdf651 |
- * This request should only be ran against a Global Catalog connection
|
|
|
cdf651 |
- * because it uses a NULL search base to search all domains in the forest,
|
|
|
cdf651 |
- * which would return an error with an LDAP port:
|
|
|
cdf651 |
- * https://technet.microsoft.com/en-us/library/cc755809(v=ws.10).aspx
|
|
|
cdf651 |
- */
|
|
|
cdf651 |
-struct tevent_req *
|
|
|
cdf651 |
-sdap_gc_posix_check_send(TALLOC_CTX *memctx, struct tevent_context *ev,
|
|
|
cdf651 |
- struct sdap_options *opts, struct sdap_handle *sh,
|
|
|
cdf651 |
- int timeout);
|
|
|
cdf651 |
-
|
|
|
cdf651 |
-int sdap_gc_posix_check_recv(struct tevent_req *req,
|
|
|
cdf651 |
- bool *_has_posix);
|
|
|
cdf651 |
|
|
|
cdf651 |
struct tevent_req *
|
|
|
cdf651 |
sdap_sd_search_send(TALLOC_CTX *memctx,
|
|
|
cdf651 |
--
|
|
|
cdf651 |
2.17.1
|
|
|
cdf651 |
|