diff options
-rw-r--r-- | regress/percent.sh | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/regress/percent.sh b/regress/percent.sh new file mode 100644 index 000000000..84999fd0f --- /dev/null +++ b/regress/percent.sh | |||
@@ -0,0 +1,65 @@ | |||
1 | # $OpenBSD: percent.sh,v 1.1 2020/04/03 02:33:31 dtucker Exp $ | ||
2 | # Placed in the Public Domain. | ||
3 | |||
4 | tid="percent expansions" | ||
5 | |||
6 | USER=`id -u -n` | ||
7 | USERID=`id -u` | ||
8 | HOST=`hostname -s` | ||
9 | HOSTNAME=`hostname` | ||
10 | |||
11 | # Localcommand is evaluated after connection because %T is not available | ||
12 | # until then. Because of this we use a different method of exercising it, | ||
13 | # and we can't override the remote user otherwise authentication will fail. | ||
14 | # We also have to explicitly enable it. | ||
15 | echo "permitlocalcommand yes" >> $OBJ/ssh_proxy | ||
16 | |||
17 | trial() | ||
18 | { | ||
19 | opt="$1"; arg="$2"; expect="$3" | ||
20 | |||
21 | trace "test $opt=$arg $expect" | ||
22 | if [ "$opt" = "localcommand" ]; then | ||
23 | ${SSH} -F $OBJ/ssh_proxy -o $opt="echo '$arg' >$OBJ/actual" \ | ||
24 | somehost true | ||
25 | got=`cat $OBJ/actual` | ||
26 | else | ||
27 | got=`${SSH} -F $OBJ/ssh_proxy -o $opt="$arg" -G \ | ||
28 | remuser@somehost | awk '$1=="'$opt'"{print $2}'` | ||
29 | fi | ||
30 | if [ "$got" != "$expect" ]; then | ||
31 | fail "$opt=$arg expect $expect got $got" | ||
32 | else | ||
33 | trace "$opt=$arg expect $expect got $got" | ||
34 | fi | ||
35 | } | ||
36 | |||
37 | for i in localcommand remotecommand controlpath identityagent forwardagent; do | ||
38 | if [ "$i" = "localcommand" ]; then | ||
39 | HASH=94237ca18fe6b187dccf57e5593c0bb0a29cc302 | ||
40 | REMUSER=$USER | ||
41 | trial $i '%T' NONE | ||
42 | else | ||
43 | HASH=dbc43d45c7f8c0ecd0a65c0da484c03b6903622e | ||
44 | REMUSER=remuser | ||
45 | fi | ||
46 | trial $i '%%' '%' | ||
47 | trial $i '%C' $HASH | ||
48 | trial $i '%i' $USERID | ||
49 | trial $i '%h' 127.0.0.1 | ||
50 | trial $i '%d' $HOME | ||
51 | trial $i '%L' $HOST | ||
52 | trial $i '%l' $HOSTNAME | ||
53 | trial $i '%n' somehost | ||
54 | trial $i '%p' $PORT | ||
55 | trial $i '%r' $REMUSER | ||
56 | trial $i '%u' $USER | ||
57 | trial $i '%%/%C/%i/%h/%d/%L/%l/%n/%p/%r/%u' \ | ||
58 | "%/$HASH/$USERID/127.0.0.1/$HOME/$HOST/$HOSTNAME/somehost/$PORT/$REMUSER/$USER" | ||
59 | done | ||
60 | |||
61 | # A subset of options support tilde expansion | ||
62 | for i in controlpath identityagent forwardagent; do | ||
63 | trial $i '~' $HOME/ | ||
64 | trial $i '~/.ssh' $HOME/.ssh | ||
65 | done | ||