summaryrefslogtreecommitdiff
path: root/regress/percent.sh
diff options
context:
space:
mode:
Diffstat (limited to 'regress/percent.sh')
-rw-r--r--regress/percent.sh51
1 files changed, 41 insertions, 10 deletions
diff --git a/regress/percent.sh b/regress/percent.sh
index 2e891f693..28781117e 100644
--- a/regress/percent.sh
+++ b/regress/percent.sh
@@ -1,4 +1,4 @@
1# $OpenBSD: percent.sh,v 1.6 2020/04/10 00:54:03 dtucker Exp $ 1# $OpenBSD: percent.sh,v 1.9 2020/07/17 07:10:24 dtucker Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4tid="percent expansions" 4tid="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
57for i in matchexec localcommand remotecommand controlpath identityagent \ 66for i in matchexec localcommand remotecommand controlpath identityagent \
58 forwardagent localforward remoteforward; do 67 forwardagent localforward remoteforward userknownhostsfile; do
59 verbose $tid $i 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,19 +84,36 @@ 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
90 trial $i '%k' localhost-with-alias
77 trial $i '%p' $PORT 91 trial $i '%p' $PORT
78 trial $i '%r' $REMUSER 92 trial $i '%r' $REMUSER
79 trial $i '%u' $USER 93 trial $i '%u' $USER
80 trial $i '%%/%C/%i/%h/%d/%L/%l/%n/%p/%r/%u' \ 94 # 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" 95 # containing %d for UserKnownHostsFile
96 if [ "$i" != "userknownhostsfile" ]; then
97 trial $i '%d' $HOME
98 trial $i '%%/%C/%i/%h/%d/%L/%l/%n/%p/%r/%u' \
99 "%/$HASH/$USERID/127.0.0.1/$HOME/$HOST/$HOSTNAME/somehost/$PORT/$REMUSER/$USER"
100 fi
82done 101done
83 102
103# Subset of above since we don't expand shell-style variables on anything that
104# runs a command because the shell will expand those.
105for i in controlpath identityagent forwardagent localforward remoteforward \
106 userknownhostsfile; do
107 verbose $tid $i dollar
108 FOO=bar
109 export FOO
110 trial $i '${FOO}' $FOO
111done
112
113
84# A subset of options support tilde expansion 114# A subset of options support tilde expansion
85for i in controlpath identityagent forwardagent; do 115for i in controlpath identityagent forwardagent; do
116 verbose $tid $i tilde
86 trial $i '~' $HOME/ 117 trial $i '~' $HOME/
87 trial $i '~/.ssh' $HOME/.ssh 118 trial $i '~/.ssh' $HOME/.ssh
88done 119done