mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-09 12:25:48 +01:00
gapplication: don't emit warnings for DBus calls
If a broken (or malicious) remote client calls Open or CommandLine on a GApplication that does not implement those, return a DBus error instead of going through and then emitting a warning. https://bugzilla.gnome.org/show_bug.cgi?id=710885
This commit is contained in:
parent
3e48e3be40
commit
415c6d2e27
@ -203,12 +203,20 @@ g_application_impl_method_call (GDBusConnection *connection,
|
|||||||
|
|
||||||
else if (strcmp (method_name, "Open") == 0)
|
else if (strcmp (method_name, "Open") == 0)
|
||||||
{
|
{
|
||||||
|
GApplicationFlags flags;
|
||||||
GVariant *platform_data;
|
GVariant *platform_data;
|
||||||
const gchar *hint;
|
const gchar *hint;
|
||||||
GVariant *array;
|
GVariant *array;
|
||||||
GFile **files;
|
GFile **files;
|
||||||
gint n, i;
|
gint n, i;
|
||||||
|
|
||||||
|
flags = g_application_get_flags (impl->app);
|
||||||
|
if ((flags & G_APPLICATION_HANDLES_OPEN) == 0)
|
||||||
|
{
|
||||||
|
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_NOT_SUPPORTED, "Application does not open files");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* freedesktop interface has no hint parameter */
|
/* freedesktop interface has no hint parameter */
|
||||||
if (g_str_equal (interface_name, "org.freedesktop.Application"))
|
if (g_str_equal (interface_name, "org.freedesktop.Application"))
|
||||||
{
|
{
|
||||||
@ -246,10 +254,18 @@ g_application_impl_method_call (GDBusConnection *connection,
|
|||||||
|
|
||||||
else if (strcmp (method_name, "CommandLine") == 0)
|
else if (strcmp (method_name, "CommandLine") == 0)
|
||||||
{
|
{
|
||||||
|
GApplicationFlags flags;
|
||||||
GApplicationCommandLine *cmdline;
|
GApplicationCommandLine *cmdline;
|
||||||
GVariant *platform_data;
|
GVariant *platform_data;
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
|
flags = g_application_get_flags (impl->app);
|
||||||
|
if ((flags & G_APPLICATION_HANDLES_COMMAND_LINE) == 0)
|
||||||
|
{
|
||||||
|
g_dbus_method_invocation_return_error (invocation, G_DBUS_ERROR, G_DBUS_ERROR_NOT_SUPPORTED, "Application does not handle command line arguments");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* Only on the GtkApplication interface */
|
/* Only on the GtkApplication interface */
|
||||||
|
|
||||||
cmdline = g_dbus_command_line_new (invocation);
|
cmdline = g_dbus_command_line_new (invocation);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user