From c2fe5c54faa92c670161d65fe5a1ff62acd4ac91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pavel=20B=C5=99ezina?= Date: Tue, 19 Jul 2016 14:24:16 +0200 Subject: [PATCH 100/102] DP: Remove old data provider interface MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reverse data provider interface is moved to a better location in NSS responder. All responders now can have an sbus interface defined per data provider connection. The unused old data provider interface is removed. Reviewed-by: Lukáš Slebodník (cherry picked from commit 04e870d99e72aa3160bdb6ab05d986fb4005c3ed) --- Makefile.am | 11 +-- src/providers/data_provider.h | 1 - src/providers/data_provider/dp_target_id.c | 7 +- src/providers/data_provider_iface.xml | 53 --------------- src/providers/data_provider_iface_generated.c | 98 --------------------------- src/providers/data_provider_iface_generated.h | 82 ---------------------- src/responder/autofs/autofssrv.c | 13 +--- src/responder/common/responder.h | 8 +-- src/responder/common/responder_common.c | 16 +++-- src/responder/common/responder_get_domains.c | 4 +- src/responder/ifp/ifpsrv.c | 13 +--- src/responder/nss/nss_iface.c | 38 +++++++++++ src/responder/nss/nss_iface.h | 30 ++++++++ src/responder/nss/nss_iface.xml | 12 ++++ src/responder/nss/nss_iface_generated.c | 69 +++++++++++++++++++ src/responder/nss/nss_iface_generated.h | 58 ++++++++++++++++ src/responder/nss/nsssrv.c | 39 ++++------- src/responder/nss/nsssrv.h | 7 ++ src/responder/pac/pacsrv.c | 13 +--- src/responder/pam/pamsrv.c | 13 +--- src/responder/pam/pamsrv_dp.c | 4 +- src/responder/ssh/sshsrv.c | 13 +--- src/responder/sudo/sudosrv.c | 13 +--- src/tests/cwrap/Makefile.am | 1 - 24 files changed, 259 insertions(+), 357 deletions(-) delete mode 100644 src/providers/data_provider_iface.xml delete mode 100644 src/providers/data_provider_iface_generated.c delete mode 100644 src/providers/data_provider_iface_generated.h create mode 100644 src/responder/nss/nss_iface.c create mode 100644 src/responder/nss/nss_iface.h create mode 100644 src/responder/nss/nss_iface.xml create mode 100644 src/responder/nss/nss_iface_generated.c create mode 100644 src/responder/nss/nss_iface_generated.h diff --git a/Makefile.am b/Makefile.am index 5d54838659e44fa446fc921d014e48ac91469b25..e2e4c4c08f66ef15684e1b3b1fe17bfae4e4131b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -492,7 +492,6 @@ SSSD_RESPONDER_OBJ = \ src/responder/common/data_provider/rdp_message.c \ src/responder/common/data_provider/rdp_client.c \ src/monitor/monitor_iface_generated.c \ - src/providers/data_provider_iface_generated.c \ src/providers/data_provider_req.c SSSD_TOOLS_OBJ = \ @@ -610,6 +609,8 @@ dist_noinst_HEADERS = \ src/responder/nss/nsssrv_netgroup.h \ src/responder/nss/nsssrv_services.h \ src/responder/nss/nsssrv_mmap_cache.h \ + src/responder/nss/nss_iface_generated.h \ + src/responder/nss/nss_iface.h \ src/responder/pac/pacsrv.h \ src/responder/common/negcache_files.h \ src/responder/common/negcache.h \ @@ -647,7 +648,6 @@ dist_noinst_HEADERS = \ src/confdb/confdb_setup.h \ src/providers/data_provider.h \ src/providers/data_provider_req.h \ - src/providers/data_provider_iface_generated.h \ src/providers/data_provider/dp.h \ src/providers/data_provider/dp_flags.h \ src/providers/data_provider/dp_responder_iface.h \ @@ -1196,10 +1196,10 @@ endif CODEGEN_XML = \ $(srcdir)/src/tests/sbus_codegen_tests.xml \ $(srcdir)/src/monitor/monitor_iface.xml \ - $(srcdir)/src/providers/data_provider_iface.xml \ $(srcdir)/src/providers/data_provider/dp_iface.xml \ $(srcdir)/src/providers/proxy/proxy_iface.xml \ - $(srcdir)/src/responder/ifp/ifp_iface.xml + $(srcdir)/src/responder/ifp/ifp_iface.xml \ + $(srcdir)/src/responder/nss/nss_iface.xml SBUS_CODEGEN = src/sbus/sbus_codegen @@ -1248,6 +1248,8 @@ sssd_nss_SOURCES = \ src/responder/nss/nsssrv_netgroup.c \ src/responder/nss/nsssrv_services.c \ src/responder/nss/nsssrv_mmap_cache.c \ + src/responder/nss/nss_iface_generated.c \ + src/responder/nss/nss_iface.c \ $(SSSD_RESPONDER_OBJ) sssd_nss_LDADD = \ $(TDB_LIBS) \ @@ -1411,7 +1413,6 @@ sssd_be_SOURCES = \ src/providers/be_ptask.c \ src/providers/be_refresh.c \ src/monitor/monitor_iface_generated.c \ - src/providers/data_provider_iface_generated.c \ src/providers/data_provider/dp.c \ src/providers/data_provider/dp_modules.c \ src/providers/data_provider/dp_targets.c \ diff --git a/src/providers/data_provider.h b/src/providers/data_provider.h index b0b6876d984d7c6574baaa8d130e374ba2e6f0c4..14a0902c265850d91fa7d29cc2708e70b060ec18 100644 --- a/src/providers/data_provider.h +++ b/src/providers/data_provider.h @@ -44,7 +44,6 @@ #include "sss_client/sss_cli.h" #include "util/authtok.h" #include "providers/data_provider_req.h" -#include "providers/data_provider_iface_generated.h" #define DATA_PROVIDER_VERSION 0x0001 #define DATA_PROVIDER_PIPE "private/sbus-dp" diff --git a/src/providers/data_provider/dp_target_id.c b/src/providers/data_provider/dp_target_id.c index 1b06cbe5b96f56c33dd048cf6211b7c97819db8c..938651545ea995091d0aaf29da12bbb8110c9add 100644 --- a/src/providers/data_provider/dp_target_id.c +++ b/src/providers/data_provider/dp_target_id.c @@ -25,6 +25,7 @@ #include "providers/data_provider/dp_private.h" #include "providers/data_provider/dp_iface.h" #include "providers/backend.h" +#include "responder/nss/nss_iface.h" #include "util/util.h" #define FILTER_TYPE(str, type) {str "=", sizeof(str "=") - 1, type} @@ -168,9 +169,9 @@ static void dp_req_initgr_pp(const char *req_name, } msg = dbus_message_new_method_call(NULL, - DP_PATH, - DATA_PROVIDER_REV_IFACE, - DATA_PROVIDER_REV_IFACE_INITGRCHECK); + NSS_MEMORYCACHE_PATH, + IFACE_NSS_MEMORYCACHE, + IFACE_NSS_MEMORYCACHE_UPDATEINITGROUPS); if (msg == NULL) { DEBUG(SSSDBG_CRIT_FAILURE, "Out of memory?!\n"); return; diff --git a/src/providers/data_provider_iface.xml b/src/providers/data_provider_iface.xml deleted file mode 100644 index 143975633081ce2ae5690c4036e7169e41d776fc..0000000000000000000000000000000000000000 --- a/src/providers/data_provider_iface.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/providers/data_provider_iface_generated.c b/src/providers/data_provider_iface_generated.c deleted file mode 100644 index bdd6a4d76d18bbb44530d816fce14009736b6f6d..0000000000000000000000000000000000000000 --- a/src/providers/data_provider_iface_generated.c +++ /dev/null @@ -1,98 +0,0 @@ -/* The following definitions are auto-generated from data_provider_iface.xml */ - -#include "util/util.h" -#include "sbus/sssd_dbus.h" -#include "sbus/sssd_dbus_meta.h" -#include "sbus/sssd_dbus_invokers.h" -#include "data_provider_iface_generated.h" - -/* methods for org.freedesktop.sssd.dataprovider */ -const struct sbus_method_meta data_provider_iface__methods[] = { - { - "RegisterService", /* name */ - NULL, /* no in_args */ - NULL, /* no out_args */ - offsetof(struct data_provider_iface, RegisterService), - NULL, /* no invoker */ - }, - { - "pamHandler", /* name */ - NULL, /* no in_args */ - NULL, /* no out_args */ - offsetof(struct data_provider_iface, pamHandler), - NULL, /* no invoker */ - }, - { - "sudoHandler", /* name */ - NULL, /* no in_args */ - NULL, /* no out_args */ - offsetof(struct data_provider_iface, sudoHandler), - NULL, /* no invoker */ - }, - { - "autofsHandler", /* name */ - NULL, /* no in_args */ - NULL, /* no out_args */ - offsetof(struct data_provider_iface, autofsHandler), - NULL, /* no invoker */ - }, - { - "hostHandler", /* name */ - NULL, /* no in_args */ - NULL, /* no out_args */ - offsetof(struct data_provider_iface, hostHandler), - NULL, /* no invoker */ - }, - { - "getDomains", /* name */ - NULL, /* no in_args */ - NULL, /* no out_args */ - offsetof(struct data_provider_iface, getDomains), - NULL, /* no invoker */ - }, - { - "getAccountInfo", /* name */ - NULL, /* no in_args */ - NULL, /* no out_args */ - offsetof(struct data_provider_iface, getAccountInfo), - NULL, /* no invoker */ - }, - { NULL, } -}; - -/* interface info for org.freedesktop.sssd.dataprovider */ -const struct sbus_interface_meta data_provider_iface_meta = { - "org.freedesktop.sssd.dataprovider", /* name */ - data_provider_iface__methods, - NULL, /* no signals */ - NULL, /* no properties */ - sbus_invoke_get_all, /* GetAll invoker */ -}; - -/* methods for org.freedesktop.sssd.dataprovider_rev */ -const struct sbus_method_meta data_provider_rev_iface__methods[] = { - { - "updateCache", /* name */ - NULL, /* no in_args */ - NULL, /* no out_args */ - offsetof(struct data_provider_rev_iface, updateCache), - NULL, /* no invoker */ - }, - { - "initgrCheck", /* name */ - NULL, /* no in_args */ - NULL, /* no out_args */ - offsetof(struct data_provider_rev_iface, initgrCheck), - NULL, /* no invoker */ - }, - { NULL, } -}; - -/* interface info for org.freedesktop.sssd.dataprovider_rev */ -const struct sbus_interface_meta data_provider_rev_iface_meta = { - "org.freedesktop.sssd.dataprovider_rev", /* name */ - data_provider_rev_iface__methods, - NULL, /* no signals */ - NULL, /* no properties */ - sbus_invoke_get_all, /* GetAll invoker */ -}; diff --git a/src/providers/data_provider_iface_generated.h b/src/providers/data_provider_iface_generated.h deleted file mode 100644 index 976e42b89c6aaf9523b16999b8f5103a1e6f8e66..0000000000000000000000000000000000000000 --- a/src/providers/data_provider_iface_generated.h +++ /dev/null @@ -1,82 +0,0 @@ -/* The following declarations are auto-generated from data_provider_iface.xml */ - -#ifndef __DATA_PROVIDER_IFACE_XML__ -#define __DATA_PROVIDER_IFACE_XML__ - -#include "sbus/sssd_dbus.h" - -/* ------------------------------------------------------------------------ - * DBus Constants - * - * Various constants of interface and method names mostly for use by clients - */ - -/* constants for org.freedesktop.sssd.dataprovider */ -#define DATA_PROVIDER_IFACE "org.freedesktop.sssd.dataprovider" -#define DATA_PROVIDER_IFACE_REGISTERSERVICE "RegisterService" -#define DATA_PROVIDER_IFACE_PAMHANDLER "pamHandler" -#define DATA_PROVIDER_IFACE_SUDOHANDLER "sudoHandler" -#define DATA_PROVIDER_IFACE_AUTOFSHANDLER "autofsHandler" -#define DATA_PROVIDER_IFACE_HOSTHANDLER "hostHandler" -#define DATA_PROVIDER_IFACE_GETDOMAINS "getDomains" -#define DATA_PROVIDER_IFACE_GETACCOUNTINFO "getAccountInfo" - -/* constants for org.freedesktop.sssd.dataprovider_rev */ -#define DATA_PROVIDER_REV_IFACE "org.freedesktop.sssd.dataprovider_rev" -#define DATA_PROVIDER_REV_IFACE_UPDATECACHE "updateCache" -#define DATA_PROVIDER_REV_IFACE_INITGRCHECK "initgrCheck" - -/* ------------------------------------------------------------------------ - * DBus handlers - * - * These structures are filled in by implementors of the different - * dbus interfaces to handle method calls. - * - * Handler functions of type sbus_msg_handler_fn accept raw messages, - * other handlers are typed appropriately. If a handler that is - * set to NULL is invoked it will result in a - * org.freedesktop.DBus.Error.NotSupported error for the caller. - * - * Handlers have a matching xxx_finish() function (unless the method has - * accepts raw messages). These finish functions the - * sbus_request_return_and_finish() with the appropriate arguments to - * construct a valid reply. Once a finish function has been called, the - * @dbus_req it was called with is freed and no longer valid. - */ - -/* vtable for org.freedesktop.sssd.dataprovider */ -struct data_provider_iface { - struct sbus_vtable vtable; /* derive from sbus_vtable */ - sbus_msg_handler_fn RegisterService; - sbus_msg_handler_fn pamHandler; - sbus_msg_handler_fn sudoHandler; - sbus_msg_handler_fn autofsHandler; - sbus_msg_handler_fn hostHandler; - sbus_msg_handler_fn getDomains; - sbus_msg_handler_fn getAccountInfo; -}; - -/* vtable for org.freedesktop.sssd.dataprovider_rev */ -struct data_provider_rev_iface { - struct sbus_vtable vtable; /* derive from sbus_vtable */ - sbus_msg_handler_fn updateCache; - sbus_msg_handler_fn initgrCheck; -}; - -/* ------------------------------------------------------------------------ - * DBus Interface Metadata - * - * These structure definitions are filled in with the information about - * the interfaces, methods, properties and so on. - * - * The actual definitions are found in the accompanying C file next - * to this header. - */ - -/* interface info for org.freedesktop.sssd.dataprovider */ -extern const struct sbus_interface_meta data_provider_iface_meta; - -/* interface info for org.freedesktop.sssd.dataprovider_rev */ -extern const struct sbus_interface_meta data_provider_rev_iface_meta; - -#endif /* __DATA_PROVIDER_IFACE_XML__ */ diff --git a/src/responder/autofs/autofssrv.c b/src/responder/autofs/autofssrv.c index c72f3c1f7aee81a9986076975086cdd88e968edb..826a36e9bc0e2afedfda17104d15b86c5fc1b7e1 100644 --- a/src/responder/autofs/autofssrv.c +++ b/src/responder/autofs/autofssrv.c @@ -44,17 +44,6 @@ struct mon_cli_iface monitor_autofs_methods = { .sysbusReconnect = NULL, }; -static struct data_provider_iface autofs_dp_methods = { - { &data_provider_iface_meta, 0 }, - .RegisterService = NULL, - .pamHandler = NULL, - .sudoHandler = NULL, - .autofsHandler = NULL, - .hostHandler = NULL, - .getDomains = NULL, - .getAccountInfo = NULL, -}; - static errno_t autofs_get_config(struct autofs_ctx *actx, struct confdb_ctx *cdb) @@ -130,7 +119,7 @@ autofs_process_init(TALLOC_CTX *mem_ctx, SSS_AUTOFS_SBUS_SERVICE_VERSION, &monitor_autofs_methods, "autofs", - &autofs_dp_methods.vtable, + NULL, autofs_connection_setup, &rctx); if (ret != EOK) { diff --git a/src/responder/common/responder.h b/src/responder/common/responder.h index 335b313ce1a6bc7c0e0ba332786e2e9f39a04ff1..9e3b2fdbda4e30b859df597374fc7d490b1720e5 100644 --- a/src/responder/common/responder.h +++ b/src/responder/common/responder.h @@ -163,11 +163,7 @@ struct mon_cli_iface; typedef int (*connection_setup_t)(struct cli_ctx *cctx); int sss_connection_setup(struct cli_ctx *cctx); -/* - * NOTE: We would like to use more strong typing for the @dp_vtable argument - * but can't since it accepts either a struct data_provider_iface - * or struct data_provider_rev_iface. So pass the base struct: sbus_vtable - */ + int sss_process_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct confdb_ctx *cdb, @@ -181,7 +177,7 @@ int sss_process_init(TALLOC_CTX *mem_ctx, uint16_t svc_version, struct mon_cli_iface *monitor_intf, const char *cli_name, - struct sbus_vtable *dp_intf, + struct sbus_iface_map *sbus_iface, connection_setup_t conn_setup, struct resp_ctx **responder_ctx); diff --git a/src/responder/common/responder_common.c b/src/responder/common/responder_common.c index 7f6264ae70e5073063b5cfcd73098eefad2ce653..c604c64a652221521ec7114b8588186f087eb11a 100644 --- a/src/responder/common/responder_common.c +++ b/src/responder/common/responder_common.c @@ -549,7 +549,7 @@ void idle_handler(struct tevent_context *ev, } static int sss_dp_init(struct resp_ctx *rctx, - struct sbus_vtable *dp_intf, + struct sbus_iface_map *sbus_iface, const char *cli_name, struct sss_domain_info *domain) { @@ -577,10 +577,12 @@ static int sss_dp_init(struct resp_ctx *rctx, return ret; } - ret = sbus_conn_register_iface(be_conn->conn, dp_intf, DP_PATH, rctx); - if (ret != EOK) { - DEBUG(SSSDBG_FATAL_FAILURE, "Failed to export data provider.\n"); - return ret; + if (sbus_iface != NULL) { + ret = sbus_conn_register_iface_map(be_conn->conn, sbus_iface, rctx); + if (ret != EOK) { + DEBUG(SSSDBG_FATAL_FAILURE, "Failed to register D-Bus interface.\n"); + return ret; + } } DLIST_ADD_END(rctx->be_conns, be_conn, struct be_conn *); @@ -925,7 +927,7 @@ int sss_process_init(TALLOC_CTX *mem_ctx, uint16_t svc_version, struct mon_cli_iface *monitor_intf, const char *cli_name, - struct sbus_vtable *dp_intf, + struct sbus_iface_map *sbus_iface, connection_setup_t conn_setup, struct resp_ctx **responder_ctx) { @@ -1040,7 +1042,7 @@ int sss_process_init(TALLOC_CTX *mem_ctx, continue; } - ret = sss_dp_init(rctx, dp_intf, cli_name, dom); + ret = sss_dp_init(rctx, sbus_iface, cli_name, dom); if (ret != EOK) { DEBUG(SSSDBG_FATAL_FAILURE, "fatal error setting up backend connector\n"); diff --git a/src/responder/common/responder_get_domains.c b/src/responder/common/responder_get_domains.c index 6b354d8b2251f3a5cf576a58ae191fd99f307dd7..cc7b99f30046569547a08f83e46cbbe9d6c19897 100644 --- a/src/responder/common/responder_get_domains.c +++ b/src/responder/common/responder_get_domains.c @@ -88,8 +88,8 @@ sss_dp_get_domains_msg(void *pvt) msg = dbus_message_new_method_call(NULL, DP_PATH, - DATA_PROVIDER_IFACE, - DATA_PROVIDER_IFACE_GETDOMAINS); + IFACE_DP, + IFACE_DP_GETDOMAINS); if (msg == NULL) { DEBUG(SSSDBG_CRIT_FAILURE, "Out of memory?!\n"); return NULL; diff --git a/src/responder/ifp/ifpsrv.c b/src/responder/ifp/ifpsrv.c index a2137ecb218824909325df6c7052dbbbcb144679..0555c00167045707b7d455d28df368749b9b84f6 100644 --- a/src/responder/ifp/ifpsrv.c +++ b/src/responder/ifp/ifpsrv.c @@ -58,17 +58,6 @@ struct mon_cli_iface monitor_ifp_methods = { .sysbusReconnect = ifp_sysbus_reconnect, }; -static struct data_provider_iface ifp_dp_methods = { - { &data_provider_iface_meta, 0 }, - .RegisterService = NULL, - .pamHandler = NULL, - .sudoHandler = NULL, - .autofsHandler = NULL, - .hostHandler = NULL, - .getDomains = NULL, - .getAccountInfo = NULL, -}; - struct sss_cmd_table *get_ifp_cmds(void) { static struct sss_cmd_table ifp_cmds[] = { @@ -238,7 +227,7 @@ int ifp_process_init(TALLOC_CTX *mem_ctx, SSS_IFP_SBUS_SERVICE_VERSION, &monitor_ifp_methods, "InfoPipe", - &ifp_dp_methods.vtable, + NULL, sss_connection_setup, &rctx); if (ret != EOK) { diff --git a/src/responder/nss/nss_iface.c b/src/responder/nss/nss_iface.c new file mode 100644 index 0000000000000000000000000000000000000000..b01732e086c5fc5c7018ec84c3438e19ed812fef --- /dev/null +++ b/src/responder/nss/nss_iface.c @@ -0,0 +1,38 @@ +/* + Authors: + Pavel Březina + + Copyright (C) 2016 Red Hat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#include "sbus/sssd_dbus.h" +#include "responder/nss/nss_iface.h" +#include "responder/nss/nsssrv.h" + +struct iface_nss_memorycache iface_nss_memorycache = { + { &iface_nss_memorycache_meta, 0 }, + .UpdateInitgroups = nss_memorycache_update_initgroups +}; + +static struct sbus_iface_map iface_map[] = { + { NSS_MEMORYCACHE_PATH, &iface_nss_memorycache.vtable }, + { NULL, NULL } +}; + +struct sbus_iface_map *nss_get_sbus_interface() +{ + return iface_map; +} diff --git a/src/responder/nss/nss_iface.h b/src/responder/nss/nss_iface.h new file mode 100644 index 0000000000000000000000000000000000000000..ab59928c3e2dac62cea6f793ff774d9e0f8da6db --- /dev/null +++ b/src/responder/nss/nss_iface.h @@ -0,0 +1,30 @@ +/* + Authors: + Pavel Březina + + Copyright (C) 2016 Red Hat + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . +*/ + +#ifndef _NSS_IFACE_H_ +#define _NSS_IFACE_H_ + +#include "responder/nss/nss_iface_generated.h" + +#define NSS_MEMORYCACHE_PATH "/org/freedesktop/sssd/nss/memcache" + +struct sbus_iface_map *nss_get_sbus_interface(void); + +#endif /* _NSS_IFACE_H_ */ diff --git a/src/responder/nss/nss_iface.xml b/src/responder/nss/nss_iface.xml new file mode 100644 index 0000000000000000000000000000000000000000..b7cc4deb77135a592bad2ca62570f206231129b7 --- /dev/null +++ b/src/responder/nss/nss_iface.xml @@ -0,0 +1,12 @@ + + + + + + + + + + + diff --git a/src/responder/nss/nss_iface_generated.c b/src/responder/nss/nss_iface_generated.c new file mode 100644 index 0000000000000000000000000000000000000000..2d0031090e33df9c9e9d9fbf1a18825026509803 --- /dev/null +++ b/src/responder/nss/nss_iface_generated.c @@ -0,0 +1,69 @@ +/* The following definitions are auto-generated from nss_iface.xml */ + +#include "util/util.h" +#include "sbus/sssd_dbus.h" +#include "sbus/sssd_dbus_meta.h" +#include "sbus/sssd_dbus_invokers.h" +#include "nss_iface_generated.h" + +/* invokes a handler with a 'ssau' DBus signature */ +static int invoke_ssau_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" }, + { "domain", "s" }, + { "groups", "au" }, + { NULL, } +}; + +int iface_nss_memorycache_UpdateInitgroups_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[] = { + { + "UpdateInitgroups", /* name */ + iface_nss_memorycache_UpdateInitgroups__in, + NULL, /* no out_args */ + offsetof(struct iface_nss_memorycache, UpdateInitgroups), + invoke_ssau_method, + }, + { NULL, } +}; + +/* interface info for org.freedesktop.sssd.nss.MemoryCache */ +const struct sbus_interface_meta iface_nss_memorycache_meta = { + "org.freedesktop.sssd.nss.MemoryCache", /* name */ + iface_nss_memorycache__methods, + NULL, /* no signals */ + NULL, /* no properties */ + sbus_invoke_get_all, /* GetAll invoker */ +}; + +/* invokes a handler with a 'ssau' DBus signature */ +static int invoke_ssau_method(struct sbus_request *dbus_req, void *function_ptr) +{ + const char * arg_0; + const char * arg_1; + uint32_t *arg_2; + int len_2; + int (*handler)(struct sbus_request *, void *, const char *, const char *, uint32_t[], int) = function_ptr; + + if (!sbus_request_parse_or_finish(dbus_req, + DBUS_TYPE_STRING, &arg_0, + DBUS_TYPE_STRING, &arg_1, + DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &arg_2, &len_2, + DBUS_TYPE_INVALID)) { + return EOK; /* request handled */ + } + + return (handler)(dbus_req, dbus_req->intf->handler_data, + arg_0, + arg_1, + arg_2, + len_2); +} diff --git a/src/responder/nss/nss_iface_generated.h b/src/responder/nss/nss_iface_generated.h new file mode 100644 index 0000000000000000000000000000000000000000..ad902482a9be03a60cbf3663b6f771d0a2020b88 --- /dev/null +++ b/src/responder/nss/nss_iface_generated.h @@ -0,0 +1,58 @@ +/* The following declarations are auto-generated from nss_iface.xml */ + +#ifndef __NSS_IFACE_XML__ +#define __NSS_IFACE_XML__ + +#include "sbus/sssd_dbus.h" + +/* ------------------------------------------------------------------------ + * DBus Constants + * + * Various constants of interface and method names mostly for use by clients + */ + +/* constants for org.freedesktop.sssd.nss.MemoryCache */ +#define IFACE_NSS_MEMORYCACHE "org.freedesktop.sssd.nss.MemoryCache" +#define IFACE_NSS_MEMORYCACHE_UPDATEINITGROUPS "UpdateInitgroups" + +/* ------------------------------------------------------------------------ + * DBus handlers + * + * These structures are filled in by implementors of the different + * dbus interfaces to handle method calls. + * + * Handler functions of type sbus_msg_handler_fn accept raw messages, + * other handlers are typed appropriately. If a handler that is + * set to NULL is invoked it will result in a + * org.freedesktop.DBus.Error.NotSupported error for the caller. + * + * Handlers have a matching xxx_finish() function (unless the method has + * accepts raw messages). These finish functions the + * sbus_request_return_and_finish() with the appropriate arguments to + * construct a valid reply. Once a finish function has been called, the + * @dbus_req it was called with is freed and no longer valid. + */ + +/* vtable for org.freedesktop.sssd.nss.MemoryCache */ +struct iface_nss_memorycache { + struct sbus_vtable vtable; /* derive from sbus_vtable */ + int (*UpdateInitgroups)(struct sbus_request *req, void *data, const char *arg_user, const char *arg_domain, uint32_t arg_groups[], int len_groups); +}; + +/* finish function for UpdateInitgroups */ +int iface_nss_memorycache_UpdateInitgroups_finish(struct sbus_request *req); + +/* ------------------------------------------------------------------------ + * DBus Interface Metadata + * + * These structure definitions are filled in with the information about + * the interfaces, methods, properties and so on. + * + * The actual definitions are found in the accompanying C file next + * to this header. + */ + +/* interface info for org.freedesktop.sssd.nss.MemoryCache */ +extern const struct sbus_interface_meta iface_nss_memorycache_meta; + +#endif /* __NSS_IFACE_XML__ */ diff --git a/src/responder/nss/nsssrv.c b/src/responder/nss/nsssrv.c index 8be3455e57e07481e7cf7d4d0f525dad5b8601fc..05b51ecdf2e17e20af2ee3ee48377cbe1bf19a24 100644 --- a/src/responder/nss/nsssrv.c +++ b/src/responder/nss/nsssrv.c @@ -37,6 +37,7 @@ #include "responder/nss/nsssrv_private.h" #include "responder/nss/nsssrv_mmap_cache.h" #include "responder/nss/nsssrv_netgroup.h" +#include "responder/nss/nss_iface.h" #include "responder/common/negcache.h" #include "db/sysdb.h" #include "confdb/confdb.h" @@ -327,7 +328,7 @@ done: return ret; } -static int nss_update_memcache(struct sbus_request *dbus_req, void *data) +int nss_update_memcache(struct sbus_request *dbus_req, void *data) { struct resp_ctx *rctx = talloc_get_type(data, struct resp_ctx); struct nss_ctx *nctx = talloc_get_type(rctx->pvt_ctx, struct nss_ctx); @@ -338,37 +339,24 @@ static int nss_update_memcache(struct sbus_request *dbus_req, void *data) return EOK; } -static int nss_memcache_initgr_check(struct sbus_request *dbus_req, void *data) +int nss_memorycache_update_initgroups(struct sbus_request *sbus_req, + void *data, + const char *user, + const char *domain, + uint32_t *groups, + int num_groups) { struct resp_ctx *rctx = talloc_get_type(data, struct resp_ctx); struct nss_ctx *nctx = talloc_get_type(rctx->pvt_ctx, struct nss_ctx); - char *user; - char *domain; - uint32_t *groups; - int gnum; - if (!sbus_request_parse_or_finish(dbus_req, - DBUS_TYPE_STRING, &user, - DBUS_TYPE_STRING, &domain, - DBUS_TYPE_ARRAY, DBUS_TYPE_UINT32, &groups, &gnum, - DBUS_TYPE_INVALID)) { - return EOK; /* handled */ - } + DEBUG(SSSDBG_TRACE_LIBS, "Updating inigroups memory cache of [%s@%s]\n", + user, domain); - DEBUG(SSSDBG_TRACE_LIBS, - "Got request for [%s@%s]\n", user, domain); + nss_update_initgr_memcache(nctx, user, domain, num_groups, groups); - nss_update_initgr_memcache(nctx, user, domain, gnum, groups); - - return sbus_request_return_and_finish(dbus_req, DBUS_TYPE_INVALID); + return iface_nss_memorycache_UpdateInitgroups_finish(sbus_req); } -static struct data_provider_rev_iface nss_dp_methods = { - { &data_provider_rev_iface_meta, 0 }, - .updateCache = nss_update_memcache, - .initgrCheck = nss_memcache_initgr_check -}; - static void nss_dp_reconnect_init(struct sbus_connection *conn, int status, void *pvt) { @@ -419,7 +407,8 @@ int nss_process_init(TALLOC_CTX *mem_ctx, NSS_SBUS_SERVICE_NAME, NSS_SBUS_SERVICE_VERSION, &monitor_nss_methods, - "NSS", &nss_dp_methods.vtable, + "NSS", + nss_get_sbus_interface(), nss_connection_setup, &rctx); if (ret != EOK) { diff --git a/src/responder/nss/nsssrv.h b/src/responder/nss/nsssrv.h index 2977479aa52082480f92eab94f7833e2e696a9ac..d4a80f76df236f40d872c701687bf453255d9890 100644 --- a/src/responder/nss/nsssrv.h +++ b/src/responder/nss/nsssrv.h @@ -81,4 +81,11 @@ struct nss_packet; struct sss_cmd_table *get_nss_cmds(void); +int nss_memorycache_update_initgroups(struct sbus_request *sbus_req, + void *data, + const char *user, + const char *domain, + uint32_t *groups, + int num_groups); + #endif /* __NSSSRV_H__ */ diff --git a/src/responder/pac/pacsrv.c b/src/responder/pac/pacsrv.c index 15d1986f842ac8397cf509ca8ef44728d6ddc5f1..852deb10eff014189d35a2769d895a901d8296e1 100644 --- a/src/responder/pac/pacsrv.c +++ b/src/responder/pac/pacsrv.c @@ -61,17 +61,6 @@ struct mon_cli_iface monitor_pac_methods = { .sysbusReconnect = NULL, }; -static struct data_provider_iface pac_dp_methods = { - { &data_provider_iface_meta, 0 }, - .RegisterService = NULL, - .pamHandler = NULL, - .sudoHandler = NULL, - .autofsHandler = NULL, - .hostHandler = NULL, - .getDomains = NULL, - .getAccountInfo = NULL, -}; - /* TODO: check if this can be made generic for all responders */ static void pac_dp_reconnect_init(struct sbus_connection *conn, int status, void *pvt) @@ -122,7 +111,7 @@ int pac_process_init(TALLOC_CTX *mem_ctx, PAC_SBUS_SERVICE_NAME, PAC_SBUS_SERVICE_VERSION, &monitor_pac_methods, - "PAC", &pac_dp_methods.vtable, + "PAC", NULL, sss_connection_setup, &rctx); if (ret != EOK) { diff --git a/src/responder/pam/pamsrv.c b/src/responder/pam/pamsrv.c index efd1e5c7527decda5de7304b54919846fa2ee0db..9374de4d63b2886262ca1541daff581603d7c838 100644 --- a/src/responder/pam/pamsrv.c +++ b/src/responder/pam/pamsrv.c @@ -66,17 +66,6 @@ struct mon_cli_iface monitor_pam_methods = { .sysbusReconnect = NULL, }; -static struct data_provider_iface pam_dp_methods = { - { &data_provider_iface_meta, 0 }, - .RegisterService = NULL, - .pamHandler = NULL, - .sudoHandler = NULL, - .autofsHandler = NULL, - .hostHandler = NULL, - .getDomains = NULL, - .getAccountInfo = NULL, -}; - static void pam_dp_reconnect_init(struct sbus_connection *conn, int status, void *pvt) { struct be_conn *be_conn = talloc_get_type(pvt, struct be_conn); @@ -201,7 +190,7 @@ static int pam_process_init(TALLOC_CTX *mem_ctx, SSS_PAM_SBUS_SERVICE_NAME, SSS_PAM_SBUS_SERVICE_VERSION, &monitor_pam_methods, - "PAM", &pam_dp_methods.vtable, + "PAM", NULL, sss_connection_setup, &rctx); if (ret != EOK) { diff --git a/src/responder/pam/pamsrv_dp.c b/src/responder/pam/pamsrv_dp.c index 826146350670d67f897ee7eec2cf6ca607b96435..aa3fdc3c32d234ed54a9f5202886157601ee3846 100644 --- a/src/responder/pam/pamsrv_dp.c +++ b/src/responder/pam/pamsrv_dp.c @@ -130,8 +130,8 @@ int pam_dp_send_req(struct pam_auth_req *preq, int timeout) msg = dbus_message_new_method_call(NULL, DP_PATH, - DATA_PROVIDER_IFACE, - DATA_PROVIDER_IFACE_PAMHANDLER); + IFACE_DP, + IFACE_DP_PAMHANDLER); if (msg == NULL) { DEBUG(SSSDBG_FATAL_FAILURE,"Out of memory?!\n"); return ENOMEM; diff --git a/src/responder/ssh/sshsrv.c b/src/responder/ssh/sshsrv.c index f763e3b00d20527225046a85609e7ff56861f682..88938215b542b5748721cfecc59ca4141010fb88 100644 --- a/src/responder/ssh/sshsrv.c +++ b/src/responder/ssh/sshsrv.c @@ -41,17 +41,6 @@ struct mon_cli_iface monitor_ssh_methods = { .sysbusReconnect = NULL, }; -static struct data_provider_iface ssh_dp_methods = { - { &data_provider_iface_meta, 0 }, - .RegisterService = NULL, - .pamHandler = NULL, - .sudoHandler = NULL, - .autofsHandler = NULL, - .hostHandler = NULL, - .getDomains = NULL, - .getAccountInfo = NULL, -}; - static void ssh_dp_reconnect_init(struct sbus_connection *conn, int status, void *pvt) { @@ -96,7 +85,7 @@ int ssh_process_init(TALLOC_CTX *mem_ctx, SSS_SSH_SBUS_SERVICE_VERSION, &monitor_ssh_methods, "SSH", - &ssh_dp_methods.vtable, + NULL, sss_connection_setup, &rctx); if (ret != EOK) { diff --git a/src/responder/sudo/sudosrv.c b/src/responder/sudo/sudosrv.c index e0346033e38f1e39e621e131c3265a583b91a5c3..d832686a8572f3729a0477cdca2f77ebcb19fbc0 100644 --- a/src/responder/sudo/sudosrv.c +++ b/src/responder/sudo/sudosrv.c @@ -42,17 +42,6 @@ struct mon_cli_iface monitor_sudo_methods = { .sysbusReconnect = NULL, }; -static struct data_provider_iface sudo_dp_methods = { - { &data_provider_iface_meta, 0 }, - .RegisterService = NULL, - .pamHandler = NULL, - .sudoHandler = NULL, - .autofsHandler = NULL, - .hostHandler = NULL, - .getDomains = NULL, - .getAccountInfo = NULL, -}; - static void sudo_dp_reconnect_init(struct sbus_connection *conn, int status, void *pvt) @@ -98,7 +87,7 @@ int sudo_process_init(TALLOC_CTX *mem_ctx, SSS_SUDO_SBUS_SERVICE_VERSION, &monitor_sudo_methods, "SUDO", - &sudo_dp_methods.vtable, + NULL, sss_connection_setup, &rctx); if (ret != EOK) { diff --git a/src/tests/cwrap/Makefile.am b/src/tests/cwrap/Makefile.am index d8a49f1434cefc02bc7fce505d1b4e07fc74ec5f..3e40cba52e927730483b14cc7e56687b250de646 100644 --- a/src/tests/cwrap/Makefile.am +++ b/src/tests/cwrap/Makefile.am @@ -49,7 +49,6 @@ SSSD_RESPONDER_OBJ = \ ../../../src/responder/common/data_provider/rdp_message.c \ ../../../src/responder/common/data_provider/rdp_client.c \ ../../../src/monitor/monitor_iface_generated.c \ - ../../../src/providers/data_provider_iface_generated.c \ ../../../src/providers/data_provider_req.c dist_noinst_DATA = \ -- 2.4.11