mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-01-11 23:16:14 +01:00
gdbus-tool: Require message bus connections for most commands
Previously, if the `--address` option was passed to `gdbus-tool`, it would treat the connection as peer to peer. However, almost all the commands `gdbus-tool` supports require a message bus (introspection, calling a method with a destination, etc.). Only the `signal` command would ever work on a peer-to-peer connection (if no `--dest` was specified). So change the `--address` option to generally create message bus connections. Signed-off-by: Philip Withnall <withnall@endlessm.com> Fixes: #938
This commit is contained in:
parent
d40275ceb7
commit
177851c9b7
@ -414,7 +414,8 @@ connection_get_group (void)
|
||||
}
|
||||
|
||||
static GDBusConnection *
|
||||
connection_get_dbus_connection (GError **error)
|
||||
connection_get_dbus_connection (gboolean require_message_bus,
|
||||
GError **error)
|
||||
{
|
||||
GDBusConnection *c;
|
||||
|
||||
@ -450,8 +451,11 @@ connection_get_dbus_connection (GError **error)
|
||||
}
|
||||
else if (opt_connection_address != NULL)
|
||||
{
|
||||
GDBusConnectionFlags flags = G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT;
|
||||
if (require_message_bus)
|
||||
flags |= G_DBUS_CONNECTION_FLAGS_MESSAGE_BUS_CONNECTION;
|
||||
c = g_dbus_connection_new_for_address_sync (opt_connection_address,
|
||||
G_DBUS_CONNECTION_FLAGS_AUTHENTICATION_CLIENT,
|
||||
flags,
|
||||
NULL, /* GDBusAuthObserver */
|
||||
NULL, /* GCancellable */
|
||||
error);
|
||||
@ -649,7 +653,7 @@ handle_emit (gint *argc,
|
||||
}
|
||||
|
||||
error = NULL;
|
||||
c = connection_get_dbus_connection (&error);
|
||||
c = connection_get_dbus_connection ((opt_emit_dest != NULL), &error);
|
||||
if (c == NULL)
|
||||
{
|
||||
if (request_completion)
|
||||
@ -956,7 +960,7 @@ handle_call (gint *argc,
|
||||
}
|
||||
|
||||
error = NULL;
|
||||
c = connection_get_dbus_connection (&error);
|
||||
c = connection_get_dbus_connection (TRUE, &error);
|
||||
if (c == NULL)
|
||||
{
|
||||
if (request_completion)
|
||||
@ -1750,7 +1754,7 @@ handle_introspect (gint *argc,
|
||||
}
|
||||
|
||||
error = NULL;
|
||||
c = connection_get_dbus_connection (&error);
|
||||
c = connection_get_dbus_connection (TRUE, &error);
|
||||
if (c == NULL)
|
||||
{
|
||||
if (request_completion)
|
||||
@ -1982,7 +1986,7 @@ handle_monitor (gint *argc,
|
||||
}
|
||||
|
||||
error = NULL;
|
||||
c = connection_get_dbus_connection (&error);
|
||||
c = connection_get_dbus_connection (TRUE, &error);
|
||||
if (c == NULL)
|
||||
{
|
||||
if (request_completion)
|
||||
@ -2202,7 +2206,7 @@ handle_wait (gint *argc,
|
||||
}
|
||||
|
||||
error = NULL;
|
||||
c = connection_get_dbus_connection (&error);
|
||||
c = connection_get_dbus_connection (TRUE, &error);
|
||||
if (c == NULL)
|
||||
{
|
||||
if (request_completion)
|
||||
|
Loading…
Reference in New Issue
Block a user