Newer Fedora versions set XAUTHORITY to a file in /tmp. Not helpful in
an NFS environment. Not at all helpful when running sudo and finding
the XAUTHORITY file owned by root.
--- /dev/null
+# Merge xauth cookies into home stash.
+if [ -n "$XAUTHORITY" ]; then
+ if [ -r "$XAUTHORITY" ]; then
+ # If we are root the old file may have been chowned.
+ [ -n "$SUDO_UID" -a -O "$XAUTHORITY" ] && chown "$SUDO_UID" "$XAUTHORITY"
+ [ -n "$SUDO_GID" -a -G "$XAUTHORITY" ] && chgrp "$SUDO_GID" "$XAUTHORITY"
+
+ # Merge and unset.
+ exec 3<&0 < "$XAUTHORITY"
+ unset XAUTHORITY
+ xauth merge - 2>/dev/null
+ exec <&3 3<&-
+ else
+ # We can't read the file so just unset.
+ unset XAUTHORITY
+ fi
+fi