|
|
d6181b |
From 330507ab3146e877391ff85d4bf6be9ce069e2bd Mon Sep 17 00:00:00 2001
|
|
|
d6181b |
From: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
d6181b |
Date: Tue, 25 Jun 2019 15:05:59 +0200
|
|
|
d6181b |
Subject: [PATCH 41/48] BE/IPA/AD/LDAP: Initialize the refresh callback from a
|
|
|
d6181b |
list to reduce logic duplication
|
|
|
d6181b |
|
|
|
d6181b |
Related: https://pagure.io/SSSD/sssd/issue/4012
|
|
|
d6181b |
|
|
|
d6181b |
This patch slightly increases the line count, but on the other hand the
|
|
|
d6181b |
code is now more declarative and contains less logic, which should
|
|
|
d6181b |
hopefully decrease the maintenance cost in the future.
|
|
|
d6181b |
|
|
|
d6181b |
Reviewed-by: Sumit Bose <sbose@redhat.com>
|
|
|
d6181b |
---
|
|
|
d6181b |
src/providers/ad/ad_refresh.c | 66 ++++++----------
|
|
|
d6181b |
src/providers/be_refresh.c | 126 +++++++++++++++++++++++-------
|
|
|
d6181b |
src/providers/be_refresh.h | 17 ++--
|
|
|
d6181b |
src/providers/ipa/ipa_refresh.c | 70 ++++++-----------
|
|
|
d6181b |
src/providers/ldap/sdap_refresh.c | 58 ++++++--------
|
|
|
d6181b |
5 files changed, 179 insertions(+), 158 deletions(-)
|
|
|
d6181b |
|
|
|
d6181b |
diff --git a/src/providers/ad/ad_refresh.c b/src/providers/ad/ad_refresh.c
|
|
|
d6181b |
index f0130cbaf..ed51b305a 100644
|
|
|
d6181b |
--- a/src/providers/ad/ad_refresh.c
|
|
|
d6181b |
+++ b/src/providers/ad/ad_refresh.c
|
|
|
d6181b |
@@ -260,52 +260,32 @@ errno_t ad_refresh_init(struct be_ctx *be_ctx,
|
|
|
d6181b |
struct ad_id_ctx *id_ctx)
|
|
|
d6181b |
{
|
|
|
d6181b |
errno_t ret;
|
|
|
d6181b |
-
|
|
|
d6181b |
- ret = be_refresh_ctx_init(be_ctx, SYSDB_SID_STR);
|
|
|
d6181b |
+ struct be_refresh_cb ad_refresh_callbacks[] = {
|
|
|
d6181b |
+ { .send_fn = ad_refresh_initgroups_send,
|
|
|
d6181b |
+ .recv_fn = ad_refresh_initgroups_recv,
|
|
|
d6181b |
+ .pvt = id_ctx,
|
|
|
d6181b |
+ },
|
|
|
d6181b |
+ { .send_fn = ad_refresh_users_send,
|
|
|
d6181b |
+ .recv_fn = ad_refresh_users_recv,
|
|
|
d6181b |
+ .pvt = id_ctx,
|
|
|
d6181b |
+ },
|
|
|
d6181b |
+ { .send_fn = ad_refresh_groups_send,
|
|
|
d6181b |
+ .recv_fn = ad_refresh_groups_recv,
|
|
|
d6181b |
+ .pvt = id_ctx,
|
|
|
d6181b |
+ },
|
|
|
d6181b |
+ { .send_fn = ad_refresh_netgroups_send,
|
|
|
d6181b |
+ .recv_fn = ad_refresh_netgroups_recv,
|
|
|
d6181b |
+ .pvt = id_ctx,
|
|
|
d6181b |
+ },
|
|
|
d6181b |
+ };
|
|
|
d6181b |
+
|
|
|
d6181b |
+ ret = be_refresh_ctx_init_with_callbacks(be_ctx,
|
|
|
d6181b |
+ SYSDB_SID_STR,
|
|
|
d6181b |
+ ad_refresh_callbacks);
|
|
|
d6181b |
if (ret != EOK) {
|
|
|
d6181b |
- DEBUG(SSSDBG_FATAL_FAILURE, "Unable to initialize refresh_ctx\n");
|
|
|
d6181b |
+ DEBUG(SSSDBG_FATAL_FAILURE, "Unable to initialize background refresh\n");
|
|
|
d6181b |
return ret;
|
|
|
d6181b |
}
|
|
|
d6181b |
|
|
|
d6181b |
- ret = be_refresh_add_cb(be_ctx->refresh_ctx,
|
|
|
d6181b |
- BE_REFRESH_TYPE_INITGROUPS,
|
|
|
d6181b |
- ad_refresh_initgroups_send,
|
|
|
d6181b |
- ad_refresh_initgroups_recv,
|
|
|
d6181b |
- id_ctx);
|
|
|
d6181b |
- if (ret != EOK && ret != EEXIST) {
|
|
|
d6181b |
- DEBUG(SSSDBG_MINOR_FAILURE, "Periodical refresh of users "
|
|
|
d6181b |
- "will not work [%d]: %s\n", ret, strerror(ret));
|
|
|
d6181b |
- }
|
|
|
d6181b |
-
|
|
|
d6181b |
- ret = be_refresh_add_cb(be_ctx->refresh_ctx,
|
|
|
d6181b |
- BE_REFRESH_TYPE_USERS,
|
|
|
d6181b |
- ad_refresh_users_send,
|
|
|
d6181b |
- ad_refresh_users_recv,
|
|
|
d6181b |
- id_ctx);
|
|
|
d6181b |
- if (ret != EOK && ret != EEXIST) {
|
|
|
d6181b |
- DEBUG(SSSDBG_MINOR_FAILURE, "Periodical refresh of users "
|
|
|
d6181b |
- "will not work [%d]: %s\n", ret, strerror(ret));
|
|
|
d6181b |
- }
|
|
|
d6181b |
-
|
|
|
d6181b |
- ret = be_refresh_add_cb(be_ctx->refresh_ctx,
|
|
|
d6181b |
- BE_REFRESH_TYPE_GROUPS,
|
|
|
d6181b |
- ad_refresh_groups_send,
|
|
|
d6181b |
- ad_refresh_groups_recv,
|
|
|
d6181b |
- id_ctx);
|
|
|
d6181b |
- if (ret != EOK && ret != EEXIST) {
|
|
|
d6181b |
- DEBUG(SSSDBG_MINOR_FAILURE, "Periodical refresh of groups "
|
|
|
d6181b |
- "will not work [%d]: %s\n", ret, strerror(ret));
|
|
|
d6181b |
- }
|
|
|
d6181b |
-
|
|
|
d6181b |
- ret = be_refresh_add_cb(be_ctx->refresh_ctx,
|
|
|
d6181b |
- BE_REFRESH_TYPE_NETGROUPS,
|
|
|
d6181b |
- ad_refresh_netgroups_send,
|
|
|
d6181b |
- ad_refresh_netgroups_recv,
|
|
|
d6181b |
- id_ctx);
|
|
|
d6181b |
- if (ret != EOK && ret != EEXIST) {
|
|
|
d6181b |
- DEBUG(SSSDBG_MINOR_FAILURE, "Periodical refresh of netgroups "
|
|
|
d6181b |
- "will not work [%d]: %s\n", ret, strerror(ret));
|
|
|
d6181b |
- }
|
|
|
d6181b |
-
|
|
|
d6181b |
return ret;
|
|
|
d6181b |
}
|
|
|
d6181b |
diff --git a/src/providers/be_refresh.c b/src/providers/be_refresh.c
|
|
|
d6181b |
index 6945ca9e3..8f50e231d 100644
|
|
|
d6181b |
--- a/src/providers/be_refresh.c
|
|
|
d6181b |
+++ b/src/providers/be_refresh.c
|
|
|
d6181b |
@@ -138,21 +138,19 @@ static errno_t be_refresh_get_values(TALLOC_CTX *mem_ctx,
|
|
|
d6181b |
return ret;
|
|
|
d6181b |
}
|
|
|
d6181b |
|
|
|
d6181b |
-struct be_refresh_cb {
|
|
|
d6181b |
+struct be_refresh_cb_ctx {
|
|
|
d6181b |
const char *name;
|
|
|
d6181b |
const char *attr_name;
|
|
|
d6181b |
bool enabled;
|
|
|
d6181b |
- be_refresh_send_t send_fn;
|
|
|
d6181b |
- be_refresh_recv_t recv_fn;
|
|
|
d6181b |
- void *pvt;
|
|
|
d6181b |
+ struct be_refresh_cb cb;
|
|
|
d6181b |
};
|
|
|
d6181b |
|
|
|
d6181b |
struct be_refresh_ctx {
|
|
|
d6181b |
- struct be_refresh_cb callbacks[BE_REFRESH_TYPE_SENTINEL];
|
|
|
d6181b |
+ struct be_refresh_cb_ctx callbacks[BE_REFRESH_TYPE_SENTINEL];
|
|
|
d6181b |
};
|
|
|
d6181b |
|
|
|
d6181b |
-errno_t be_refresh_ctx_init(struct be_ctx *be_ctx,
|
|
|
d6181b |
- const char *attr_name)
|
|
|
d6181b |
+static errno_t be_refresh_ctx_init(struct be_ctx *be_ctx,
|
|
|
d6181b |
+ const char *attr_name)
|
|
|
d6181b |
{
|
|
|
d6181b |
struct be_refresh_ctx *ctx = NULL;
|
|
|
d6181b |
uint32_t refresh_interval;
|
|
|
d6181b |
@@ -193,13 +191,11 @@ errno_t be_refresh_ctx_init(struct be_ctx *be_ctx,
|
|
|
d6181b |
return EOK;
|
|
|
d6181b |
}
|
|
|
d6181b |
|
|
|
d6181b |
-errno_t be_refresh_add_cb(struct be_refresh_ctx *ctx,
|
|
|
d6181b |
- enum be_refresh_type type,
|
|
|
d6181b |
- be_refresh_send_t send_fn,
|
|
|
d6181b |
- be_refresh_recv_t recv_fn,
|
|
|
d6181b |
- void *pvt)
|
|
|
d6181b |
+static errno_t be_refresh_add_cb(struct be_refresh_ctx *ctx,
|
|
|
d6181b |
+ enum be_refresh_type type,
|
|
|
d6181b |
+ struct be_refresh_cb *cb)
|
|
|
d6181b |
{
|
|
|
d6181b |
- if (ctx == NULL || send_fn == NULL || recv_fn == NULL
|
|
|
d6181b |
+ if (ctx == NULL || cb->send_fn == NULL || cb->recv_fn == NULL
|
|
|
d6181b |
|| type >= BE_REFRESH_TYPE_SENTINEL) {
|
|
|
d6181b |
return EINVAL;
|
|
|
d6181b |
}
|
|
|
d6181b |
@@ -209,9 +205,78 @@ errno_t be_refresh_add_cb(struct be_refresh_ctx *ctx,
|
|
|
d6181b |
}
|
|
|
d6181b |
|
|
|
d6181b |
ctx->callbacks[type].enabled = true;
|
|
|
d6181b |
- ctx->callbacks[type].send_fn = send_fn;
|
|
|
d6181b |
- ctx->callbacks[type].recv_fn = recv_fn;
|
|
|
d6181b |
- ctx->callbacks[type].pvt = pvt;
|
|
|
d6181b |
+ ctx->callbacks[type].cb.send_fn = cb->send_fn;
|
|
|
d6181b |
+ ctx->callbacks[type].cb.recv_fn = cb->recv_fn;
|
|
|
d6181b |
+ ctx->callbacks[type].cb.pvt = cb->pvt;
|
|
|
d6181b |
+
|
|
|
d6181b |
+ return EOK;
|
|
|
d6181b |
+}
|
|
|
d6181b |
+
|
|
|
d6181b |
+static errno_t be_refresh_set_callbacks(struct be_refresh_ctx *refresh_ctx,
|
|
|
d6181b |
+ struct be_refresh_cb *callbacks)
|
|
|
d6181b |
+{
|
|
|
d6181b |
+ errno_t ret;
|
|
|
d6181b |
+
|
|
|
d6181b |
+ if (callbacks == NULL || refresh_ctx == NULL) {
|
|
|
d6181b |
+ return EINVAL;
|
|
|
d6181b |
+ }
|
|
|
d6181b |
+
|
|
|
d6181b |
+ ret = be_refresh_add_cb(refresh_ctx,
|
|
|
d6181b |
+ BE_REFRESH_TYPE_INITGROUPS,
|
|
|
d6181b |
+ &callbacks[BE_REFRESH_TYPE_INITGROUPS]);
|
|
|
d6181b |
+ if (ret != EOK && ret != EEXIST) {
|
|
|
d6181b |
+ DEBUG(SSSDBG_MINOR_FAILURE, "Periodical refresh of initgroups "
|
|
|
d6181b |
+ "will not work [%d]: %s\n", ret, strerror(ret));
|
|
|
d6181b |
+ }
|
|
|
d6181b |
+
|
|
|
d6181b |
+ ret = be_refresh_add_cb(refresh_ctx,
|
|
|
d6181b |
+ BE_REFRESH_TYPE_USERS,
|
|
|
d6181b |
+ &callbacks[BE_REFRESH_TYPE_USERS]);
|
|
|
d6181b |
+ if (ret != EOK && ret != EEXIST) {
|
|
|
d6181b |
+ DEBUG(SSSDBG_MINOR_FAILURE, "Periodical refresh of users "
|
|
|
d6181b |
+ "will not work [%d]: %s\n", ret, strerror(ret));
|
|
|
d6181b |
+ }
|
|
|
d6181b |
+
|
|
|
d6181b |
+ ret = be_refresh_add_cb(refresh_ctx,
|
|
|
d6181b |
+ BE_REFRESH_TYPE_GROUPS,
|
|
|
d6181b |
+ &callbacks[BE_REFRESH_TYPE_GROUPS]);
|
|
|
d6181b |
+ if (ret != EOK && ret != EEXIST) {
|
|
|
d6181b |
+ DEBUG(SSSDBG_MINOR_FAILURE, "Periodical refresh of groups "
|
|
|
d6181b |
+ "will not work [%d]: %s\n", ret, strerror(ret));
|
|
|
d6181b |
+ }
|
|
|
d6181b |
+
|
|
|
d6181b |
+ ret = be_refresh_add_cb(refresh_ctx,
|
|
|
d6181b |
+ BE_REFRESH_TYPE_NETGROUPS,
|
|
|
d6181b |
+ &callbacks[BE_REFRESH_TYPE_NETGROUPS]);
|
|
|
d6181b |
+ if (ret != EOK && ret != EEXIST) {
|
|
|
d6181b |
+ DEBUG(SSSDBG_MINOR_FAILURE, "Periodical refresh of netgroups "
|
|
|
d6181b |
+ "will not work [%d]: %s\n", ret, strerror(ret));
|
|
|
d6181b |
+ }
|
|
|
d6181b |
+
|
|
|
d6181b |
+ return EOK;
|
|
|
d6181b |
+}
|
|
|
d6181b |
+
|
|
|
d6181b |
+errno_t be_refresh_ctx_init_with_callbacks(struct be_ctx *be_ctx,
|
|
|
d6181b |
+ const char *attr_name,
|
|
|
d6181b |
+ struct be_refresh_cb *callbacks)
|
|
|
d6181b |
+{
|
|
|
d6181b |
+ errno_t ret;
|
|
|
d6181b |
+
|
|
|
d6181b |
+ if (be_ctx == NULL || attr_name == NULL || callbacks == NULL) {
|
|
|
d6181b |
+ return EINVAL;
|
|
|
d6181b |
+ }
|
|
|
d6181b |
+
|
|
|
d6181b |
+ ret = be_refresh_ctx_init(be_ctx, attr_name);
|
|
|
d6181b |
+ if (ret != EOK) {
|
|
|
d6181b |
+ DEBUG(SSSDBG_FATAL_FAILURE, "Unable to initialize refresh_ctx\n");
|
|
|
d6181b |
+ return ret;
|
|
|
d6181b |
+ }
|
|
|
d6181b |
+
|
|
|
d6181b |
+ ret = be_refresh_set_callbacks(be_ctx->refresh_ctx, callbacks);
|
|
|
d6181b |
+ if (ret != EOK) {
|
|
|
d6181b |
+ DEBUG(SSSDBG_FATAL_FAILURE, "Unable to initialize refresh callbacks\n");
|
|
|
d6181b |
+ return ENOMEM;
|
|
|
d6181b |
+ }
|
|
|
d6181b |
|
|
|
d6181b |
return EOK;
|
|
|
d6181b |
}
|
|
|
d6181b |
@@ -220,7 +285,7 @@ struct be_refresh_state {
|
|
|
d6181b |
struct tevent_context *ev;
|
|
|
d6181b |
struct be_ctx *be_ctx;
|
|
|
d6181b |
struct be_refresh_ctx *ctx;
|
|
|
d6181b |
- struct be_refresh_cb *cb;
|
|
|
d6181b |
+ struct be_refresh_cb_ctx *cb_ctx;
|
|
|
d6181b |
|
|
|
d6181b |
struct sss_domain_info *domain;
|
|
|
d6181b |
enum be_refresh_type index;
|
|
|
d6181b |
@@ -308,10 +373,11 @@ static errno_t be_refresh_step(struct tevent_req *req)
|
|
|
d6181b |
|
|
|
d6181b |
while (state->domain != NULL) {
|
|
|
d6181b |
/* find first enabled callback */
|
|
|
d6181b |
- state->cb = &state->ctx->callbacks[state->index];
|
|
|
d6181b |
- while (state->index != BE_REFRESH_TYPE_SENTINEL && !state->cb->enabled) {
|
|
|
d6181b |
+ state->cb_ctx = &state->ctx->callbacks[state->index];
|
|
|
d6181b |
+ while (state->index != BE_REFRESH_TYPE_SENTINEL
|
|
|
d6181b |
+ && !state->cb_ctx->enabled) {
|
|
|
d6181b |
state->index++;
|
|
|
d6181b |
- state->cb = &state->ctx->callbacks[state->index];
|
|
|
d6181b |
+ state->cb_ctx = &state->ctx->callbacks[state->index];
|
|
|
d6181b |
}
|
|
|
d6181b |
|
|
|
d6181b |
/* if not found than continue with next domain */
|
|
|
d6181b |
@@ -322,14 +388,16 @@ static errno_t be_refresh_step(struct tevent_req *req)
|
|
|
d6181b |
continue;
|
|
|
d6181b |
}
|
|
|
d6181b |
|
|
|
d6181b |
- if (state->cb->send_fn == NULL || state->cb->recv_fn == NULL) {
|
|
|
d6181b |
+ if (state->cb_ctx->cb.send_fn == NULL
|
|
|
d6181b |
+ || state->cb_ctx->cb.recv_fn == NULL) {
|
|
|
d6181b |
DEBUG(SSSDBG_CRIT_FAILURE, "Invalid parameters!\n");
|
|
|
d6181b |
ret = ERR_INTERNAL;
|
|
|
d6181b |
goto done;
|
|
|
d6181b |
}
|
|
|
d6181b |
|
|
|
d6181b |
talloc_zfree(state->refresh_values);
|
|
|
d6181b |
- ret = be_refresh_get_values(state, state->index, state->cb->attr_name,
|
|
|
d6181b |
+ ret = be_refresh_get_values(state, state->index,
|
|
|
d6181b |
+ state->cb_ctx->attr_name,
|
|
|
d6181b |
state->domain, state->period,
|
|
|
d6181b |
&state->refresh_values);
|
|
|
d6181b |
if (ret != EOK) {
|
|
|
d6181b |
@@ -343,7 +411,9 @@ static errno_t be_refresh_step(struct tevent_req *req)
|
|
|
d6181b |
state->refresh_val_size++);
|
|
|
d6181b |
|
|
|
d6181b |
DEBUG(SSSDBG_TRACE_FUNC, "Refreshing %zu %s in domain %s\n",
|
|
|
d6181b |
- state->refresh_val_size, state->cb->name, state->domain->name);
|
|
|
d6181b |
+ state->refresh_val_size,
|
|
|
d6181b |
+ state->cb_ctx->name,
|
|
|
d6181b |
+ state->domain->name);
|
|
|
d6181b |
|
|
|
d6181b |
ret = be_refresh_batch_step(req, 0);
|
|
|
d6181b |
if (ret == EOK) {
|
|
|
d6181b |
@@ -416,10 +486,10 @@ static void be_refresh_batch_step_wakeup(struct tevent_context *ev,
|
|
|
d6181b |
state = tevent_req_data(req, struct be_refresh_state);
|
|
|
d6181b |
|
|
|
d6181b |
DEBUG(SSSDBG_TRACE_INTERNAL, "Issuing refresh\n");
|
|
|
d6181b |
- subreq = state->cb->send_fn(state, state->ev, state->be_ctx,
|
|
|
d6181b |
- state->domain,
|
|
|
d6181b |
- state->refresh_batch,
|
|
|
d6181b |
- state->cb->pvt);
|
|
|
d6181b |
+ subreq = state->cb_ctx->cb.send_fn(state, state->ev, state->be_ctx,
|
|
|
d6181b |
+ state->domain,
|
|
|
d6181b |
+ state->refresh_batch,
|
|
|
d6181b |
+ state->cb_ctx->cb.pvt);
|
|
|
d6181b |
if (subreq == NULL) {
|
|
|
d6181b |
tevent_req_error(req, ENOMEM);
|
|
|
d6181b |
return;
|
|
|
d6181b |
@@ -436,7 +506,7 @@ static void be_refresh_done(struct tevent_req *subreq)
|
|
|
d6181b |
req = tevent_req_callback_data(subreq, struct tevent_req);
|
|
|
d6181b |
state = tevent_req_data(req, struct be_refresh_state);
|
|
|
d6181b |
|
|
|
d6181b |
- ret = state->cb->recv_fn(subreq);
|
|
|
d6181b |
+ ret = state->cb_ctx->cb.recv_fn(subreq);
|
|
|
d6181b |
talloc_zfree(subreq);
|
|
|
d6181b |
if (ret != EOK) {
|
|
|
d6181b |
goto done;
|
|
|
d6181b |
diff --git a/src/providers/be_refresh.h b/src/providers/be_refresh.h
|
|
|
d6181b |
index 4ac5b70c2..42d73d938 100644
|
|
|
d6181b |
--- a/src/providers/be_refresh.h
|
|
|
d6181b |
+++ b/src/providers/be_refresh.h
|
|
|
d6181b |
@@ -51,16 +51,17 @@ enum be_refresh_type {
|
|
|
d6181b |
BE_REFRESH_TYPE_SENTINEL
|
|
|
d6181b |
};
|
|
|
d6181b |
|
|
|
d6181b |
-struct be_refresh_ctx;
|
|
|
d6181b |
+struct be_refresh_cb {
|
|
|
d6181b |
+ be_refresh_send_t send_fn;
|
|
|
d6181b |
+ be_refresh_recv_t recv_fn;
|
|
|
d6181b |
+ void *pvt;
|
|
|
d6181b |
+};
|
|
|
d6181b |
|
|
|
d6181b |
-errno_t be_refresh_ctx_init(struct be_ctx *be_ctx,
|
|
|
d6181b |
- const char *attr_name);
|
|
|
d6181b |
+struct be_refresh_ctx;
|
|
|
d6181b |
|
|
|
d6181b |
-errno_t be_refresh_add_cb(struct be_refresh_ctx *ctx,
|
|
|
d6181b |
- enum be_refresh_type type,
|
|
|
d6181b |
- be_refresh_send_t send_fn,
|
|
|
d6181b |
- be_refresh_recv_t recv_fn,
|
|
|
d6181b |
- void *pvt);
|
|
|
d6181b |
+errno_t be_refresh_ctx_init_with_callbacks(struct be_ctx *be_ctx,
|
|
|
d6181b |
+ const char *attr_name,
|
|
|
d6181b |
+ struct be_refresh_cb *callbacks);
|
|
|
d6181b |
|
|
|
d6181b |
struct tevent_req *be_refresh_send(TALLOC_CTX *mem_ctx,
|
|
|
d6181b |
struct tevent_context *ev,
|
|
|
d6181b |
diff --git a/src/providers/ipa/ipa_refresh.c b/src/providers/ipa/ipa_refresh.c
|
|
|
d6181b |
index bb47b0edf..7b05cf9e4 100644
|
|
|
d6181b |
--- a/src/providers/ipa/ipa_refresh.c
|
|
|
d6181b |
+++ b/src/providers/ipa/ipa_refresh.c
|
|
|
d6181b |
@@ -240,52 +240,32 @@ errno_t ipa_refresh_init(struct be_ctx *be_ctx,
|
|
|
d6181b |
struct ipa_id_ctx *id_ctx)
|
|
|
d6181b |
{
|
|
|
d6181b |
errno_t ret;
|
|
|
d6181b |
-
|
|
|
d6181b |
- ret = be_refresh_ctx_init(be_ctx, SYSDB_NAME);
|
|
|
d6181b |
+ struct be_refresh_cb ipa_refresh_callbacks[] = {
|
|
|
d6181b |
+ { .send_fn = ipa_refresh_initgroups_send,
|
|
|
d6181b |
+ .recv_fn = ipa_refresh_initgroups_recv,
|
|
|
d6181b |
+ .pvt = id_ctx,
|
|
|
d6181b |
+ },
|
|
|
d6181b |
+ { .send_fn = ipa_refresh_users_send,
|
|
|
d6181b |
+ .recv_fn = ipa_refresh_users_recv,
|
|
|
d6181b |
+ .pvt = id_ctx,
|
|
|
d6181b |
+ },
|
|
|
d6181b |
+ { .send_fn = ipa_refresh_groups_send,
|
|
|
d6181b |
+ .recv_fn = ipa_refresh_groups_recv,
|
|
|
d6181b |
+ .pvt = id_ctx,
|
|
|
d6181b |
+ },
|
|
|
d6181b |
+ { .send_fn = ipa_refresh_netgroups_send,
|
|
|
d6181b |
+ .recv_fn = ipa_refresh_netgroups_recv,
|
|
|
d6181b |
+ .pvt = id_ctx,
|
|
|
d6181b |
+ },
|
|
|
d6181b |
+ };
|
|
|
d6181b |
+
|
|
|
d6181b |
+ ret = be_refresh_ctx_init_with_callbacks(be_ctx,
|
|
|
d6181b |
+ SYSDB_NAME,
|
|
|
d6181b |
+ ipa_refresh_callbacks);
|
|
|
d6181b |
if (ret != EOK) {
|
|
|
d6181b |
- DEBUG(SSSDBG_FATAL_FAILURE, "Unable to initialize refresh_ctx\n");
|
|
|
d6181b |
- return ENOMEM;
|
|
|
d6181b |
- }
|
|
|
d6181b |
-
|
|
|
d6181b |
- ret = be_refresh_add_cb(be_ctx->refresh_ctx,
|
|
|
d6181b |
- BE_REFRESH_TYPE_USERS,
|
|
|
d6181b |
- ipa_refresh_initgroups_send,
|
|
|
d6181b |
- ipa_refresh_initgroups_recv,
|
|
|
d6181b |
- id_ctx);
|
|
|
d6181b |
- if (ret != EOK && ret != EEXIST) {
|
|
|
d6181b |
- DEBUG(SSSDBG_MINOR_FAILURE, "Periodical refresh of initgroups "
|
|
|
d6181b |
- "will not work [%d]: %s\n", ret, strerror(ret));
|
|
|
d6181b |
+ DEBUG(SSSDBG_FATAL_FAILURE, "Unable to initialize background refresh\n");
|
|
|
d6181b |
+ return ret;
|
|
|
d6181b |
}
|
|
|
d6181b |
|
|
|
d6181b |
- ret = be_refresh_add_cb(be_ctx->refresh_ctx,
|
|
|
d6181b |
- BE_REFRESH_TYPE_USERS,
|
|
|
d6181b |
- ipa_refresh_users_send,
|
|
|
d6181b |
- ipa_refresh_users_recv,
|
|
|
d6181b |
- id_ctx);
|
|
|
d6181b |
- if (ret != EOK && ret != EEXIST) {
|
|
|
d6181b |
- DEBUG(SSSDBG_MINOR_FAILURE, "Periodical refresh of users "
|
|
|
d6181b |
- "will not work [%d]: %s\n", ret, strerror(ret));
|
|
|
d6181b |
- }
|
|
|
d6181b |
-
|
|
|
d6181b |
- ret = be_refresh_add_cb(be_ctx->refresh_ctx,
|
|
|
d6181b |
- BE_REFRESH_TYPE_GROUPS,
|
|
|
d6181b |
- ipa_refresh_groups_send,
|
|
|
d6181b |
- ipa_refresh_groups_recv,
|
|
|
d6181b |
- id_ctx);
|
|
|
d6181b |
- if (ret != EOK && ret != EEXIST) {
|
|
|
d6181b |
- DEBUG(SSSDBG_MINOR_FAILURE, "Periodical refresh of groups "
|
|
|
d6181b |
- "will not work [%d]: %s\n", ret, strerror(ret));
|
|
|
d6181b |
- }
|
|
|
d6181b |
-
|
|
|
d6181b |
- ret = be_refresh_add_cb(be_ctx->refresh_ctx,
|
|
|
d6181b |
- BE_REFRESH_TYPE_NETGROUPS,
|
|
|
d6181b |
- ipa_refresh_netgroups_send,
|
|
|
d6181b |
- ipa_refresh_netgroups_recv,
|
|
|
d6181b |
- id_ctx);
|
|
|
d6181b |
- if (ret != EOK && ret != EEXIST) {
|
|
|
d6181b |
- DEBUG(SSSDBG_MINOR_FAILURE, "Periodical refresh of netgroups "
|
|
|
d6181b |
- "will not work [%d]: %s\n", ret, strerror(ret));
|
|
|
d6181b |
- }
|
|
|
d6181b |
-
|
|
|
d6181b |
- return ret;
|
|
|
d6181b |
+ return EOK;
|
|
|
d6181b |
}
|
|
|
d6181b |
diff --git a/src/providers/ldap/sdap_refresh.c b/src/providers/ldap/sdap_refresh.c
|
|
|
d6181b |
index 3ceddb61e..ff4d2116d 100644
|
|
|
d6181b |
--- a/src/providers/ldap/sdap_refresh.c
|
|
|
d6181b |
+++ b/src/providers/ldap/sdap_refresh.c
|
|
|
d6181b |
@@ -258,41 +258,31 @@ errno_t sdap_refresh_init(struct be_ctx *be_ctx,
|
|
|
d6181b |
struct sdap_id_ctx *id_ctx)
|
|
|
d6181b |
{
|
|
|
d6181b |
errno_t ret;
|
|
|
d6181b |
-
|
|
|
d6181b |
- ret = be_refresh_ctx_init(be_ctx, SYSDB_NAME);
|
|
|
d6181b |
+ struct be_refresh_cb sdap_refresh_callbacks[] = {
|
|
|
d6181b |
+ { .send_fn = sdap_refresh_initgroups_send,
|
|
|
d6181b |
+ .recv_fn = sdap_refresh_initgroups_recv,
|
|
|
d6181b |
+ .pvt = id_ctx,
|
|
|
d6181b |
+ },
|
|
|
d6181b |
+ { .send_fn = sdap_refresh_users_send,
|
|
|
d6181b |
+ .recv_fn = sdap_refresh_users_recv,
|
|
|
d6181b |
+ .pvt = id_ctx,
|
|
|
d6181b |
+ },
|
|
|
d6181b |
+ { .send_fn = sdap_refresh_groups_send,
|
|
|
d6181b |
+ .recv_fn = sdap_refresh_groups_recv,
|
|
|
d6181b |
+ .pvt = id_ctx,
|
|
|
d6181b |
+ },
|
|
|
d6181b |
+ { .send_fn = sdap_refresh_netgroups_send,
|
|
|
d6181b |
+ .recv_fn = sdap_refresh_netgroups_recv,
|
|
|
d6181b |
+ .pvt = id_ctx,
|
|
|
d6181b |
+ },
|
|
|
d6181b |
+ };
|
|
|
d6181b |
+
|
|
|
d6181b |
+ ret = be_refresh_ctx_init_with_callbacks(be_ctx,
|
|
|
d6181b |
+ SYSDB_NAME,
|
|
|
d6181b |
+ sdap_refresh_callbacks);
|
|
|
d6181b |
if (ret != EOK) {
|
|
|
d6181b |
- DEBUG(SSSDBG_FATAL_FAILURE, "Unable to initialize refresh_ctx\n");
|
|
|
d6181b |
- return ENOMEM;
|
|
|
d6181b |
- }
|
|
|
d6181b |
-
|
|
|
d6181b |
- ret = be_refresh_add_cb(be_ctx->refresh_ctx,
|
|
|
d6181b |
- BE_REFRESH_TYPE_USERS,
|
|
|
d6181b |
- sdap_refresh_users_send,
|
|
|
d6181b |
- sdap_refresh_users_recv,
|
|
|
d6181b |
- id_ctx);
|
|
|
d6181b |
- if (ret != EOK && ret != EEXIST) {
|
|
|
d6181b |
- DEBUG(SSSDBG_MINOR_FAILURE, "Periodical refresh of users "
|
|
|
d6181b |
- "will not work [%d]: %s\n", ret, strerror(ret));
|
|
|
d6181b |
- }
|
|
|
d6181b |
-
|
|
|
d6181b |
- ret = be_refresh_add_cb(be_ctx->refresh_ctx,
|
|
|
d6181b |
- BE_REFRESH_TYPE_USERS,
|
|
|
d6181b |
- sdap_refresh_groups_send,
|
|
|
d6181b |
- sdap_refresh_groups_recv,
|
|
|
d6181b |
- id_ctx);
|
|
|
d6181b |
- if (ret != EOK && ret != EEXIST) {
|
|
|
d6181b |
- DEBUG(SSSDBG_MINOR_FAILURE, "Periodical refresh of groups "
|
|
|
d6181b |
- "will not work [%d]: %s\n", ret, strerror(ret));
|
|
|
d6181b |
- }
|
|
|
d6181b |
-
|
|
|
d6181b |
- ret = be_refresh_add_cb(be_ctx->refresh_ctx,
|
|
|
d6181b |
- BE_REFRESH_TYPE_USERS,
|
|
|
d6181b |
- sdap_refresh_netgroups_send,
|
|
|
d6181b |
- sdap_refresh_netgroups_recv,
|
|
|
d6181b |
- id_ctx);
|
|
|
d6181b |
- if (ret != EOK && ret != EEXIST) {
|
|
|
d6181b |
- DEBUG(SSSDBG_MINOR_FAILURE, "Periodical refresh of netgroups "
|
|
|
d6181b |
- "will not work [%d]: %s\n", ret, strerror(ret));
|
|
|
d6181b |
+ DEBUG(SSSDBG_FATAL_FAILURE, "Unable to initialize background refresh\n");
|
|
|
d6181b |
+ return ret;
|
|
|
d6181b |
}
|
|
|
d6181b |
|
|
|
d6181b |
return ret;
|
|
|
d6181b |
--
|
|
|
d6181b |
2.20.1
|
|
|
d6181b |
|