Merge branch '938-gdbus-tool-message-bus-connections' into 'master'

gdbus-tool: Require message bus connections for most commands

Closes #938

See merge request GNOME/glib!926
This commit is contained in:
Sebastian Dröge 2020-02-24 12:53:57 +00:00
commit e3c69acf01

View File

@ -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)