]> git.ipfire.org Git - thirdparty/openssh-portable.git/commitdiff
upstream: Test for %-token and env var expansion in SetEnv.
authordtucker@openbsd.org <dtucker@openbsd.org>
Mon, 3 Mar 2025 06:54:37 +0000 (06:54 +0000)
committerDarren Tucker <dtucker@dtucker.net>
Mon, 3 Mar 2025 07:17:41 +0000 (18:17 +1100)
OpenBSD-Regress-ID: bd6139a6177ac4afb29a0ce4afc23567b22ef9f9

regress/percent.sh

index 6ec117fd9b9315d1b18127590599f10a28c6f2db..91d0e3157c83dd191cd9ce76264b77e8f326919f 100644 (file)
@@ -1,4 +1,4 @@
-#      $OpenBSD: percent.sh,v 1.19 2025/03/02 07:41:06 dtucker Exp $
+#      $OpenBSD: percent.sh,v 1.20 2025/03/03 06:54:37 dtucker Exp $
 #      Placed in the Public Domain.
 
 tid="percent expansions"
@@ -68,6 +68,18 @@ trial()
                    remuser@somehost | awk '$1=="'$opt'"{print $2" "$3}'`
                expect="/$expect /$expect"
                ;;
+       setenv)
+               # First make sure we don't expand variable names.
+               got=`${SSH} -F $OBJ/ssh_proxy -o $opt="$arg=TESTVAL" -G \
+                   remuser@somehost | awk '$1=="'$opt'"{print $2}'`
+               if [ "$got" != "$arg=TESTVAL" ]; then
+                       fatal "incorrectly expanded setenv variable name"
+               fi
+               # Now check that the the value expands as expected.
+               got=`${SSH} -F $OBJ/ssh_proxy -o $opt=TESTVAL="$arg" -G \
+                   remuser@somehost | awk '$1=="'$opt'"{print $2}'`
+               got=`echo "$got" | sed 's/^TESTVAL=//'`
+               ;;
        *)
                got=`${SSH} -F $OBJ/ssh_proxy -o $opt="$arg" -G \
                    remuser@somehost | awk '$1=="'$opt'"{print $2}'`
@@ -79,7 +91,7 @@ trial()
 
 for i in matchexec localcommand remotecommand controlpath identityagent \
     forwardagent localforward remoteforward revokedhostkeys \
-    user user-l user-at userknownhostsfile; do
+    user user-l user-at setenv userknownhostsfile; do
        verbose $tid $i percent
        case "$i" in
        localcommand|userknownhostsfile)
@@ -126,7 +138,7 @@ 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 \
-    user user-l user-at userknownhostsfile; do
+    user user-l user-at setenv userknownhostsfile; do
        verbose $tid $i dollar
        FOO=bar
        export FOO