treat output of sshrc as environment assignment lines?

James Ralston qralston+ml.openssh-unix-dev at andrew.cmu.edu
Tue Feb 8 05:18:12 EST 2005


Currently, ~/.ssh/environment can set static environment variables,
and ~/.ssh/rc can run initialization routines.  But there is no way
for sshrc to propagate changes to the environment to the user's shell
or command.

There is, however, a possible way to do this.  If the
PermitUserEnvironment option is set, sshd could treat the stdout of
sshrc as additional assignment lines of the form name=value.  This
would permit sshrc to propagate propagate changes to the environment
to the user's shell or command.

The specific problem I am trying to solve here is to use a temporary,
securely-created Xauthority file.  If sshd were to read the output of
sshrc, then I could do it.  E.g.:

if read proto cookie && [ -n "$DISPLAY" ]; then
  if xauth=`mktemp -t xauth-XXXXXXXXXX" 1>/dev/null`; then
    XAUTHORITY=${xauth}; export "${XAUTHORITY}"
    echo "XAUTHORITY=${XAUTHORITY}"
  fi
  if [ `echo "x${DISPLAY}" | cut -c1-11` = 'xlocalhost:' ]; then
    # X11UseLocalhost=yes
    echo add "unix:`echo $DISPLAY | cut -c11-`" ${proto} ${cookie}
  else
    # X11UseLocalhost=no
    echo add "${DISPLAY}" "${proto}" "${cookie}"
  fi | xauth -q -
fi

Having sshd evaluate the output that sshrc produces (if
PermitUserEnvironment is set, that is) would enable this and other
"smart" initialization routines.

Thoughts?  (I.e., if I were to write a patch to implement this
feature, would it be accepted?)

-- 
James Ralston, Information Technology
Software Engineering Institute
Carnegie Mellon University, Pittsburgh, PA, USA




More information about the openssh-unix-dev mailing list