|
|
71e593 |
From 65c689876b89e1ae2a1d214d509e8ef4a611cd4c Mon Sep 17 00:00:00 2001
|
|
|
71e593 |
From: =?UTF-8?q?Pavel=20B=C5=99ezina?= <pbrezina@redhat.com>
|
|
|
71e593 |
Date: Wed, 5 Sep 2018 13:51:55 +0200
|
|
|
71e593 |
Subject: [PATCH 24/28] dp: set be_ctx->provider as part of dp_init request
|
|
|
71e593 |
|
|
|
71e593 |
Backend context is overused inside sssd code even during its initialization.
|
|
|
71e593 |
Some parts of initialization code requires access to be_ctx->provider so we
|
|
|
71e593 |
must make it available as soon as possible.
|
|
|
71e593 |
|
|
|
71e593 |
Better solution would be to always use 'provider' directly in initialization
|
|
|
71e593 |
but this makes it safer for any future changes as one does not have to keep
|
|
|
71e593 |
in mind when it is safe to use be_ctx->provider and when not. Now it is
|
|
|
71e593 |
always safe.
|
|
|
71e593 |
|
|
|
71e593 |
Resolves:
|
|
|
71e593 |
https://pagure.io/SSSD/sssd/issue/3812
|
|
|
71e593 |
|
|
|
71e593 |
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
71e593 |
(cherry picked from commit 4c5a1afa0df41aac05d34455c6e54a6f52a8dd28)
|
|
|
71e593 |
---
|
|
|
71e593 |
src/providers/data_provider/dp.c | 21 +++++++++++++--------
|
|
|
71e593 |
src/providers/data_provider/dp.h | 1 -
|
|
|
71e593 |
src/providers/data_provider_be.c | 2 +-
|
|
|
71e593 |
src/providers/proxy/proxy_init.c | 2 +-
|
|
|
71e593 |
4 files changed, 15 insertions(+), 11 deletions(-)
|
|
|
71e593 |
|
|
|
71e593 |
diff --git a/src/providers/data_provider/dp.c b/src/providers/data_provider/dp.c
|
|
|
71e593 |
index fd19d2803334726d0b59e76cc6c936a62d72d5e5..bd003c8b3e2919409941c11b3f1aa76ed074da7d 100644
|
|
|
71e593 |
--- a/src/providers/data_provider/dp.c
|
|
|
71e593 |
+++ b/src/providers/data_provider/dp.c
|
|
|
71e593 |
@@ -120,6 +120,7 @@ static int dp_destructor(struct data_provider *provider)
|
|
|
71e593 |
}
|
|
|
71e593 |
|
|
|
71e593 |
struct dp_init_state {
|
|
|
71e593 |
+ struct be_ctx *be_ctx;
|
|
|
71e593 |
struct data_provider *provider;
|
|
|
71e593 |
char *sbus_name;
|
|
|
71e593 |
};
|
|
|
71e593 |
@@ -158,6 +159,7 @@ dp_init_send(TALLOC_CTX *mem_ctx,
|
|
|
71e593 |
goto done;
|
|
|
71e593 |
}
|
|
|
71e593 |
|
|
|
71e593 |
+ state->be_ctx = be_ctx;
|
|
|
71e593 |
state->provider->ev = ev;
|
|
|
71e593 |
state->provider->uid = uid;
|
|
|
71e593 |
state->provider->gid = gid;
|
|
|
71e593 |
@@ -224,12 +226,14 @@ static void dp_init_done(struct tevent_req *subreq)
|
|
|
71e593 |
sbus_server_set_on_connection(state->provider->sbus_server,
|
|
|
71e593 |
dp_client_init, state->provider);
|
|
|
71e593 |
|
|
|
71e593 |
+ /* be_ctx->provider must be accessible from modules and targets */
|
|
|
71e593 |
+ state->be_ctx->provider = talloc_steal(state->be_ctx, state->provider);
|
|
|
71e593 |
+
|
|
|
71e593 |
ret = dp_init_modules(state->provider, &state->provider->modules);
|
|
|
71e593 |
if (ret != EOK) {
|
|
|
71e593 |
DEBUG(SSSDBG_CRIT_FAILURE, "Unable to initialize DP modules "
|
|
|
71e593 |
"[%d]: %s\n", ret, sss_strerror(ret));
|
|
|
71e593 |
- tevent_req_error(req, ret);
|
|
|
71e593 |
- return;
|
|
|
71e593 |
+ goto done;
|
|
|
71e593 |
}
|
|
|
71e593 |
|
|
|
71e593 |
ret = dp_init_targets(state->provider, state->provider->be_ctx,
|
|
|
71e593 |
@@ -237,25 +241,27 @@ static void dp_init_done(struct tevent_req *subreq)
|
|
|
71e593 |
if (ret != EOK) {
|
|
|
71e593 |
DEBUG(SSSDBG_CRIT_FAILURE, "Unable to initialize DP targets "
|
|
|
71e593 |
"[%d]: %s\n", ret, sss_strerror(ret));
|
|
|
71e593 |
- tevent_req_error(req, ret);
|
|
|
71e593 |
- return;
|
|
|
71e593 |
+ goto done;
|
|
|
71e593 |
}
|
|
|
71e593 |
|
|
|
71e593 |
ret = dp_init_interface(state->provider);
|
|
|
71e593 |
if (ret != EOK) {
|
|
|
71e593 |
DEBUG(SSSDBG_CRIT_FAILURE, "Unable to initialize DP interface "
|
|
|
71e593 |
"[%d]: %s\n", ret, sss_strerror(ret));
|
|
|
71e593 |
+ goto done;
|
|
|
71e593 |
+ }
|
|
|
71e593 |
+
|
|
|
71e593 |
+done:
|
|
|
71e593 |
+ if (ret != EOK) {
|
|
|
71e593 |
+ talloc_zfree(state->be_ctx->provider);
|
|
|
71e593 |
tevent_req_error(req, ret);
|
|
|
71e593 |
- return;
|
|
|
71e593 |
}
|
|
|
71e593 |
|
|
|
71e593 |
tevent_req_done(req);
|
|
|
71e593 |
- return;
|
|
|
71e593 |
}
|
|
|
71e593 |
|
|
|
71e593 |
errno_t dp_init_recv(TALLOC_CTX *mem_ctx,
|
|
|
71e593 |
struct tevent_req *req,
|
|
|
71e593 |
- struct data_provider **_provider,
|
|
|
71e593 |
const char **_sbus_name)
|
|
|
71e593 |
{
|
|
|
71e593 |
struct dp_init_state *state;
|
|
|
71e593 |
@@ -263,7 +269,6 @@ errno_t dp_init_recv(TALLOC_CTX *mem_ctx,
|
|
|
71e593 |
|
|
|
71e593 |
TEVENT_REQ_RETURN_ON_ERROR(req);
|
|
|
71e593 |
|
|
|
71e593 |
- *_provider = talloc_steal(mem_ctx, state->provider);
|
|
|
71e593 |
*_sbus_name = talloc_steal(mem_ctx, state->sbus_name);
|
|
|
71e593 |
|
|
|
71e593 |
return EOK;
|
|
|
71e593 |
diff --git a/src/providers/data_provider/dp.h b/src/providers/data_provider/dp.h
|
|
|
71e593 |
index 33e6e6567bc56ac8ac8180edca01e8d937d0d39d..0028eb1cbdcb7e9db004a8c9c2f6c13b317cae7d 100644
|
|
|
71e593 |
--- a/src/providers/data_provider/dp.h
|
|
|
71e593 |
+++ b/src/providers/data_provider/dp.h
|
|
|
71e593 |
@@ -117,7 +117,6 @@ dp_init_send(TALLOC_CTX *mem_ctx,
|
|
|
71e593 |
|
|
|
71e593 |
errno_t dp_init_recv(TALLOC_CTX *mem_ctx,
|
|
|
71e593 |
struct tevent_req *req,
|
|
|
71e593 |
- struct data_provider **_provider,
|
|
|
71e593 |
const char **_sbus_name);
|
|
|
71e593 |
|
|
|
71e593 |
bool _dp_target_enabled(struct data_provider *provider,
|
|
|
71e593 |
diff --git a/src/providers/data_provider_be.c b/src/providers/data_provider_be.c
|
|
|
71e593 |
index 670ddb477cb7363b5f831e8b7b50b6b7f39c6289..6d2477e34b02ae84d241714b72296c62a2560bb1 100644
|
|
|
71e593 |
--- a/src/providers/data_provider_be.c
|
|
|
71e593 |
+++ b/src/providers/data_provider_be.c
|
|
|
71e593 |
@@ -541,7 +541,7 @@ static void dp_initialized(struct tevent_req *req)
|
|
|
71e593 |
|
|
|
71e593 |
be_ctx = tevent_req_callback_data(req, struct be_ctx);
|
|
|
71e593 |
|
|
|
71e593 |
- ret = dp_init_recv(be_ctx, req, &be_ctx->provider, &be_ctx->sbus_name);
|
|
|
71e593 |
+ ret = dp_init_recv(be_ctx, req, &be_ctx->sbus_name);
|
|
|
71e593 |
talloc_zfree(req);
|
|
|
71e593 |
if (ret != EOK) {
|
|
|
71e593 |
goto done;
|
|
|
71e593 |
diff --git a/src/providers/proxy/proxy_init.c b/src/providers/proxy/proxy_init.c
|
|
|
71e593 |
index 98c6dd1798dbf98419db71004cb55fcf21f58f81..32343a3bf52df866708a69f3f4364a4c65c1d3c6 100644
|
|
|
71e593 |
--- a/src/providers/proxy/proxy_init.c
|
|
|
71e593 |
+++ b/src/providers/proxy/proxy_init.c
|
|
|
71e593 |
@@ -214,7 +214,7 @@ static errno_t proxy_init_auth_ctx(TALLOC_CTX *mem_ctx,
|
|
|
71e593 |
goto done;
|
|
|
71e593 |
}
|
|
|
71e593 |
|
|
|
71e593 |
- ret = proxy_client_init(dp_sbus_conn(provider), auth_ctx);
|
|
|
71e593 |
+ ret = proxy_client_init(dp_sbus_conn(be_ctx->provider), auth_ctx);
|
|
|
71e593 |
if (ret != EOK) {
|
|
|
71e593 |
goto done;
|
|
|
71e593 |
}
|
|
|
71e593 |
--
|
|
|
71e593 |
2.14.4
|