power-funcs: getXConsole() doesn't always work

Bug #239191 reported by DaveAbrahams
Affects Status Importance Assigned to Milestone
acpi-support (Ubuntu)

Bug Description

Binary package hint: acpi-support

The following code contains a comment explaining the problem. To reproduce, chown root:root ~/.Xauthority and restart X.

# based on /usr/share/acpi-support/power-funcs, which is inadequate
# because sometimes root takes ownership of the user's .Xauthority
# file, and then gdm puts the file elsewhere (e.g. /tmp/.gdm2398).
 displaynum=`ps ax | grep -m1 -e '[X] .* vt'$console | sed -re 's!.*/X .*:([0-9]+).*!\1!'`
    export DISPLAY=:$displaynum
    pid=`ps ax | grep -m1 -e '[X] .* vt'$console | cut -d' ' -f 1`
    export XAUTHORITY=$(grep -zx "XAUTHORITY=.*" /proc/$pid/environ | sed -r -e 's/XAUTHORITY=(.*)/\1/')

Revision history for this message
DaveAbrahams (boostpro) wrote :

Oops; the output of ps begins with a space, so the 2nd to last line needs to be either

  pid=`ps ax | grep -m1 -e '[X] .* vt'$console | cut -d' ' -f 2`

or perhaps the more-resilient

  pid=`ps ax | grep -m1 -e '[X] .* vt'$console | sed -re 's/[^0-9]*([0-9]+).*/\1/'`

which is what I'm currently using.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.