178 lines
6.9 KiB
Diff
178 lines
6.9 KiB
Diff
|
From d1f38315fa7f8c9d3392af0feb32afc56a0f6c4e Mon Sep 17 00:00:00 2001
|
||
|
From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fidencio@redhat.com>
|
||
|
Date: Fri, 16 Feb 2018 13:55:53 +0100
|
||
|
Subject: [PATCH] NSS: Add InvalidateGroupById handler
|
||
|
MIME-Version: 1.0
|
||
|
Content-Type: text/plain; charset=UTF-8
|
||
|
Content-Transfer-Encoding: 8bit
|
||
|
|
||
|
There are some situations where, from the backend, the NSS responder
|
||
|
will have to be notified to invalidate a group.
|
||
|
|
||
|
In order to achieve this in a clean way, let's add the
|
||
|
InvalidateGroupById handler and make use of it later in this very same
|
||
|
series.
|
||
|
|
||
|
Related:
|
||
|
https://pagure.io/SSSD/sssd/issue/2653
|
||
|
|
||
|
Signed-off-by: Fabiano Fidêncio <fidencio@redhat.com>
|
||
|
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
|
||
|
(cherry picked from commit 851d31264c826d7e1bca38bb6d49e66b446707e7)
|
||
|
---
|
||
|
src/responder/nss/nss_iface.c | 16 ++++++++++++++
|
||
|
src/responder/nss/nss_iface.xml | 3 +++
|
||
|
src/responder/nss/nss_iface_generated.c | 38 +++++++++++++++++++++++++++++++++
|
||
|
src/responder/nss/nss_iface_generated.h | 5 +++++
|
||
|
4 files changed, 62 insertions(+)
|
||
|
|
||
|
diff --git a/src/responder/nss/nss_iface.c b/src/responder/nss/nss_iface.c
|
||
|
index 415af9550..805e4fcdf 100644
|
||
|
--- a/src/responder/nss/nss_iface.c
|
||
|
+++ b/src/responder/nss/nss_iface.c
|
||
|
@@ -199,12 +199,28 @@ int nss_memorycache_update_initgroups(struct sbus_request *sbus_req,
|
||
|
return iface_nss_memorycache_UpdateInitgroups_finish(sbus_req);
|
||
|
}
|
||
|
|
||
|
+int nss_memorycache_invalidate_group_by_id(struct sbus_request *sbus_req,
|
||
|
+ void *data,
|
||
|
+ gid_t gid)
|
||
|
+{
|
||
|
+ struct resp_ctx *rctx = talloc_get_type(data, struct resp_ctx);
|
||
|
+ struct nss_ctx *nctx = talloc_get_type(rctx->pvt_ctx, struct nss_ctx);
|
||
|
+
|
||
|
+ DEBUG(SSSDBG_TRACE_LIBS,
|
||
|
+ "Invalidating group %"PRIu32" from memory cache\n", gid);
|
||
|
+
|
||
|
+ sss_mmap_cache_gr_invalidate_gid(nctx->grp_mc_ctx, gid);
|
||
|
+
|
||
|
+ return iface_nss_memorycache_InvalidateGroupById_finish(sbus_req);
|
||
|
+}
|
||
|
+
|
||
|
struct iface_nss_memorycache iface_nss_memorycache = {
|
||
|
{ &iface_nss_memorycache_meta, 0 },
|
||
|
.UpdateInitgroups = nss_memorycache_update_initgroups,
|
||
|
.InvalidateAllUsers = nss_memorycache_invalidate_users,
|
||
|
.InvalidateAllGroups = nss_memorycache_invalidate_groups,
|
||
|
.InvalidateAllInitgroups = nss_memorycache_invalidate_initgroups,
|
||
|
+ .InvalidateGroupById = nss_memorycache_invalidate_group_by_id,
|
||
|
};
|
||
|
|
||
|
static struct sbus_iface_map iface_map[] = {
|
||
|
diff --git a/src/responder/nss/nss_iface.xml b/src/responder/nss/nss_iface.xml
|
||
|
index 27aae0197..4d8cf14f9 100644
|
||
|
--- a/src/responder/nss/nss_iface.xml
|
||
|
+++ b/src/responder/nss/nss_iface.xml
|
||
|
@@ -14,5 +14,8 @@
|
||
|
</method>
|
||
|
<method name="InvalidateAllInitgroups">
|
||
|
</method>
|
||
|
+ <method name="InvalidateGroupById">
|
||
|
+ <arg name="gid" type="u" direction="in" />
|
||
|
+ </method>
|
||
|
</interface>
|
||
|
</node>
|
||
|
diff --git a/src/responder/nss/nss_iface_generated.c b/src/responder/nss/nss_iface_generated.c
|
||
|
index 4a8b704da..8d5a4584b 100644
|
||
|
--- a/src/responder/nss/nss_iface_generated.c
|
||
|
+++ b/src/responder/nss/nss_iface_generated.c
|
||
|
@@ -12,6 +12,9 @@
|
||
|
/* invokes a handler with a 'ssau' DBus signature */
|
||
|
static int invoke_ssau_method(struct sbus_request *dbus_req, void *function_ptr);
|
||
|
|
||
|
+/* invokes a handler with a 'u' DBus signature */
|
||
|
+static int invoke_u_method(struct sbus_request *dbus_req, void *function_ptr);
|
||
|
+
|
||
|
/* arguments for org.freedesktop.sssd.nss.MemoryCache.UpdateInitgroups */
|
||
|
const struct sbus_arg_meta iface_nss_memorycache_UpdateInitgroups__in[] = {
|
||
|
{ "user", "s" },
|
||
|
@@ -44,6 +47,18 @@ int iface_nss_memorycache_InvalidateAllInitgroups_finish(struct sbus_request *re
|
||
|
DBUS_TYPE_INVALID);
|
||
|
}
|
||
|
|
||
|
+/* arguments for org.freedesktop.sssd.nss.MemoryCache.InvalidateGroupById */
|
||
|
+const struct sbus_arg_meta iface_nss_memorycache_InvalidateGroupById__in[] = {
|
||
|
+ { "gid", "u" },
|
||
|
+ { NULL, }
|
||
|
+};
|
||
|
+
|
||
|
+int iface_nss_memorycache_InvalidateGroupById_finish(struct sbus_request *req)
|
||
|
+{
|
||
|
+ return sbus_request_return_and_finish(req,
|
||
|
+ DBUS_TYPE_INVALID);
|
||
|
+}
|
||
|
+
|
||
|
/* methods for org.freedesktop.sssd.nss.MemoryCache */
|
||
|
const struct sbus_method_meta iface_nss_memorycache__methods[] = {
|
||
|
{
|
||
|
@@ -74,6 +89,13 @@ const struct sbus_method_meta iface_nss_memorycache__methods[] = {
|
||
|
offsetof(struct iface_nss_memorycache, InvalidateAllInitgroups),
|
||
|
NULL, /* no invoker */
|
||
|
},
|
||
|
+ {
|
||
|
+ "InvalidateGroupById", /* name */
|
||
|
+ iface_nss_memorycache_InvalidateGroupById__in,
|
||
|
+ NULL, /* no out_args */
|
||
|
+ offsetof(struct iface_nss_memorycache, InvalidateGroupById),
|
||
|
+ invoke_u_method,
|
||
|
+ },
|
||
|
{ NULL, }
|
||
|
};
|
||
|
|
||
|
@@ -86,6 +108,22 @@ const struct sbus_interface_meta iface_nss_memorycache_meta = {
|
||
|
sbus_invoke_get_all, /* GetAll invoker */
|
||
|
};
|
||
|
|
||
|
+/* invokes a handler with a 'u' DBus signature */
|
||
|
+static int invoke_u_method(struct sbus_request *dbus_req, void *function_ptr)
|
||
|
+{
|
||
|
+ uint32_t arg_0;
|
||
|
+ int (*handler)(struct sbus_request *, void *, uint32_t) = function_ptr;
|
||
|
+
|
||
|
+ if (!sbus_request_parse_or_finish(dbus_req,
|
||
|
+ DBUS_TYPE_UINT32, &arg_0,
|
||
|
+ DBUS_TYPE_INVALID)) {
|
||
|
+ return EOK; /* request handled */
|
||
|
+ }
|
||
|
+
|
||
|
+ return (handler)(dbus_req, dbus_req->intf->handler_data,
|
||
|
+ arg_0);
|
||
|
+}
|
||
|
+
|
||
|
/* invokes a handler with a 'ssau' DBus signature */
|
||
|
static int invoke_ssau_method(struct sbus_request *dbus_req, void *function_ptr)
|
||
|
{
|
||
|
diff --git a/src/responder/nss/nss_iface_generated.h b/src/responder/nss/nss_iface_generated.h
|
||
|
index 11fac7916..27a6d0853 100644
|
||
|
--- a/src/responder/nss/nss_iface_generated.h
|
||
|
+++ b/src/responder/nss/nss_iface_generated.h
|
||
|
@@ -18,6 +18,7 @@
|
||
|
#define IFACE_NSS_MEMORYCACHE_INVALIDATEALLUSERS "InvalidateAllUsers"
|
||
|
#define IFACE_NSS_MEMORYCACHE_INVALIDATEALLGROUPS "InvalidateAllGroups"
|
||
|
#define IFACE_NSS_MEMORYCACHE_INVALIDATEALLINITGROUPS "InvalidateAllInitgroups"
|
||
|
+#define IFACE_NSS_MEMORYCACHE_INVALIDATEGROUPBYID "InvalidateGroupById"
|
||
|
|
||
|
/* ------------------------------------------------------------------------
|
||
|
* DBus handlers
|
||
|
@@ -44,6 +45,7 @@ struct iface_nss_memorycache {
|
||
|
int (*InvalidateAllUsers)(struct sbus_request *req, void *data);
|
||
|
int (*InvalidateAllGroups)(struct sbus_request *req, void *data);
|
||
|
int (*InvalidateAllInitgroups)(struct sbus_request *req, void *data);
|
||
|
+ int (*InvalidateGroupById)(struct sbus_request *req, void *data, uint32_t arg_gid);
|
||
|
};
|
||
|
|
||
|
/* finish function for UpdateInitgroups */
|
||
|
@@ -58,6 +60,9 @@ int iface_nss_memorycache_InvalidateAllGroups_finish(struct sbus_request *req);
|
||
|
/* finish function for InvalidateAllInitgroups */
|
||
|
int iface_nss_memorycache_InvalidateAllInitgroups_finish(struct sbus_request *req);
|
||
|
|
||
|
+/* finish function for InvalidateGroupById */
|
||
|
+int iface_nss_memorycache_InvalidateGroupById_finish(struct sbus_request *req);
|
||
|
+
|
||
|
/* ------------------------------------------------------------------------
|
||
|
* DBus Interface Metadata
|
||
|
*
|
||
|
--
|
||
|
2.14.3
|
||
|
|