Permalink
Browse files

- XDM-AUTHORIZATION-1

- defensive programming
  • Loading branch information...
1 parent 59a1fae commit 56b97a8aecc1ff5c7633522173218a224f9362ea adam committed Feb 23, 2006
Showing with 11 additions and 2 deletions.
  1. +11 −2 bin/xauth-user
View
@@ -12,9 +12,18 @@ if [ -z "$DISPLAY" ]; then
exit 1
fi
-cookie="`xauth list $DISPLAY`"
+# Not sure what to do here. Sometimes we get two results:
+# one for MIT-MAGIC-COOKIE-1 and one for XDM-AUTHORIZATION-1.
+# In that case, XDM-AUTHORIZATION-1 seems to be the right one
+# (presumably because xdm/gdm/kdm was used to login).
+cookie="`xauth list $DISPLAY | tail -n 1`"
+
+if [ -z "$cookie" ]; then
+ echo "xauth list $DISPLAY failed to return a cookie" >&2
+ exit 1
+fi
for user in "$@"; do
echo "Adding '$cookie' for user $user"
- su -c "unset XAUTHORITY; xauth add $cookie" "$user"
+ su -c "set -x; unset XAUTHORITY; xauth add $cookie" "$user"
done

0 comments on commit 56b97a8

Please sign in to comment.