diff options
author | Jakub Hrozek <jhrozek@redhat.com> | 2014-04-10 09:11:12 +0200 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2014-06-03 13:16:26 +0200 |
commit | e00e430c6eb82673daa2c248e642dec264f211cc (patch) | |
tree | c332988a610757d60086fa7672e92c02a36d564d /src/sbus/sssd_dbus_connection.c | |
parent | 9cd08bf4b843529c14f71655d62687589301f198 (diff) | |
download | sssd-e00e430c6eb82673daa2c248e642dec264f211cc.tar.gz sssd-e00e430c6eb82673daa2c248e642dec264f211cc.tar.xz sssd-e00e430c6eb82673daa2c248e642dec264f211cc.zip |
SBUS: Generate introspection from the interface meta structure
https://fedorahosted.org/sssd/ticket/2234
This patch generates the introspection data from the sbus interface meta
structure. The generated XML conforms to
http://dbus.freedesktop.org/doc/dbus-specification.html#introspection-format
The XML description of the interface also always includes the
org.freedesktop.DBus.Introspectable interface, which this patch also allows
in the policy settings.
(cherry picked from commit 42c28b9424b6ef8a0021b124773e171dd5defadd)
Diffstat (limited to 'src/sbus/sssd_dbus_connection.c')
-rw-r--r-- | src/sbus/sssd_dbus_connection.c | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/src/sbus/sssd_dbus_connection.c b/src/sbus/sssd_dbus_connection.c index 1d927c847..27e1f3ea8 100644 --- a/src/sbus/sssd_dbus_connection.c +++ b/src/sbus/sssd_dbus_connection.c @@ -377,6 +377,8 @@ DBusHandlerResult sbus_message_handler(DBusConnection *dbus_conn, const struct sbus_interface_meta *interface; struct sbus_request *dbus_req = NULL; sbus_msg_handler_fn handler_fn = NULL; + void *handler_data = NULL; /* Must be a talloc pointer! */ + struct sbus_introspect_ctx *ictx = NULL; DBusHandlerResult result; int ret; @@ -424,19 +426,46 @@ DBusHandlerResult sbus_message_handler(DBusConnection *dbus_conn, dbus_message_unref(reply); result = DBUS_HANDLER_RESULT_HANDLED; } + } else { + /* Special case: check for Introspection request + * This is usually only useful for system bus connections + */ + if (strcmp(msg_interface, DBUS_INTROSPECT_INTERFACE) == 0 && + strcmp(msg_method, DBUS_INTROSPECT_METHOD) == 0) { + DEBUG(SSSDBG_TRACE_LIBS, "Got introspection request\n"); + ictx = talloc(intf_p->conn, struct sbus_introspect_ctx); + if (ictx == NULL) { + result = sbus_reply_internal_error(message, intf_p->conn); + } else { + handler_fn = sbus_introspect; + ictx->iface = interface; + handler_data = ictx; + } + } } if (handler_fn) { dbus_req = sbus_new_request(intf_p->conn, intf_p->intf, message); if (!dbus_req) { + talloc_zfree(handler_data); ret = ENOMEM; } else { dbus_req->method = method; - ret = handler_fn(dbus_req, intf_p->intf->instance_data); + if (handler_data) { + /* If the handler uses private instance data, make + * sure they go away when the request does + */ + talloc_steal(dbus_req, handler_data); + } else { + /* If no custom handler data is set, pass on the + * interface data + */ + handler_data = intf_p->intf->instance_data; + } + ret = handler_fn(dbus_req, handler_data); } if (ret != EOK) { - if (dbus_req) - talloc_free(dbus_req); + talloc_free(dbus_req); result = sbus_reply_internal_error(message, intf_p->conn); } else { result = DBUS_HANDLER_RESULT_HANDLED; |