diff options
author | Darren Tucker <dtucker@cvs.openbsd.org> | 2020-07-17 03:26:59 +0000 |
---|---|---|
committer | Darren Tucker <dtucker@cvs.openbsd.org> | 2020-07-17 03:26:59 +0000 |
commit | f7a3e9b1986778afd96bdbd1ed5a075dde9ea1af (patch) | |
tree | 3941c51049d044dd9764d7095c7f625d9c3bf76f /regress | |
parent | 0c8323f57c57cde9e619204ecbc9536a216ba618 (diff) |
Add tests for expansions on UserKnownHostsFile.
Diffstat (limited to 'regress')
-rw-r--r-- | regress/usr.bin/ssh/percent.sh | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/regress/usr.bin/ssh/percent.sh b/regress/usr.bin/ssh/percent.sh index ec9c5d09bc7..b64d2b5160f 100644 --- a/regress/usr.bin/ssh/percent.sh +++ b/regress/usr.bin/ssh/percent.sh @@ -1,4 +1,4 @@ -# $OpenBSD: percent.sh,v 1.7 2020/05/29 04:32:26 dtucker Exp $ +# $OpenBSD: percent.sh,v 1.8 2020/07/17 03:26:58 dtucker Exp $ # Placed in the Public Domain. tid="percent expansions" @@ -20,12 +20,21 @@ trial() trace "test $opt=$arg $expect" rm -f $OBJ/actual + got="" case "$opt" in localcommand) ${SSH} -F $OBJ/ssh_proxy -o $opt="echo '$arg' >$OBJ/actual" \ somehost true got=`cat $OBJ/actual` ;; + userknownhostsfile) + # Move the userknownhosts file to what the expansion says, + # make sure ssh works then put it back. + mv "$OBJ/known_hosts" "$OBJ/$expect" + ${SSH} -F $OBJ/ssh_proxy -o $opt="$OBJ/$arg" somehost true && \ + got="$expect" + mv "$OBJ/$expect" "$OBJ/known_hosts" + ;; matchexec) (cat $OBJ/ssh_proxy && \ echo "Match Exec \"echo '$arg' >$OBJ/actual\"") \ @@ -50,13 +59,18 @@ trial() } for i in matchexec localcommand remotecommand controlpath identityagent \ - forwardagent localforward remoteforward; do + forwardagent localforward remoteforward userknownhostsfile; do verbose $tid $i percent - if [ "$i" = "localcommand" ]; then - REMUSER=$USER + case "$i" in + localcommand|userknownhostsfile) + # Any test that's going to actually make a connection needs + # to use the real username. + REMUSER=$USER ;; + *) + REMUSER=remuser ;; + esac + if [ "$i" = "$localcommand" ]; then trial $i '%T' NONE - else - REMUSER=remuser fi # Matches implementation in readconf.c:ssh_connection_hash() HASH=`printf "${HOSTNAME}127.0.0.1${PORT}$REMUSER" | @@ -65,20 +79,25 @@ for i in matchexec localcommand remotecommand controlpath identityagent \ trial $i '%C' $HASH trial $i '%i' $USERID trial $i '%h' 127.0.0.1 - trial $i '%d' $HOME trial $i '%L' $HOST trial $i '%l' $HOSTNAME trial $i '%n' somehost trial $i '%p' $PORT trial $i '%r' $REMUSER trial $i '%u' $USER - trial $i '%%/%C/%i/%h/%d/%L/%l/%n/%p/%r/%u' \ - "%/$HASH/$USERID/127.0.0.1/$HOME/$HOST/$HOSTNAME/somehost/$PORT/$REMUSER/$USER" + # We can't specify a full path outside the regress dir, so skip tests + # containing %d for UserKnownHostsFile + if [ "$i" != "userknownhostsfile" ]; then + trial $i '%d' $HOME + trial $i '%%/%C/%i/%h/%d/%L/%l/%n/%p/%r/%u' \ + "%/$HASH/$USERID/127.0.0.1/$HOME/$HOST/$HOSTNAME/somehost/$PORT/$REMUSER/$USER" + fi done # Subset of above since we don't expand shell-style variables on anything that # runs a command because the shell will expand those. -for i in controlpath identityagent forwardagent localforward remoteforward; do +for i in controlpath identityagent forwardagent localforward remoteforward \ + userknownhostsfile; do verbose $tid $i dollar FOO=bar export FOO |