diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2014-06-25 12:33:03 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2014-07-08 20:38:16 +0200 |
commit | b76419cf8830440b46c20a15585562343c7b1924 (patch) | |
tree | aa7846d57deb98274a1bb49bc67797b20ea86a41 /src/responder/ifp | |
parent | 0c1d65998907930678da2d091789446f2c344d5d (diff) | |
download | sssd-b76419cf8830440b46c20a15585562343c7b1924.tar.gz sssd-b76419cf8830440b46c20a15585562343c7b1924.tar.xz sssd-b76419cf8830440b46c20a15585562343c7b1924.zip |
IFP: Provide a SBUS method to reconnect to sysbus
Introduces a new method implemented only by the IFP responder. When this
method is received, the responder attempts to reconnect to the system
bus, if not connected already.
Reviewed-by: Pavel Březina <pbrezina@redhat.com>
Reviewed-by: Pavel Reichl <preichl@redhat.com>
Diffstat (limited to 'src/responder/ifp')
-rw-r--r-- | src/responder/ifp/ifpsrv.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/responder/ifp/ifpsrv.c b/src/responder/ifp/ifpsrv.c index 9014c3e85..4af836543 100644 --- a/src/responder/ifp/ifpsrv.c +++ b/src/responder/ifp/ifpsrv.c @@ -44,6 +44,8 @@ #define DEFAULT_ALLOWED_UIDS "0" +static int ifp_sysbus_reconnect(struct sbus_request *dbus_req, void *data); + struct mon_cli_iface monitor_ifp_methods = { { &mon_cli_iface_meta, 0 }, .ping = monitor_common_pong, @@ -52,6 +54,7 @@ struct mon_cli_iface monitor_ifp_methods = { .goOffline = NULL, .resetOffline = NULL, .rotateLogs = responder_logrotate, + .sysbusReconnect = ifp_sysbus_reconnect, }; static struct data_provider_iface ifp_dp_methods = { @@ -257,6 +260,40 @@ fail: return ret; } +static int ifp_sysbus_reconnect(struct sbus_request *dbus_req, void *data) +{ + struct resp_ctx *rctx = talloc_get_type(data, struct resp_ctx); + struct ifp_ctx *ifp_ctx = (struct ifp_ctx*) rctx->pvt_ctx; + errno_t ret; + + DEBUG(SSSDBG_TRACE_FUNC, "Attempting to reconnect to the system bus\n"); + + if (ifp_ctx->sysbus) { + DEBUG(SSSDBG_TRACE_LIBS, "Already connected to sysbus\n"); + goto done; + } + + /* Connect to the D-BUS system bus and set up methods */ + ret = sysbus_init(ifp_ctx, ifp_ctx->rctx->ev, + INFOPIPE_IFACE, + ifp_ifaces, + ifp_ctx, &ifp_ctx->sysbus); + if (ret == ERR_NO_SYSBUS) { + DEBUG(SSSDBG_MINOR_FAILURE, + "The system bus is not available..\n"); + goto done; + } else if (ret != EOK) { + DEBUG(SSSDBG_CRIT_FAILURE, + "Failed to connect to the system message bus\n"); + return ret; + } + + DEBUG(SSSDBG_TRACE_LIBS, "Reconnected to the system bus!\n"); + +done: + return sbus_request_return_and_finish(dbus_req, DBUS_TYPE_INVALID); +} + int ifp_process_init(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct confdb_ctx *cdb) |