Subject: bug#22565: Cannot talk to upowerd over D-Bus

From: [email-masked] (Ludovic Courtès)
Date: Sun, 07 Feb 2016 15:49:56 +0100

tags 22565 notabug
close 22565
thanks

[email-masked] (Ludovic Courtès) skribis:

> On GuixSD as of v0.9.0-1430-g234ea8a, attempts to talk to upowerd over
> D-Bus fail:
>
> $ sudo dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.Suspend
> Error org.freedesktop.DBus.Error.UnknownMethod: Method "Suspend" with signature "" on interface "org.freedesktop.UPower" doesn't exist
>
> See
> <https://lists.gnu.org/archive/html/guix-devel/2016-01/msg01004.html>.

Actually the above method simply does not exist (the blog post
at <http://andrusiv.com/blog/2011/12/12/shutdown-dbus.html> is several
years old.)

If we invoke methods that do exist, everything is fine:

--8<---------------cut here---------------start------------->8---
$ dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.GetCriticalAction
method return time=1454855982.307374 sender=:1.1 -> destination=:1.51 serial=449 reply_serial=2
   string "PowerOff"
$ dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.GetDisplayDevice
method return time=1454855987.010638 sender=:1.1 -> destination=:1.52 serial=450 reply_serial=2
   object path "/org/freedesktop/UPower/devices/DisplayDevice"
$ dbus-send --print-reply --system --dest=org.freedesktop.UPower /org/freedesktop/UPower org.freedesktop.UPower.EnumerateDevices
method return time=1454856012.554536 sender=:1.1 -> destination=:1.53 serial=451 reply_serial=2
   array [
      object path "/org/freedesktop/UPower/devices/line_power_AC"
      object path "/org/freedesktop/UPower/devices/battery_BAT0"
   ]
--8<---------------cut here---------------end--------------->8---

The thing is, poweroff/suspend/hibernate is now delegated to logind (see
src/linux/up-backend.c in UPower.)

Indeed, the ‘loginctl’ command (or, presumably, other elogind clients
such as GNOME or Xfce) can talk to elogind:

--8<---------------cut here---------------start------------->8---
$ loginctl suspend 
Failed to suspend: Interactive authentication required.
--8<---------------cut here---------------end--------------->8---

I suppose we need some polkit magic to allow unprivileged users to
invoke those actions, but that’s a different issue.

Thanks,
Ludo’.