diff options
author | Stef Walter <stefw@redhat.com> | 2014-02-18 14:32:54 +0100 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2014-03-14 13:42:20 +0100 |
commit | 07e941c1bbdc752142bbd3b838c540bc7ecd0ed7 (patch) | |
tree | 56453ab3ece875a6f80fc374fadaef07584484b7 /src/responder/nss/nsssrv.c | |
parent | d9577dbd92555b0755881e37724019ef9c578404 (diff) | |
download | sssd-07e941c1bbdc752142bbd3b838c540bc7ecd0ed7.tar.gz sssd-07e941c1bbdc752142bbd3b838c540bc7ecd0ed7.tar.xz sssd-07e941c1bbdc752142bbd3b838c540bc7ecd0ed7.zip |
sbus: Refactor how we export DBus interfaces
Most importantly, stop using per connection private data. This doesn't
scale when you have more than one thing exporting or exported on a
connection.
Remove struct sbus_interface and expand sbus_conn_add_interface()
function. Remove various struct sbus_interface args to connection
initialization functions and make callers use sbus_conn_add_interface()
directly. The old method was optimized for exporting one interface
on a connection. We'll have connections that export zero, one or more
interfaces.
To export an interface on a DBus server, call sbus_conn_add_interface()
from within the sbus_server_conn_init_fn. To export an interface on
a DBus client, call sbus_conn_add_interface() after sbus_new_connection()
returns.
As before struct sbus_interface represents an object exported via DBus.
However it is now talloc allocated. One can set instance data on the
struct sbus_interface. This instance data is passed to the various
handlers and used in their implementation.
However, we now have type safe interface exporting in the various
high level sss_process_init() sss_monitor_init() and so on.
Introspection support was not in use, and is now gone until we
implement it using the metadata (future patch).
Reviewed-by: Jakub Hrozek <jhrozek@redhat.com>
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
Reviewed-by: Lukáš Slebodník <lslebodn@redhat.com>
Diffstat (limited to 'src/responder/nss/nsssrv.c')
-rw-r--r-- | src/responder/nss/nsssrv.c | 41 |
1 files changed, 12 insertions, 29 deletions
diff --git a/src/responder/nss/nsssrv.c b/src/responder/nss/nsssrv.c index 05bcdda07..ca4fbfd02 100644 --- a/src/responder/nss/nsssrv.c +++ b/src/responder/nss/nsssrv.c @@ -55,8 +55,8 @@ #define SHELL_REALLOC_INCREMENT 5 #define SHELL_REALLOC_MAX 50 -static int nss_clear_memcache(struct sbus_request *dbus_req); -static int nss_clear_netgroup_hash_table(struct sbus_request *dbus_req); +static int nss_clear_memcache(struct sbus_request *dbus_req, void *data); +static int nss_clear_netgroup_hash_table(struct sbus_request *dbus_req, void *data); struct mon_cli_iface monitor_nss_methods = { { &mon_cli_iface_meta, 0 }, @@ -70,18 +70,11 @@ struct mon_cli_iface monitor_nss_methods = { .clearEnumCache = nss_clear_netgroup_hash_table }; -struct sbus_interface monitor_nss_interface = { - MONITOR_PATH, - &monitor_nss_methods.vtable, - NULL, -}; - -static int nss_clear_memcache(struct sbus_request *dbus_req) +static int nss_clear_memcache(struct sbus_request *dbus_req, void *data) { errno_t ret; int memcache_timeout; - struct resp_ctx *rctx = talloc_get_type(sbus_conn_get_private_data(dbus_req->conn), - struct resp_ctx); + struct resp_ctx *rctx = talloc_get_type(data, struct resp_ctx); struct nss_ctx *nctx = (struct nss_ctx*) rctx->pvt_ctx; ret = unlink(SSS_NSS_MCACHE_DIR"/"CLEAR_MC_FLAG); @@ -134,11 +127,10 @@ done: return sbus_request_return_and_finish(dbus_req, DBUS_TYPE_INVALID); } -static int nss_clear_netgroup_hash_table(struct sbus_request *dbus_req) +static int nss_clear_netgroup_hash_table(struct sbus_request *dbus_req, void *data) { errno_t ret; - struct resp_ctx *rctx = talloc_get_type(sbus_conn_get_private_data(dbus_req->conn), - struct resp_ctx); + struct resp_ctx *rctx = talloc_get_type(data, struct resp_ctx); struct nss_ctx *nctx = (struct nss_ctx*) rctx->pvt_ctx; ret = nss_orphan_netgroups(nctx); @@ -304,10 +296,9 @@ done: return ret; } -static int nss_update_memcache(struct sbus_request *dbus_req) +static int nss_update_memcache(struct sbus_request *dbus_req, void *data) { - struct resp_ctx *rctx = talloc_get_type(sbus_conn_get_private_data(dbus_req->conn), - struct resp_ctx); + struct resp_ctx *rctx = talloc_get_type(data, struct resp_ctx); struct nss_ctx *nctx = talloc_get_type(rctx->pvt_ctx, struct nss_ctx); nss_update_pw_memcache(nctx); @@ -316,10 +307,9 @@ static int nss_update_memcache(struct sbus_request *dbus_req) return EOK; } -static int nss_memcache_initgr_check(struct sbus_request *dbus_req) +static int nss_memcache_initgr_check(struct sbus_request *dbus_req, void *data) { - struct resp_ctx *rctx = talloc_get_type(sbus_conn_get_private_data(dbus_req->conn), - struct resp_ctx); + struct resp_ctx *rctx = talloc_get_type(data, struct resp_ctx); struct nss_ctx *nctx = talloc_get_type(rctx->pvt_ctx, struct nss_ctx); DBusError dbus_error; dbus_bool_t dbret; @@ -359,13 +349,6 @@ static struct data_provider_rev_iface nss_dp_methods = { .initgrCheck = nss_memcache_initgr_check }; -struct sbus_interface nss_dp_interface = { - DP_PATH, - &nss_dp_methods.vtable, - NULL -}; - - static void nss_dp_reconnect_init(struct sbus_connection *conn, int status, void *pvt) { @@ -417,8 +400,8 @@ int nss_process_init(TALLOC_CTX *mem_ctx, CONFDB_NSS_CONF_ENTRY, NSS_SBUS_SERVICE_NAME, NSS_SBUS_SERVICE_VERSION, - &monitor_nss_interface, - "NSS", &nss_dp_interface, + &monitor_nss_methods, + "NSS", &nss_dp_methods.vtable, &rctx); if (ret != EOK) { DEBUG(SSSDBG_FATAL_FAILURE, "sss_process_init() failed\n"); |