|
|
8d3578 |
From f035dee4d63ebe96a8435778e4c8ce413e8c025b Mon Sep 17 00:00:00 2001
|
|
|
8d3578 |
From: Jakub Hrozek <jhrozek@redhat.com>
|
|
|
8d3578 |
Date: Tue, 21 May 2019 12:09:24 +0200
|
|
|
8d3578 |
Subject: [PATCH 50/64] BE: Pass in attribute to look up with instead of
|
|
|
8d3578 |
hardcoding SYSDB_NAME
|
|
|
8d3578 |
|
|
|
8d3578 |
In later patches, we will implement refreshes for AD or IPA which might
|
|
|
8d3578 |
refresh objects that do not have a name yet, but always do have a different
|
|
|
8d3578 |
attribute, like a SID or a uniqueID. In this case, it's better to use that
|
|
|
8d3578 |
different attribute instead of name.
|
|
|
8d3578 |
|
|
|
8d3578 |
This patch allows the caller to tell the refresh module which attribute
|
|
|
8d3578 |
to use.
|
|
|
8d3578 |
|
|
|
8d3578 |
Related:
|
|
|
8d3578 |
https://pagure.io/SSSD/sssd/issue/4012
|
|
|
8d3578 |
|
|
|
8d3578 |
Reviewed-by: Sumit Bose <sbose@redhat.com>
|
|
|
8d3578 |
(cherry picked from commit d1eb0a70de3c98ca9dc03a0b79287f4ce6ee4855)
|
|
|
8d3578 |
|
|
|
8d3578 |
Reviewed-by: Sumit Bose <sbose@redhat.com>
|
|
|
8d3578 |
---
|
|
|
8d3578 |
src/providers/be_refresh.c | 12 ++++++++----
|
|
|
8d3578 |
src/providers/be_refresh.h | 3 ++-
|
|
|
8d3578 |
src/providers/ldap/sdap_refresh.c | 2 +-
|
|
|
8d3578 |
3 files changed, 11 insertions(+), 6 deletions(-)
|
|
|
8d3578 |
|
|
|
8d3578 |
diff --git a/src/providers/be_refresh.c b/src/providers/be_refresh.c
|
|
|
8d3578 |
index c7b048a95..66cc4cf98 100644
|
|
|
8d3578 |
--- a/src/providers/be_refresh.c
|
|
|
8d3578 |
+++ b/src/providers/be_refresh.c
|
|
|
8d3578 |
@@ -89,6 +89,7 @@ done:
|
|
|
8d3578 |
|
|
|
8d3578 |
static errno_t be_refresh_get_values(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
enum be_refresh_type type,
|
|
|
8d3578 |
+ const char *attr_name,
|
|
|
8d3578 |
struct sss_domain_info *domain,
|
|
|
8d3578 |
time_t period,
|
|
|
8d3578 |
char ***_values)
|
|
|
8d3578 |
@@ -116,7 +117,7 @@ static errno_t be_refresh_get_values(TALLOC_CTX *mem_ctx,
|
|
|
8d3578 |
}
|
|
|
8d3578 |
|
|
|
8d3578 |
ret = be_refresh_get_values_ex(mem_ctx, domain, period,
|
|
|
8d3578 |
- base_dn, SYSDB_NAME, _values);
|
|
|
8d3578 |
+ base_dn, attr_name, _values);
|
|
|
8d3578 |
|
|
|
8d3578 |
talloc_free(base_dn);
|
|
|
8d3578 |
return ret;
|
|
|
8d3578 |
@@ -131,10 +132,12 @@ struct be_refresh_cb {
|
|
|
8d3578 |
};
|
|
|
8d3578 |
|
|
|
8d3578 |
struct be_refresh_ctx {
|
|
|
8d3578 |
+ const char *attr_name;
|
|
|
8d3578 |
struct be_refresh_cb callbacks[BE_REFRESH_TYPE_SENTINEL];
|
|
|
8d3578 |
};
|
|
|
8d3578 |
|
|
|
8d3578 |
-struct be_refresh_ctx *be_refresh_ctx_init(struct be_ctx *be_ctx)
|
|
|
8d3578 |
+struct be_refresh_ctx *be_refresh_ctx_init(struct be_ctx *be_ctx,
|
|
|
8d3578 |
+ const char *attr_name)
|
|
|
8d3578 |
{
|
|
|
8d3578 |
struct be_refresh_ctx *ctx = NULL;
|
|
|
8d3578 |
uint32_t refresh_interval;
|
|
|
8d3578 |
@@ -145,6 +148,7 @@ struct be_refresh_ctx *be_refresh_ctx_init(struct be_ctx *be_ctx)
|
|
|
8d3578 |
return NULL;
|
|
|
8d3578 |
}
|
|
|
8d3578 |
|
|
|
8d3578 |
+ ctx->attr_name = attr_name;
|
|
|
8d3578 |
ctx->callbacks[BE_REFRESH_TYPE_USERS].name = "users";
|
|
|
8d3578 |
ctx->callbacks[BE_REFRESH_TYPE_GROUPS].name = "groups";
|
|
|
8d3578 |
ctx->callbacks[BE_REFRESH_TYPE_NETGROUPS].name = "netgroups";
|
|
|
8d3578 |
@@ -284,8 +288,8 @@ static errno_t be_refresh_step(struct tevent_req *req)
|
|
|
8d3578 |
goto done;
|
|
|
8d3578 |
}
|
|
|
8d3578 |
|
|
|
8d3578 |
- ret = be_refresh_get_values(state, state->index, state->domain,
|
|
|
8d3578 |
- state->period, &values);
|
|
|
8d3578 |
+ ret = be_refresh_get_values(state, state->index, state->ctx->attr_name,
|
|
|
8d3578 |
+ state->domain, state->period, &values);
|
|
|
8d3578 |
if (ret != EOK) {
|
|
|
8d3578 |
DEBUG(SSSDBG_CRIT_FAILURE, "Unable to obtain DN list [%d]: %s\n",
|
|
|
8d3578 |
ret, sss_strerror(ret));
|
|
|
8d3578 |
diff --git a/src/providers/be_refresh.h b/src/providers/be_refresh.h
|
|
|
8d3578 |
index 664f01816..8c7b1d0ba 100644
|
|
|
8d3578 |
--- a/src/providers/be_refresh.h
|
|
|
8d3578 |
+++ b/src/providers/be_refresh.h
|
|
|
8d3578 |
@@ -52,7 +52,8 @@ enum be_refresh_type {
|
|
|
8d3578 |
|
|
|
8d3578 |
struct be_refresh_ctx;
|
|
|
8d3578 |
|
|
|
8d3578 |
-struct be_refresh_ctx *be_refresh_ctx_init(struct be_ctx *be_ctx);
|
|
|
8d3578 |
+struct be_refresh_ctx *be_refresh_ctx_init(struct be_ctx *be_ctx,
|
|
|
8d3578 |
+ const char *attr_name);
|
|
|
8d3578 |
|
|
|
8d3578 |
errno_t be_refresh_add_cb(struct be_refresh_ctx *ctx,
|
|
|
8d3578 |
enum be_refresh_type type,
|
|
|
8d3578 |
diff --git a/src/providers/ldap/sdap_refresh.c b/src/providers/ldap/sdap_refresh.c
|
|
|
8d3578 |
index 457df8be2..ed04da36a 100644
|
|
|
8d3578 |
--- a/src/providers/ldap/sdap_refresh.c
|
|
|
8d3578 |
+++ b/src/providers/ldap/sdap_refresh.c
|
|
|
8d3578 |
@@ -260,7 +260,7 @@ errno_t sdap_refresh_init(struct be_ctx *be_ctx,
|
|
|
8d3578 |
{
|
|
|
8d3578 |
errno_t ret;
|
|
|
8d3578 |
|
|
|
8d3578 |
- be_ctx->refresh_ctx = be_refresh_ctx_init(be_ctx);
|
|
|
8d3578 |
+ be_ctx->refresh_ctx = be_refresh_ctx_init(be_ctx, SYSDB_NAME);
|
|
|
8d3578 |
if (be_ctx->refresh_ctx == NULL) {
|
|
|
8d3578 |
DEBUG(SSSDBG_FATAL_FAILURE, "Unable to initialize refresh_ctx\n");
|
|
|
8d3578 |
return ENOMEM;
|
|
|
8d3578 |
--
|
|
|
8d3578 |
2.20.1
|
|
|
8d3578 |
|