diff --git a/gio/gdbus-tool.c b/gio/gdbus-tool.c index 57978f1c2..863a5e80a 100644 --- a/gio/gdbus-tool.c +++ b/gio/gdbus-tool.c @@ -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)