diff options
Diffstat (limited to 'crypto/openssh/regress/cfgmatch.sh')
-rw-r--r-- | crypto/openssh/regress/cfgmatch.sh | 70 |
1 files changed, 36 insertions, 34 deletions
diff --git a/crypto/openssh/regress/cfgmatch.sh b/crypto/openssh/regress/cfgmatch.sh index 05a6668551a9..2737a5f977ef 100644 --- a/crypto/openssh/regress/cfgmatch.sh +++ b/crypto/openssh/regress/cfgmatch.sh @@ -1,4 +1,4 @@ -# $OpenBSD: cfgmatch.sh,v 1.13 2021/06/08 06:52:43 djm Exp $ +# $OpenBSD: cfgmatch.sh,v 1.14 2024/09/27 01:05:54 djm Exp $ # Placed in the Public Domain. tid="sshd_config match" @@ -26,7 +26,7 @@ start_client() kill $client_pid fatal "timeout waiting for background ssh" fi - done + done } stop_client() @@ -119,40 +119,42 @@ stop_client # requires knowledge of actual group memberships user running the test). params="user:user:u1 host:host:h1 address:addr:1.2.3.4 \ localaddress:laddr:5.6.7.8 rdomain:rdomain:rdom1" -cp $OBJ/sshd_proxy_bak $OBJ/sshd_config -echo 'Banner /nomatch' >>$OBJ/sshd_config -for i in $params; do - config=`echo $i | cut -f1 -d:` - criteria=`echo $i | cut -f2 -d:` - value=`echo $i | cut -f3 -d:` - cat >>$OBJ/sshd_config <<EOD - Match $config $value - Banner /$value +for separator in " " "=" ; do + cp $OBJ/sshd_proxy_bak $OBJ/sshd_config + echo 'Banner /nomatch' >>$OBJ/sshd_config + for i in $params; do + config=`echo $i | cut -f1 -d:` + criteria=`echo $i | cut -f2 -d:` + value=`echo $i | cut -f3 -d:` + cat >>$OBJ/sshd_config <<EOD + Match ${config}${separator}${value} + Banner /$value EOD -done + done -${SUDO} ${SSHD} -f $OBJ/sshd_config -T >/dev/null || \ - fail "validate config for w/out spec" - -# Test matching each criteria. -for i in $params; do - testcriteria=`echo $i | cut -f2 -d:` - expected=/`echo $i | cut -f3 -d:` - spec="" - for j in $params; do - config=`echo $j | cut -f1 -d:` - criteria=`echo $j | cut -f2 -d:` - value=`echo $j | cut -f3 -d:` - if [ "$criteria" = "$testcriteria" ]; then - spec="$criteria=$value,$spec" - else - spec="$criteria=1$value,$spec" + ${SUDO} ${SSHD} -f $OBJ/sshd_config -T >/dev/null || \ + fail "validate config for w/out spec" + + # Test matching each criteria. + for i in $params; do + testcriteria=`echo $i | cut -f2 -d:` + expected=/`echo $i | cut -f3 -d:` + spec="" + for j in $params; do + config=`echo $j | cut -f1 -d:` + criteria=`echo $j | cut -f2 -d:` + value=`echo $j | cut -f3 -d:` + if [ "$criteria" = "$testcriteria" ]; then + spec="$criteria=$value,$spec" + else + spec="$criteria=1$value,$spec" + fi + done + trace "test spec $spec" + result=`${SUDO} ${SSHD} -f $OBJ/sshd_config -T -C "$spec" | \ + awk '$1=="banner"{print $2}'` + if [ "$result" != "$expected" ]; then + fail "match $config expected $expected got $result" fi done - trace "test spec $spec" - result=`${SUDO} ${SSHD} -f $OBJ/sshd_config -T -C "$spec" | \ - awk '$1=="banner"{print $2}'` - if [ "$result" != "$expected" ]; then - fail "match $config expected $expected got $result" - fi done |