After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 678852 - gnome-shell does not handle boolean objects returned by dbus properly
gnome-shell does not handle boolean objects returned by dbus properly
Status: RESOLVED FIXED
Product: gnome-shell
Classification: Core
Component: general
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gnome-shell-maint
gnome-shell-maint
Depends on:
Blocks:
 
 
Reported: 2012-06-26 10:05 UTC by Hans de Goede
Modified: 2012-06-26 16:08 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Fix wrong result handling of remote calls (2.84 KB, patch)
2012-06-26 15:52 UTC, Florian Müllner
committed Details | Review

Description Hans de Goede 2012-06-26 10:05:58 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
Comment 1 Hans de Goede 2012-06-26 10:09:37 UTC
p.s.

This is with a fully up2date Fedora-17 x86_64 install.
Comment 2 Florian Müllner 2012-06-26 15:52:17 UTC
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.
Comment 3 Colin Walters 2012-06-26 16:00:26 UTC
Review of attachment 217307 [details] [review]:

Hm, so this code was broken from the start, looks like.
Comment 4 Florian Müllner 2012-06-26 16:08:46 UTC
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 ...