[OpenAFS] significant delay for afs user to login as root via su

Carson Gaspar carson@taltos.org
Thu, 18 Mar 2010 12:03:21 -0700


David S. Goldberg wrote:
>> - Assuming you're using ssh (I am guessing that you are), convince sshd
>>   to write your Xauthority information somewhere else, like a file
>>   in /tmp (and make sure your XAUTHORITY environment variable is correct).
>>   I would guess this is possible, but I don't know if there's an easy
>>   way to do it.
> 
> I do this with the following code in ~/.ssh/rc:
> 
> if [ "$DISPLAY" = "" ]; then exit 0 ; fi
> if [ ! -d /tmp/.${USER} ]; then # I actually don't reference $USER -
>                               # just put your own ID there.
>     /bin/sh -c "umask 77 ; mkdir /tmp/.${USER}" ; 
>     XAUTHORITY=/tmp/.${USER}/.Xauthority;

Please don't use that code if you want something robust. Use something 
like the below (tossed off in a few seconds, so take with a grain of salt):

unset XAUTHORITY
if test ! -d "/tmp/.${USER}"; then
	(umask 77; echo mkdir "/tmp/.${USER}") && \
	XAUTHORITY="/tmp/.${USER}/.Xauthority"
else
	touch "/tmp/.${USER}/.Xauthority" && \
	XAUTHORITY="/tmp/.${USER}/.Xauthority"
fi
if test -z "${XAUTHORITY}"; then
	# Something is wrong
	test -t 2 && echo "Could not set XAUTHORITY" 1>&2
fi

-- 
Carson