[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#730251: pu: package shutdown-at-night/0.10+deb7u1



Package: release.debian.org
User: release.debian.org@packages.debian.org
Usertags: pu
Severity: normal

The shutdown-at-night package is currently unable to detect when some
desktop environments are used, because they fail to update utmp when
users log in.  The package is intended for environments like offices or
schools that want to save power by turning off unused machines at night
and turning them back on in the morning.  When it is unable to discover
that a machine is in use, it will turn off the machine while people are
working on it.  I've gotten reports that teachers experience their
machine turn off while they are writing at 16:00.

The following change solve the issue by detecting the X login screen for
KDE, Gnome and XFCE environments, and assuming the machine is unused if
the login screen can be seen.

The same change was already uploaded to unstable as version 0.13, with a
few other unrelated changes.  This patch is a backport of the relevant
change:

Index: debian/changelog
===================================================================
--- debian/changelog	(revision 82665)
+++ debian/changelog	(working copy)
@@ -1,3 +1,14 @@
+shutdown-at-night (0.10+deb7u2) UNRELEASED; urgency=low
+
+  * Backport fix for #729553 from unstable.
+  * Rewrite logic checking if a host is unused to look for the KDM,
+    Gnome or lightdm login screen to confirm the X sessions are unused
+    (Closes: #729553).
+  * Add depend on x11-utils for the xlsclients tool used to check unused
+    X sessions.
+
+ -- Petter Reinholdtsen <pere@debian.org>  Fri, 22 Nov 2013 23:13:08 +0100
+
 shutdown-at-night (0.10+deb7u1) wheezy; urgency=low

   * Quiet down cron job to wake up client to not complain when fping
Index: debian/control
===================================================================
--- debian/control	(revision 82665)
+++ debian/control	(working copy)
@@ -10,7 +10,7 @@
 Package: shutdown-at-night
 Architecture: all
 Depends: ${misc:Depends}, ${perl:Depends},  cron | fcron,
- wakeonlan, ng-utils, fping, ethtool
+ wakeonlan, ng-utils, fping, ethtool, x11-utils
 Recommends: nvram-wakeup
 Suggests: sitesummary (>= 0.0.41)
 Description: System to shut down clients at night, and wake them in the
morning
Index: shutdown-at-night
===================================================================
--- shutdown-at-night	(revision 82665)
+++ shutdown-at-night	(working copy)
@@ -61,9 +61,27 @@
     ethtool -s $interface wol g
 }

+# Return false if X session is confirmed unused (ie login screen is
+# shown).  If not sure, claim it is used to be safe.
+is_xsession_used() {
+    for s in \
+        /var/run/gdm3/auth-for-Debian-gdm-*/database \
+        /var/lib/lightdm/.Xauthority \
+        /var/run/xauth/* \
+        /run/xauth/*; do
+        if [ -e "$s" ] ; then
+            if XAUTHORITY="$s" DISPLAY=:0 xlsclients | egrep -q
'kdmgreet|lightdm-gtk-greeter|razor-lightdm-greeter|lightdm-kde-greeter|gdm-simple-greeter'
; then
+                return 1
+            fi
+        fi
+    done
+    return 0
+}
+
+
 is_host_unused() {
     # Logged in users, or ldm connection to a remote server
-    if [ "$(who)" ] ||  ps -efwww | egrep -q ' ssh .*LTSP_CLIEN[T]' ; then
+    if is_xsession_used || [ "$(who)" ] ||  ps -efwww | egrep -q ' ssh
.*LTSP_CLIEN[T]' ; then
	  return 1
     fi
     # Uptime is less than one hour


-- System Information:
Debian Release: 7.2
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-4-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash


Reply to: