Package: hibernate
Version: 1.12-1
Severity: normal
Tags: patch

The xpid code in the hibernate script looks for one of a long list of
window managers to figure out what user is running X. This failed for
me, since my window manager, ion3, is not included in the list (neither
are ion2 or ion, or probably several others). I think that the last
program in the list, X, matched, but of course the X process itself is
running as root so it gets the wrong user and things don't work.

I think there are probably better ways to do this when xdm is used. For
example, here I have:

[EMAIL PROTECTED]:~>last :0 | grep 'still logged in'       
joey     :0                            Mon Jan 30 22:21   still logged in   

I've attached a patch to use that.

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.6.15-1-686
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)

hibernate depends on no packages.

Versions of packages hibernate recommends:
ii  console-tools              1:0.2.3dbs-60 Linux console and font utilities
ii  hdparm                     6.3-3         tune hard disk parameters for high
pn  vlock                      <none>        (no description available)

-- no debconf information

-- 
see shy jo
--- /tmp/hibernate      2006-01-31 00:13:29.000000000 -0500
+++ /usr/sbin/hibernate 2006-01-31 00:20:14.000000000 -0500
@@ -206,20 +206,36 @@
 
     # Find a useful XAUTHORITY and ideally a username too if we can!
     local xuser xauth xpid
-    for xpid in `pidof kwrapper ksmserver kdeinit gnome-session fvwm fvwm2 pwm 
blackbox fluxbox X XFree86 Xorg` ; do
-       # Ensure the process still exists, and we aren't hallucinating.
-       [ -d "/proc/$xpid/" ] || continue
-
-       xauth=`awk 'BEGIN{RS="\\000";FS="="}($1 == "XAUTHORITY"){print $2}' < 
/proc/$xpid/environ`
-       xhome=`awk 'BEGIN{RS="\\000";FS="="}($1 == "HOME"){print $2}' < 
/proc/$xpid/environ`
-       xuser=`/bin/ls -ld /proc/$xpid/ | awk '{print $3}'`
-       [ -z $xauth ] && [ -n $xhome ] && [ -f $xhome/.Xauthority ] && 
xauth=$xhome/.Xauthority
-
-       XAUTHORITY=$xauth su $xuser -c "$xhost" > /dev/null 2>&1 && break
-
-       xauth=
-       xuser=
+    for display in $(seq 0 8); do
+       xuser=$(last ":$display" | grep 'still logged in') || true
+       if [ -n "$xuser" ]; then
+           xhome=$(getent passwd "$xuser" | cut -d: -f 6)
+           if [ -n "$xhome" ]; then
+               xauth=$xhome/.Xauthority
+           fi
+       fi
+       if [ -z "$xhome" ] || [ -z "$xauth" ]; then
+          xauth=
+          xuser=
+          xhome=
+       fi
     done
+    if [ -z $xuser ] ; then
+        for xpid in `pidof kwrapper ksmserver kdeinit gnome-session fvwm fvwm2 
pwm blackbox fluxbox X XFree86 Xorg` ; do
+           # Ensure the process still exists, and we aren't hallucinating.
+           [ -d "/proc/$xpid/" ] || continue
+
+           xauth=`awk 'BEGIN{RS="\\000";FS="="}($1 == "XAUTHORITY"){print $2}' 
< /proc/$xpid/environ`
+           xhome=`awk 'BEGIN{RS="\\000";FS="="}($1 == "HOME"){print $2}' < 
/proc/$xpid/environ`
+           xuser=`/bin/ls -ld /proc/$xpid/ | awk '{print $3}'`
+           [ -z $xauth ] && [ -n $xhome ] && [ -f $xhome/.Xauthority ] && 
xauth=$xhome/.Xauthority
+
+           XAUTHORITY=$xauth su $xuser -c "$xhost" > /dev/null 2>&1 && break
+
+          xauth=
+          xuser=
+       done
+    fi
     if [ -n $xuser ] ; then
        XUSER=$xuser
        if [ -n "$xauth" ] ; then

Attachment: signature.asc
Description: Digital signature

Reply via email to