Bug 3521 - skip tests for '%C' since no openssl in local path
Summary: skip tests for '%C' since no openssl in local path
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: Regression tests (show other bugs)
Version: 9.1p1
Hardware: Other Linux
: P5 enhancement
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-14 14:53 AEDT by renmingshuai
Modified: 2023-03-17 13:42 AEDT (History)
1 user (show)

See Also:


Attachments
Skip these tests if there is no openssl in local path. (2.11 KB, text/plain)
2023-01-14 14:53 AEDT, renmingshuai
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description renmingshuai 2023-01-14 14:53:46 AEDT
Created attachment 3650 [details]
Skip these tests if there is no openssl in local path.

Tests for '%C' in percent.sh depend on openssl in local path, so skip these tests when there is no openssl in local path.

make tests
...
run test percent.sh ...
percent expansions matchexec percent
/home/communities/openssh-portable/regress/percent.sh: line 83: openssl: command not found
matchexec=%C expect  got 9a4228f7ab4f48c26c7ce594366bbe6e69cbe511
matchexec=%%/%C/%i/%h/%d/%L/%l/%n/%p/%r/%u expect %//0/127.0.0.1//root/localhost/localhost.localdomain/somehost/4242/remuser/root got %/9a4228f7ab4f48c26c7ce594366bbe6e69cbe511/0/127.0.0.1//root/localhost/localhost.localdomain/somehost/4242/remuser/root
percent expansions localcommand percent
/home/communities/openssh-portable/regress/percent.sh: line 83: openssl: command not found
...
Comment 1 Darren Tucker 2023-01-14 21:40:01 AEDT
Comment on attachment 3650 [details]
Skip these tests if there is no openssl in local path.

I think this should have been fixed by https://github.com/openssh/openssh-portable/commit/d77fc611a62f2dfee0b654c31a50a814b13310dd

That said, looking at this again did turn up another potential improvement.

>+NOOPENSSL=0
>+IFS=":";for i in $PATH;do [ -x "$i/openssl" ] && NOOPENSSL=1;done

configure now does this for us: if OPENSSL_BIN is an empty string we don't have one.

>+	if [ $NOOPENSSL -eq 1 ]; then
>+		# Matches implementation in readconf.c:ssh_connection_hash()
>+		HASH=`printf "${HOSTNAME}127.0.0.1${PORT}$REMUSER" |
>+		    $OPENSSL_BIN sha1 | cut -f2 -d' '`
>+	fi
> 	trial $i '%%' '%'
>-	trial $i '%C' $HASH
>+	if [ $NOOPENSSL -eq 1 ]; then trial $i '%C' $HASH; fi

The order of the trials is not important, so we can move this up inside the conditional above.

>+		if [ $NOOPENSSL -eq 0 ]; then
>+			trial $i '%%/%i/%h/%d/%L/%l/%n/%p/%r/%u' \
>+				"%/$USERID/127.0.0.1/$HOME/$HOST/$HOSTNAME/somehost/$PORT/$REMUSER/$USER"
>+		else
>+			trial $i '%%/%C/%i/%h/%d/%L/%l/%n/%p/%r/%u' \
>+		    	    "%/$HASH/$USERID/127.0.0.1/$HOME/$HOST/$HOSTNAME/somehost/$PORT/$REMUSER/$USER"
>+		fi

In HEAD we currently skip the entire test if we don't have openssl, but  the order of the %-tokens is not important either, so we can set up the test without $HASH and append $HASH if we have it, instead of duplicating the bulk of the string.  I've changed that.

Thanks for the report, I believe this is all now fixed (if not please reopen this bug).
Comment 2 Damien Miller 2023-03-17 13:42:45 AEDT
OpenSSH 9.3 has been released. Close resolved bugs