Skip to content

Commit 6575859

Browse files
committed
upstream: Test for %-token and env var expansion in SetEnv.
OpenBSD-Regress-ID: bd6139a6177ac4afb29a0ce4afc23567b22ef9f9
1 parent fd7ad8d commit 6575859

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

regress/percent.sh

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# $OpenBSD: percent.sh,v 1.19 2025/03/02 07:41:06 dtucker Exp $
1+
# $OpenBSD: percent.sh,v 1.20 2025/03/03 06:54:37 dtucker Exp $
22
# Placed in the Public Domain.
33

44
tid="percent expansions"
@@ -68,6 +68,18 @@ trial()
6868
remuser@somehost | awk '$1=="'$opt'"{print $2" "$3}'`
6969
expect="/$expect /$expect"
7070
;;
71+
setenv)
72+
# First make sure we don't expand variable names.
73+
got=`${SSH} -F $OBJ/ssh_proxy -o $opt="$arg=TESTVAL" -G \
74+
remuser@somehost | awk '$1=="'$opt'"{print $2}'`
75+
if [ "$got" != "$arg=TESTVAL" ]; then
76+
fatal "incorrectly expanded setenv variable name"
77+
fi
78+
# Now check that the the value expands as expected.
79+
got=`${SSH} -F $OBJ/ssh_proxy -o $opt=TESTVAL="$arg" -G \
80+
remuser@somehost | awk '$1=="'$opt'"{print $2}'`
81+
got=`echo "$got" | sed 's/^TESTVAL=//'`
82+
;;
7183
*)
7284
got=`${SSH} -F $OBJ/ssh_proxy -o $opt="$arg" -G \
7385
remuser@somehost | awk '$1=="'$opt'"{print $2}'`
@@ -79,7 +91,7 @@ trial()
7991

8092
for i in matchexec localcommand remotecommand controlpath identityagent \
8193
forwardagent localforward remoteforward revokedhostkeys \
82-
user user-l user-at userknownhostsfile; do
94+
user user-l user-at setenv userknownhostsfile; do
8395
verbose $tid $i percent
8496
case "$i" in
8597
localcommand|userknownhostsfile)
@@ -126,7 +138,7 @@ done
126138
# Subset of above since we don't expand shell-style variables on anything that
127139
# runs a command because the shell will expand those.
128140
for i in controlpath identityagent forwardagent localforward remoteforward \
129-
user user-l user-at userknownhostsfile; do
141+
user user-l user-at setenv userknownhostsfile; do
130142
verbose $tid $i dollar
131143
FOO=bar
132144
export FOO

0 commit comments

Comments
 (0)