Skip to content

gdbus-codegen: Add a GDBusCallFlags arg to method calls

Currently the code generated by gdbus-codegen uses G_DBUS_CALL_FLAGS_NONE in its D-Bus calls, which occur for each method defined by the input XML, and for proxy_set_property functions. This means that if the daemon which implements the methods checks for G_DBUS_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION and only does interactive authorization if that flag is present, users of the generated code have no way to cause the daemon to use interactive authorization (e.g. polkit dialogs).

If we simply changed the generated code to always use G_DBUS_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION, its users would have no way to disallow interactive authorization (except for manually calling the D-Bus method themselves).

So instead, this commit adds a GDBusCallFlags argument to method call functions. Since this is an API break which will require changes in projects using gdbus-codegen code, the change is conditional on the command line argument --glib-min-version having the value 2.64 or higher.

The impetus for this change is that I'm changing accountsservice to properly respect G_DBUS_FLAGS_ALLOW_INTERACTIVE_AUTHORIZATION, and libaccountsservice uses generated code for D-Bus method calls. So these changes will allow libaccountsservice to continue allowing interactive authorization, and avoid breaking any users of it which expect that. See https://gitlab.freedesktop.org/accountsservice/accountsservice/merge_requests/46

It might make sense to also let GDBusCallFlags be specified for property set operations, but that is not needed in the case of accountsservice, and would require significant work and breaking API in multiple places.

Edited by Phaedrus Leeds

Merge request reports