Bug#729553: shutdown-at-night: Shuts down machines with the user still active

Petter Reinholdtsen pere at hungry.com
Fri Nov 22 22:21:40 UTC 2013


Here is a proposed patch for the package in Wheezy, backporting the
relevant part from unstable.  We should check with the stable release
managers if it is acceptable into wheezy.

I've commited this change to
<URL: svn+ssh://svn.debian.org/svn/debian-edu/branches/wheezy/shutdown-at-night >.
The change in unstable is tested and found to be working.

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 at 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

-- 
Happy hacking
Petter Reinholdtsen



More information about the Debian-edu-pkg-team mailing list