GNOME Bugzilla – Bug 677718
GDBusProxy: treat org.freedesktop.systemd1.Masked error as non-fatal
Last modified: 2012-06-08 17:45:19 UTC
The way GDBusProxy work is pretty nice, you can get a GDBusProxy even if the service doesn't exist and just wait until :g-name-owner is set to non-NULL if the service is started. This is helpful because it relieves the application programmer from watching names and creating/destroying proxies himself. See [1] for an example. However, if you mask a service using systemd then this fails e.g. GDBusProxy construction fails, see [2] Therefore, I think we should probably treat StartServiceByName() erroring out with the error org.freedesktop.systemd1.Masked the same way we handle the error org.freedesktop.DBus.Error.ServiceUnknown e.g. we should continue proxy construction including watching the name, see http://git.gnome.org/browse/glib/tree/gio/gdbusproxy.c?id=2.33.2#n1592 That way we'll work a lot better with masked D-Bus services... -- gdbus-example-watch-proxy is this program: http://developer.gnome.org/gio/unstable/GDBusProxy.html#gdbus-wellknown-proxy [1] : $ ./gdbus-example-watch-proxy -n foo.bar -o /foo/bar -i foo.bar --- Proxy object is inert - there is no name owner for the name bus: Session Bus name: foo.bar object path: /foo/bar interface: foo.bar [2] : $ ./gdbus-example-watch-proxy -s -n org.freedesktop.PolicyKit1 -o /org/freedesktop/PolicyKit1/Authority -i org.freedesktop.PolicyKit1.Authority +++ Proxy object points to remote object owned by :1.6 bus: System Bus name: org.freedesktop.PolicyKit1 object path: /org/freedesktop/PolicyKit1/Authority interface: org.freedesktop.PolicyKit1.Authority properties: BackendFeatures -> uint32 1 BackendName -> 'js' BackendVersion -> '0.106' ^C $ sudo systemctl stop polkit.service $ sudo systemctl mask polkit.service ln -s '/dev/null' '/etc/systemd/system/polkit.service' $ ./gdbus-example-watch-proxy -s -n org.freedesktop.PolicyKit1 -o /org/freedesktop/PolicyKit1/Authority -i org.freedesktop.PolicyKit1.Authority Error creating proxy: Error calling StartServiceByName for org.freedesktop.PolicyKit1: GDBus.Error:org.freedesktop.systemd1.Masked: Unit polkit.service is masked. [davidz@thinkpad tests]$
Fixed on master http://git.gnome.org/browse/glib/commit/?id=3e706ef88b3b433f777e552c85339b901314deaa and cherry-picked to 2.32 as well http://git.gnome.org/browse/glib/commit/?h=glib-2-32&id=667284a19de10618cd37f88ad25f1cb0a7dac517
This change actually has some interesting (and useful) implications for polkit users, see http://cgit.freedesktop.org/polkit/commit/?id=acf3a06e55f9ca8a7f7bfa012c24e8794d27c85f http://cgit.freedesktop.org/udisks/commit/?id=f66346217c233f9689c3ad73312597821da94a82