[openssh-commits] [openssh] 04/06: upstream: Tests for User expansion of %-tokens and environment

git+noreply at mindrot.org git+noreply at mindrot.org
Mon Mar 3 18:18:05 AEDT 2025


This is an automated email from the git hooks/post-receive script.

dtucker pushed a commit to branch master
in repository openssh.

commit e6cfd783f1491b502db9322aa970822c63f1667d
Author: dtucker at openbsd.org <dtucker at openbsd.org>
AuthorDate: Sat Mar 1 06:12:47 2025 +0000

    upstream: Tests for User expansion of %-tokens and environment
    
    variables.
    
    OpenBSD-Regress-ID: 7ed21dd0e09fb1f3537b8b177f171018aa501628
---
 regress/percent.sh | 21 +++++++++++++++------
 1 file changed, 15 insertions(+), 6 deletions(-)

diff --git a/regress/percent.sh b/regress/percent.sh
index 354854f9..f3c82b2f 100644
--- a/regress/percent.sh
+++ b/regress/percent.sh
@@ -1,4 +1,4 @@
-#	$OpenBSD: percent.sh,v 1.17 2023/03/27 03:56:50 dtucker Exp $
+#	$OpenBSD: percent.sh,v 1.18 2025/03/01 06:12:47 dtucker Exp $
 #	Placed in the Public Domain.
 
 tid="percent expansions"
@@ -29,6 +29,15 @@ trial()
 		    somehost true
 		got=`cat $OBJ/actual`
 		;;
+	user)
+		if [ "$arg" = '%r' ] || [ "$arg" = '%C' ]; then
+			# User does not support %r, ie itself or %C.  Skip test.
+			got="$expect"
+		else
+			got=`${SSH} -F $OBJ/ssh_proxy -o $opt="$arg" -G \
+			    remuser at somehost | awk '$1=="'$opt'"{print $2}'`
+		fi
+		;;
 	userknownhostsfile)
 		# Move the userknownhosts file to what the expansion says,
 		# make sure ssh works then put it back.
@@ -62,7 +71,7 @@ trial()
 
 for i in matchexec localcommand remotecommand controlpath identityagent \
     forwardagent localforward remoteforward revokedhostkeys \
-    userknownhostsfile; do
+    user userknownhostsfile; do
 	verbose $tid $i percent
 	case "$i" in
 	localcommand|userknownhostsfile)
@@ -77,7 +86,7 @@ for i in matchexec localcommand remotecommand controlpath identityagent \
 	fi
 	# Matches implementation in readconf.c:ssh_connection_hash()
 	if [ ! -z "${OPENSSL_BIN}" ]; then
-		HASH=`printf "${HOSTNAME}127.0.0.1${PORT}$REMUSER" |
+		HASH=`printf "${HOSTNAME}127.0.0.1${PORT}${REMUSER}" |
 		    $OPENSSL_BIN sha1 | cut -f2 -d' '`
 		trial $i '%C' $HASH
 	fi
@@ -92,8 +101,8 @@ for i in matchexec localcommand remotecommand controlpath identityagent \
 	trial $i '%r' $REMUSER
 	trial $i '%u' $USER
 	# We can't specify a full path outside the regress dir, so skip tests
-	# containing %d for UserKnownHostsFile
-	if [ "$i" != "userknownhostsfile" ]; then
+	# containing %d for UserKnownHostsFile, and %r can't refer to itself.
+	if [ "$i" != "userknownhostsfile" ] && [ "$i" != "user" ]; then
 		trial $i '%d' $HOME
 		in='%%/%i/%h/%d/%L/%l/%n/%p/%r/%u'
 		out="%/$USERID/127.0.0.1/$HOME/$HOST/$HOSTNAME/somehost/$PORT/$REMUSER/$USER"
@@ -108,7 +117,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 \
-    userknownhostsfile; do
+    user userknownhostsfile; do
 	verbose $tid $i dollar
 	FOO=bar
 	export FOO

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list