diff options
Diffstat (limited to 'regress/percent.sh')
-rw-r--r-- | regress/percent.sh | 39 |
1 files changed, 29 insertions, 10 deletions
diff --git a/regress/percent.sh b/regress/percent.sh index cdcbe1839..f569f82c2 100644 --- a/regress/percent.sh +++ b/regress/percent.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: percent.sh,v 1.7 2020/05/29 04:32:26 dtucker Exp $ | 1 | # $OpenBSD: percent.sh,v 1.8 2020/07/17 03:26:58 dtucker Exp $ |
2 | # Placed in the Public Domain. | 2 | # Placed in the Public Domain. |
3 | 3 | ||
4 | tid="percent expansions" | 4 | tid="percent expansions" |
@@ -25,12 +25,21 @@ trial() | |||
25 | 25 | ||
26 | trace "test $opt=$arg $expect" | 26 | trace "test $opt=$arg $expect" |
27 | rm -f $OBJ/actual | 27 | rm -f $OBJ/actual |
28 | got="" | ||
28 | case "$opt" in | 29 | case "$opt" in |
29 | localcommand) | 30 | localcommand) |
30 | ${SSH} -F $OBJ/ssh_proxy -o $opt="echo '$arg' >$OBJ/actual" \ | 31 | ${SSH} -F $OBJ/ssh_proxy -o $opt="echo '$arg' >$OBJ/actual" \ |
31 | somehost true | 32 | somehost true |
32 | got=`cat $OBJ/actual` | 33 | got=`cat $OBJ/actual` |
33 | ;; | 34 | ;; |
35 | userknownhostsfile) | ||
36 | # Move the userknownhosts file to what the expansion says, | ||
37 | # make sure ssh works then put it back. | ||
38 | mv "$OBJ/known_hosts" "$OBJ/$expect" | ||
39 | ${SSH} -F $OBJ/ssh_proxy -o $opt="$OBJ/$arg" somehost true && \ | ||
40 | got="$expect" | ||
41 | mv "$OBJ/$expect" "$OBJ/known_hosts" | ||
42 | ;; | ||
34 | matchexec) | 43 | matchexec) |
35 | (cat $OBJ/ssh_proxy && \ | 44 | (cat $OBJ/ssh_proxy && \ |
36 | echo "Match Exec \"echo '$arg' >$OBJ/actual\"") \ | 45 | echo "Match Exec \"echo '$arg' >$OBJ/actual\"") \ |
@@ -55,13 +64,18 @@ trial() | |||
55 | } | 64 | } |
56 | 65 | ||
57 | for i in matchexec localcommand remotecommand controlpath identityagent \ | 66 | for i in matchexec localcommand remotecommand controlpath identityagent \ |
58 | forwardagent localforward remoteforward; do | 67 | forwardagent localforward remoteforward userknownhostsfile; do |
59 | verbose $tid $i percent | 68 | verbose $tid $i percent |
60 | if [ "$i" = "localcommand" ]; then | 69 | case "$i" in |
61 | REMUSER=$USER | 70 | localcommand|userknownhostsfile) |
71 | # Any test that's going to actually make a connection needs | ||
72 | # to use the real username. | ||
73 | REMUSER=$USER ;; | ||
74 | *) | ||
75 | REMUSER=remuser ;; | ||
76 | esac | ||
77 | if [ "$i" = "$localcommand" ]; then | ||
62 | trial $i '%T' NONE | 78 | trial $i '%T' NONE |
63 | else | ||
64 | REMUSER=remuser | ||
65 | fi | 79 | fi |
66 | # Matches implementation in readconf.c:ssh_connection_hash() | 80 | # Matches implementation in readconf.c:ssh_connection_hash() |
67 | HASH=`printf "${HOSTNAME}127.0.0.1${PORT}$REMUSER" | | 81 | HASH=`printf "${HOSTNAME}127.0.0.1${PORT}$REMUSER" | |
@@ -70,20 +84,25 @@ for i in matchexec localcommand remotecommand controlpath identityagent \ | |||
70 | trial $i '%C' $HASH | 84 | trial $i '%C' $HASH |
71 | trial $i '%i' $USERID | 85 | trial $i '%i' $USERID |
72 | trial $i '%h' 127.0.0.1 | 86 | trial $i '%h' 127.0.0.1 |
73 | trial $i '%d' $HOME | ||
74 | trial $i '%L' $HOST | 87 | trial $i '%L' $HOST |
75 | trial $i '%l' $HOSTNAME | 88 | trial $i '%l' $HOSTNAME |
76 | trial $i '%n' somehost | 89 | trial $i '%n' somehost |
77 | trial $i '%p' $PORT | 90 | trial $i '%p' $PORT |
78 | trial $i '%r' $REMUSER | 91 | trial $i '%r' $REMUSER |
79 | trial $i '%u' $USER | 92 | trial $i '%u' $USER |
80 | trial $i '%%/%C/%i/%h/%d/%L/%l/%n/%p/%r/%u' \ | 93 | # We can't specify a full path outside the regress dir, so skip tests |
81 | "%/$HASH/$USERID/127.0.0.1/$HOME/$HOST/$HOSTNAME/somehost/$PORT/$REMUSER/$USER" | 94 | # containing %d for UserKnownHostsFile |
95 | if [ "$i" != "userknownhostsfile" ]; then | ||
96 | trial $i '%d' $HOME | ||
97 | trial $i '%%/%C/%i/%h/%d/%L/%l/%n/%p/%r/%u' \ | ||
98 | "%/$HASH/$USERID/127.0.0.1/$HOME/$HOST/$HOSTNAME/somehost/$PORT/$REMUSER/$USER" | ||
99 | fi | ||
82 | done | 100 | done |
83 | 101 | ||
84 | # Subset of above since we don't expand shell-style variables on anything that | 102 | # Subset of above since we don't expand shell-style variables on anything that |
85 | # runs a command because the shell will expand those. | 103 | # runs a command because the shell will expand those. |
86 | for i in controlpath identityagent forwardagent localforward remoteforward; do | 104 | for i in controlpath identityagent forwardagent localforward remoteforward \ |
105 | userknownhostsfile; do | ||
87 | verbose $tid $i dollar | 106 | verbose $tid $i dollar |
88 | FOO=bar | 107 | FOO=bar |
89 | export FOO | 108 | export FOO |