From: Samuel Cabrero Date: Tue, 12 Dec 2023 15:02:33 +0000 (+0100) Subject: idmap_nss: Install a messaging filter to reload the configuration X-Git-Tag: talloc-2.4.2~340 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=086a90d52b0c4bd388bf5707159ae1a727f8e400;p=thirdparty%2Fsamba.git idmap_nss: Install a messaging filter to reload the configuration Signed-off-by: Samuel Cabrero Reviewed-by: Alexander Bokovoy --- diff --git a/source3/winbindd/idmap_nss.c b/source3/winbindd/idmap_nss.c index 957c5c569cf..0af25362219 100644 --- a/source3/winbindd/idmap_nss.c +++ b/source3/winbindd/idmap_nss.c @@ -26,6 +26,8 @@ #include "idmap.h" #include "lib/winbind_util.h" #include "libcli/security/dom_sid.h" +#include "lib/global_contexts.h" +#include "messages.h" #undef DBGC_CLASS #define DBGC_CLASS DBGC_IDMAP @@ -87,6 +89,34 @@ static NTSTATUS idmap_nss_get_context(struct idmap_domain *dom, return NT_STATUS_OK; } +static bool idmap_nss_msg_filter(struct messaging_rec *rec, void *private_data) +{ + struct idmap_domain *dom = talloc_get_type_abort(private_data, + struct idmap_domain); + struct idmap_nss_context *ctx = NULL; + NTSTATUS status; + bool ret; + + if (rec->msg_type == MSG_SMB_CONF_UPDATED) { + ret = lp_load_global(get_dyn_CONFIGFILE()); + if (!ret) { + DBG_WARNING("Failed to reload configuration\n"); + return false; + } + + status = idmap_nss_get_context(dom, &ctx); + if (NT_STATUS_IS_ERR(status)) { + DBG_WARNING("Failed to get idmap nss context: %s\n", + nt_errstr(status)); + return false; + } + + ctx->use_upn = idmap_config_bool(dom->name, "use_upn", false); + } + + return false; +} + /***************************** Initialise idmap database. *****************************/ @@ -95,6 +125,8 @@ static NTSTATUS idmap_nss_int_init(struct idmap_domain *dom) { struct idmap_nss_context *ctx = NULL; NTSTATUS status; + struct messaging_context *msg_ctx = global_messaging_context(); + struct tevent_req *req = NULL; status = idmap_nss_context_create(dom, dom, &ctx); if (NT_STATUS_IS_ERR(status)) { @@ -103,6 +135,17 @@ static NTSTATUS idmap_nss_int_init(struct idmap_domain *dom) dom->private_data = ctx; + req = messaging_filtered_read_send( + dom, + messaging_tevent_context(msg_ctx), + msg_ctx, + idmap_nss_msg_filter, + dom); + if (req == NULL) { + DBG_WARNING("messaging_filtered_read_send failed\n"); + return NT_STATUS_UNSUCCESSFUL; + } + return status; }