GNOME Bugzilla – Bug 678852
gnome-shell does not handle boolean objects returned by dbus properly
Last modified: 2012-06-26 16:08:50 UTC
Hi, As discussed in bug 678597, gnome-shell does not handle boolean objects returned by dbus properly, or alternatively one could argue that the dbus-proxy code returns bad objects. One example of this (I've not done an extensive audit) is the usage of CanShutdown in js/ui/userMenu.js, the purpose of this code is to not show "Shutdown" in the user-menu if shutdown is not available. To reproduce the issue, run: dbus-send --session --type=method_call --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.CanShutdown Notice how it returns true, click on the usermenu and press/ release alt, The menuitem at the bottom changes from suspend to shutdown and back, this is all good. Now start dconf-editor, go to gnome.desktop.lockdown and check disable-log-out. Run: dbus-send --session --type=method_call --print-reply --dest=org.gnome.SessionManager /org/gnome/SessionManager org.gnome.SessionManager.CanShutdown Again, notice how it now returns false Click on the usermenu and press/ release alt, The menuitem at the bottom *still* changes from suspend to shutdown and back, not good! This can be fixed with the following simple patch: --- a/js/ui/userMenu.js +++ b/js/ui/userMenu.js @@ -572,7 +572,7 @@ const UserMenuButton = new Lang.Class({ this._session.CanShutdownRemote(Lang.bind(this, function(result, error) { if (!error) { - this._haveShutdown = result; + this._haveShutdown = result == 'true'; this._updateSuspendOrPowerOff(); } })); Change /usr/share/gnome-shell/js/ui/userMenu.js according to this patch, press alt+f2 and enter "r" to reload the shell, and click on the usermenu and press/ release alt again, notice how it now never shows shutdown, as long as the gnome.desktop.lockdown.disable-log-out option is set. Note this is just an example of the issue which I encountered while working on automount inhibit, this issue very likely impacts more then just CanShutdown. We either need to audit all usages of boolean values returned by dbus proxies and change them to val == 'true', or modify the dbus-proxy code to return a proper js boolean type. Regards, Hans
p.s. This is with a fully up2date Fedora-17 x86_64 install.
Created attachment 217307 [details] [review] Fix wrong result handling of remote calls When using dbus-glib, single return values were special-cased to be returned verbatim rather than as array with a single element. This is no longer true since switching to GDBus, so fix the places where the change was overlooked.
Review of attachment 217307 [details] [review]: Hm, so this code was broken from the start, looks like.
Attachment 217307 [details] pushed as ae16da4 - Fix wrong result handling of remote calls (In reply to comment #3) > Review of attachment 217307 [details] [review]: > > Hm, so this code was broken from the start, looks like. To be honest, the code in js/gdm/powerMenu.js is untested, but yeah, it probably didn't work ...