diff options
| author | Jakub Hrozek <jhrozek@redhat.com> | 2014-04-10 09:11:12 +0200 |
|---|---|---|
| committer | Jakub Hrozek <jhrozek@redhat.com> | 2014-04-15 11:24:43 +0200 |
| commit | 42c28b9424b6ef8a0021b124773e171dd5defadd (patch) | |
| tree | 4bb8c5fd4d6aef0dfe8087e2de3fd18917f7b637 /src/sbus/sssd_dbus_connection.c | |
| parent | 9123c2abff5780f485764261eb4b180e9ceadf20 (diff) | |
| download | sssd-42c28b9424b6ef8a0021b124773e171dd5defadd.tar.gz sssd-42c28b9424b6ef8a0021b124773e171dd5defadd.tar.xz sssd-42c28b9424b6ef8a0021b124773e171dd5defadd.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.
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 150b5469..64777fbe 100644 --- a/src/sbus/sssd_dbus_connection.c +++ b/src/sbus/sssd_dbus_connection.c @@ -378,6 +378,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; @@ -425,19 +427,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; |
