From a0a218b2d904a23bf4cd0f2758cf59b847c24c4f Mon Sep 17 00:00:00 2001 From: Iain Patterson Date: Mon, 20 Jan 2014 16:07:24 +0000 Subject: [PATCH] Handle non-default XAUTHORITY. 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. --- .profile.d/xauth.bashrc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .profile.d/xauth.bashrc diff --git a/.profile.d/xauth.bashrc b/.profile.d/xauth.bashrc new file mode 100644 index 0000000..0cf088c --- /dev/null +++ b/.profile.d/xauth.bashrc @@ -0,0 +1,17 @@ +# 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 -- 2.20.1