Package: acpid
Version: 1:2.0.22-2
Severity: normal
Tags: patch

Current procedure of causing a shutdown when the power button is pressed
is as follows:
- acpid
  - /etc/acpi/powerbtn-acpi-support.sh
    - /usr/share/acpi-support/policy-funcs
      - CheckPolicy()

But CheckPolicy only checks if systemd-logind is running. This is not
enough. If there is no systemd as PID 1 or systemd-shim running, the
org.freedesktop.systemd1.Manager interface will be unavailable for
systemd-logind. The system won't shutdown.

Attached patch enables checks for availability of the interface (but
preserves the earlier test for logind running).

If there is no such interface acpid falls back to classic shutdown.

--- System information. ---
Architecture: amd64
Kernel:       Linux 3.14-1-amd64

Debian Release: jessie/sid
  500 testing         security.debian.org 
  500 testing         ftp.pl.debian.org 
  500 stable          security.debian.org 
  500 stable          ftp.pl.debian.org 

--- Package information. ---
Depends        (Version) | Installed
========================-+-============
libc6          (>= 2.15) | 
lsb-base     (>= 3.2-14) | 
kmod                     | 


Recommends               (Version) | Installed
==================================-+-=============
acpi-support-base     (>= 0.114-1) | 0.141-3


Package's Suggests field is empty.




-- 
Marcin Szewczyk                       http://wodny.org
mailto:marcin.szewc...@wodny.borg  <- remove b / usuĊ„ b
xmpp:wo...@ubuntu.pl                  xmpp:wo...@jabster.pl
--- /usr/share/acpi-support/policy-funcs	2014-06-26 14:25:01.616856080 +0200
+++ /usr/share/acpi-support/policy-funcs	2014-06-26 14:32:05.005003163 +0200
@@ -14,13 +14,14 @@
 	local PMS
 
 	getXconsole
-	PMS="/usr/bin/gnome-power-manager /usr/bin/kpowersave /usr/bin/xfce4-power-manager /lib/systemd/systemd-logind /usr/bin/mate-power-manager"
+	PMS="/usr/bin/gnome-power-manager /usr/bin/kpowersave /usr/bin/xfce4-power-manager /usr/bin/mate-power-manager"
 	PMS="$PMS /usr/bin/guidance-power-manager /usr/lib/dalston/dalston-power-applet"
 	pidof -x $PMS > /dev/null ||
         { test "$XUSER" != "" && 
           pidof dcopserver > /dev/null &&
           test -x /usr/bin/dcop &&
           /usr/bin/dcop --user $XUSER kded kded loadedModules | grep -q klaptopdaemon; } ||
+        HasLogindAndSystemd1Manager ||
         PowerDevilRunning ||
 	GnomeSettingsDaemonPowerRunning
 }
@@ -48,6 +49,18 @@
 	done
 }
 
+# Check if systemd-logind will be able to call org.freedesktop.systemd1.Manager
+# interface provided by systemd running as PID 1 or by systemd-shim
+HasLogindAndSystemd1Manager() {
+  pidof -x "/lib/systemd/systemd-logind" > /dev/null &&
+  # shutdown.target used as a representative of power management calls class
+  dbus-send --print-reply --system --type=method_call \
+    --dest=org.freedesktop.systemd1 \
+    /org/freedesktop/systemd1 \
+    org.freedesktop.systemd1.Manager.GetUnitFileState string:shutdown.target \
+    > /dev/null 2>&1
+}
+
 # Ask kde if the powerdevil module is loaded
 PowerDevilRunning() {
 	DBusSend kded4 org.kde.kded /kded org.kde.kded.loadedModules | grep -q powerdevil

Reply via email to