summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Williams <dcbw@redhat.com>2012-10-07 10:55:50 -0500
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2012-12-04 17:37:47 +0000
commitbed0713c0a67b7bd558285b748ff212a3dfdd003 (patch)
treeaae724e02150ca14ef0b5afade0330da2746b144
parentf9056cf5fe5ce67ad0b530c9af1977860231dde2 (diff)
downloaddbus-glib-bed0713c0a67b7bd558285b748ff212a3dfdd003.tar.gz
Add DBusGMethodInvocation accessor for the DBusGConnection
If you're using two connections, say a shared connection and a private connection that uses DBusServer, there's no way to figure out which DBusConnection a method invocation originates from, and thus no way to do access control based on that. Private bus setup done with eg: void new_conn_func(DBusServer *s, DBusConnection *conn, gpointer to_export) { DBusGConnection *gconn; /* set access control, eg with dbus_connection_set_unix_user_function() */ dbus_connection_setup_with_g_main(conn, NULL); gconn = dbus_connection_get_g_connection(conn); dbus_g_connection_register_object(gconn, "/foo", G_OBJECT (to_export)); } void start_server(GObject *to_export) { DBusServer *s; s = dbus_server_listen("unix:path=/var/foo", NULL); dbus_server_setup_with_g_main (s, NULL); dbus_server_set_new_connection_function (s, new_conn_func, to_export); } Reviewed-by: Simon McVittie <simon.mcvittie@collabora.co.uk> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=55729
-rw-r--r--dbus/dbus-glib.h2
-rw-r--r--dbus/dbus-gobject.c16
2 files changed, 18 insertions, 0 deletions
diff --git a/dbus/dbus-glib.h b/dbus/dbus-glib.h
index bd5784c..9aa71c1 100644
--- a/dbus/dbus-glib.h
+++ b/dbus/dbus-glib.h
@@ -329,6 +329,8 @@ void dbus_g_method_return (DBusGMethodInvocation *con
void dbus_g_method_return_error (DBusGMethodInvocation *context, const GError *error);
+DBusGConnection * dbus_g_method_invocation_get_g_connection (DBusGMethodInvocation *context);
+
/* Probably possible to replace this with a closure */
typedef struct {
GCallback cb;
diff --git a/dbus/dbus-gobject.c b/dbus/dbus-gobject.c
index bac91be..9889836 100644
--- a/dbus/dbus-gobject.c
+++ b/dbus/dbus-gobject.c
@@ -3276,6 +3276,22 @@ out:
g_free (context);
}
+/**
+ * dbus_g_method_invocation_get_g_connection:
+ * @context: the method context
+ *
+ * <!-- Returns: says it all -->
+ *
+ * Returns: (transfer none): the @DBusGConnection from which the method was called.
+ */
+DBusGConnection *
+dbus_g_method_invocation_get_g_connection (DBusGMethodInvocation *context)
+{
+ g_return_val_if_fail (context != NULL, NULL);
+
+ return context->connection;
+}
+
const char *
_dbus_gobject_get_path (GObject *obj)
{