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