mirror of
https://github.com/PowerShell/openssh-portable.git
synced 2025-07-30 09:14:59 +02:00
- djm@cvs.openbsd.org 2011/05/23 03:31:31
[regress/cfgmatch.sh] include testing of multiple/overridden AuthorizedKeysFiles refactor to simply daemon start/stop and get rid of racy constructs
This commit is contained in:
parent
295ee63ab2
commit
8cb3587336
@ -30,6 +30,10 @@
|
|||||||
GlobalKnownHostsFile2 by making UserKnownHostsFile/GlobalKnownHostsFile
|
GlobalKnownHostsFile2 by making UserKnownHostsFile/GlobalKnownHostsFile
|
||||||
accept multiple paths per line and making their defaults include
|
accept multiple paths per line and making their defaults include
|
||||||
known_hosts2; ok markus
|
known_hosts2; ok markus
|
||||||
|
- djm@cvs.openbsd.org 2011/05/23 03:31:31
|
||||||
|
[regress/cfgmatch.sh]
|
||||||
|
include testing of multiple/overridden AuthorizedKeysFiles
|
||||||
|
refactor to simply daemon start/stop and get rid of racy constructs
|
||||||
|
|
||||||
20110520
|
20110520
|
||||||
- (djm) [session.c] call setexeccon() before executing passwd for pw
|
- (djm) [session.c] call setexeccon() before executing passwd for pw
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
# $OpenBSD: cfgmatch.sh,v 1.4 2006/12/13 08:36:36 dtucker Exp $
|
# $OpenBSD: cfgmatch.sh,v 1.5 2011/05/23 03:31:31 djm Exp $
|
||||||
# Placed in the Public Domain.
|
# Placed in the Public Domain.
|
||||||
|
|
||||||
tid="sshd_config match"
|
tid="sshd_config match"
|
||||||
@ -7,6 +7,28 @@ pidfile=$OBJ/remote_pid
|
|||||||
fwdport=3301
|
fwdport=3301
|
||||||
fwd="-L $fwdport:127.0.0.1:$PORT"
|
fwd="-L $fwdport:127.0.0.1:$PORT"
|
||||||
|
|
||||||
|
echo "ExitOnForwardFailure=yes" >> ssh_config
|
||||||
|
echo "ExitOnForwardFailure=yes" >> ssh_proxy
|
||||||
|
|
||||||
|
start_client()
|
||||||
|
{
|
||||||
|
rm -f $pidfile
|
||||||
|
${SSH} -q -$p $fwd "$@" somehost \
|
||||||
|
exec sh -c \'"echo \$\$ > $pidfile; exec sleep 100"\' \
|
||||||
|
>>$TEST_SSH_LOGFILE 2>&1 &
|
||||||
|
client_pid=$!
|
||||||
|
# Wait for remote end
|
||||||
|
n=0
|
||||||
|
while test ! -f $pidfile ; do
|
||||||
|
sleep 1
|
||||||
|
n=`expr $n + 1`
|
||||||
|
if test $n -gt 60; then
|
||||||
|
kill $client_pid
|
||||||
|
fatal "timeout waiting for background ssh"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
stop_client()
|
stop_client()
|
||||||
{
|
{
|
||||||
pid=`cat $pidfile`
|
pid=`cat $pidfile`
|
||||||
@ -14,11 +36,15 @@ stop_client()
|
|||||||
kill $pid
|
kill $pid
|
||||||
sleep 1
|
sleep 1
|
||||||
fi
|
fi
|
||||||
|
wait
|
||||||
}
|
}
|
||||||
|
|
||||||
cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak
|
cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak
|
||||||
|
grep -v AuthorizedKeysFile $OBJ/sshd_proxy_bak > $OBJ/sshd_proxy
|
||||||
|
echo "AuthorizedKeysFile /dev/null" >>$OBJ/sshd_proxy
|
||||||
echo "PermitOpen 127.0.0.1:1" >>$OBJ/sshd_config
|
echo "PermitOpen 127.0.0.1:1" >>$OBJ/sshd_config
|
||||||
|
echo "Match user $USER" >>$OBJ/sshd_proxy
|
||||||
|
echo "AuthorizedKeysFile /dev/null $OBJ/authorized_keys_%u" >>$OBJ/sshd_proxy
|
||||||
echo "Match Address 127.0.0.1" >>$OBJ/sshd_config
|
echo "Match Address 127.0.0.1" >>$OBJ/sshd_config
|
||||||
echo "PermitOpen 127.0.0.1:$PORT" >>$OBJ/sshd_config
|
echo "PermitOpen 127.0.0.1:$PORT" >>$OBJ/sshd_config
|
||||||
|
|
||||||
@ -32,12 +58,8 @@ start_sshd
|
|||||||
|
|
||||||
# Test Match + PermitOpen in sshd_config. This should be permitted
|
# Test Match + PermitOpen in sshd_config. This should be permitted
|
||||||
for p in 1 2; do
|
for p in 1 2; do
|
||||||
rm -f $pidfile
|
|
||||||
trace "match permitopen localhost proto $p"
|
trace "match permitopen localhost proto $p"
|
||||||
${SSH} -$p $fwd -F $OBJ/ssh_config -f somehost \
|
start_client -F $OBJ/ssh_config
|
||||||
exec sh -c \'"echo \$\$ > $pidfile; exec sleep 100"\' >>$TEST_SSH_LOGFILE 2>&1 ||\
|
|
||||||
fail "match permitopen proto $p sshd failed"
|
|
||||||
sleep 1;
|
|
||||||
${SSH} -q -$p -p $fwdport -F $OBJ/ssh_config somehost true || \
|
${SSH} -q -$p -p $fwdport -F $OBJ/ssh_config somehost true || \
|
||||||
fail "match permitopen permit proto $p"
|
fail "match permitopen permit proto $p"
|
||||||
stop_client
|
stop_client
|
||||||
@ -45,12 +67,8 @@ done
|
|||||||
|
|
||||||
# Same but from different source. This should not be permitted
|
# Same but from different source. This should not be permitted
|
||||||
for p in 1 2; do
|
for p in 1 2; do
|
||||||
rm -f $pidfile
|
|
||||||
trace "match permitopen proxy proto $p"
|
trace "match permitopen proxy proto $p"
|
||||||
${SSH} -q -$p $fwd -F $OBJ/ssh_proxy -f somehost \
|
start_client -F $OBJ/ssh_proxy
|
||||||
exec sh -c \'"echo \$\$ > $pidfile; exec sleep 100"\' >>$TEST_SSH_LOGFILE 2>&1 ||\
|
|
||||||
fail "match permitopen proxy proto $p sshd failed"
|
|
||||||
sleep 1;
|
|
||||||
${SSH} -q -$p -p $fwdport -F $OBJ/ssh_config somehost true && \
|
${SSH} -q -$p -p $fwdport -F $OBJ/ssh_config somehost true && \
|
||||||
fail "match permitopen deny proto $p"
|
fail "match permitopen deny proto $p"
|
||||||
stop_client
|
stop_client
|
||||||
@ -62,12 +80,8 @@ cat $OBJ/rsa.pub >> $OBJ/authorized_keys_$USER
|
|||||||
echon 'permitopen="127.0.0.1:'$PORT'" ' >>$OBJ/authorized_keys_$USER
|
echon 'permitopen="127.0.0.1:'$PORT'" ' >>$OBJ/authorized_keys_$USER
|
||||||
cat $OBJ/rsa1.pub >> $OBJ/authorized_keys_$USER
|
cat $OBJ/rsa1.pub >> $OBJ/authorized_keys_$USER
|
||||||
for p in 1 2; do
|
for p in 1 2; do
|
||||||
rm -f $pidfile
|
|
||||||
trace "match permitopen proxy w/key opts proto $p"
|
trace "match permitopen proxy w/key opts proto $p"
|
||||||
${SSH} -q -$p $fwd -F $OBJ/ssh_proxy -f somehost \
|
start_client -F $OBJ/ssh_proxy
|
||||||
exec sh -c \'"echo \$\$ > $pidfile; exec sleep 100"\' >>$TEST_SSH_LOGFILE 2>&1 ||\
|
|
||||||
fail "match permitopen w/key opt proto $p sshd failed"
|
|
||||||
sleep 1;
|
|
||||||
${SSH} -q -$p -p $fwdport -F $OBJ/ssh_config somehost true && \
|
${SSH} -q -$p -p $fwdport -F $OBJ/ssh_config somehost true && \
|
||||||
fail "match permitopen deny w/key opt proto $p"
|
fail "match permitopen deny w/key opt proto $p"
|
||||||
stop_client
|
stop_client
|
||||||
@ -76,12 +90,8 @@ done
|
|||||||
# Test both sshd_config and key options permitting the same dst/port pair.
|
# Test both sshd_config and key options permitting the same dst/port pair.
|
||||||
# Should be permitted.
|
# Should be permitted.
|
||||||
for p in 1 2; do
|
for p in 1 2; do
|
||||||
rm -f $pidfile
|
|
||||||
trace "match permitopen localhost proto $p"
|
trace "match permitopen localhost proto $p"
|
||||||
${SSH} -$p $fwd -F $OBJ/ssh_config -f somehost \
|
start_client -F $OBJ/ssh_config
|
||||||
exec sh -c \'"echo \$\$ > $pidfile; exec sleep 100"\' >>$TEST_SSH_LOGFILE 2>&1 ||\
|
|
||||||
fail "match permitopen proto $p sshd failed"
|
|
||||||
sleep 1;
|
|
||||||
${SSH} -q -$p -p $fwdport -F $OBJ/ssh_config somehost true || \
|
${SSH} -q -$p -p $fwdport -F $OBJ/ssh_config somehost true || \
|
||||||
fail "match permitopen permit proto $p"
|
fail "match permitopen permit proto $p"
|
||||||
stop_client
|
stop_client
|
||||||
@ -94,12 +104,8 @@ echo "PermitOpen 127.0.0.1:1 127.0.0.1:2" >>$OBJ/sshd_proxy
|
|||||||
|
|
||||||
# Test that a Match overrides a PermitOpen in the global section
|
# Test that a Match overrides a PermitOpen in the global section
|
||||||
for p in 1 2; do
|
for p in 1 2; do
|
||||||
rm -f $pidfile
|
|
||||||
trace "match permitopen proxy w/key opts proto $p"
|
trace "match permitopen proxy w/key opts proto $p"
|
||||||
${SSH} -q -$p $fwd -F $OBJ/ssh_proxy -f somehost \
|
start_client -F $OBJ/ssh_proxy
|
||||||
exec sh -c \'"echo \$\$ > $pidfile; exec sleep 100"\' >>$TEST_SSH_LOGFILE 2>&1 ||\
|
|
||||||
fail "match override permitopen proto $p sshd failed"
|
|
||||||
sleep 1;
|
|
||||||
${SSH} -q -$p -p $fwdport -F $OBJ/ssh_config somehost true && \
|
${SSH} -q -$p -p $fwdport -F $OBJ/ssh_config somehost true && \
|
||||||
fail "match override permitopen proto $p"
|
fail "match override permitopen proto $p"
|
||||||
stop_client
|
stop_client
|
||||||
@ -113,12 +119,8 @@ echo "PermitOpen 127.0.0.1:1 127.0.0.1:2" >>$OBJ/sshd_proxy
|
|||||||
# Test that a rule that doesn't match doesn't override, plus test a
|
# Test that a rule that doesn't match doesn't override, plus test a
|
||||||
# PermitOpen entry that's not at the start of the list
|
# PermitOpen entry that's not at the start of the list
|
||||||
for p in 1 2; do
|
for p in 1 2; do
|
||||||
rm -f $pidfile
|
|
||||||
trace "nomatch permitopen proxy w/key opts proto $p"
|
trace "nomatch permitopen proxy w/key opts proto $p"
|
||||||
${SSH} -q -$p $fwd -F $OBJ/ssh_proxy -f somehost \
|
start_client -F $OBJ/ssh_proxy
|
||||||
exec sh -c \'"echo \$\$ > $pidfile; exec sleep 100"\' >>$TEST_SSH_LOGFILE 2>&1 ||\
|
|
||||||
fail "nomatch override permitopen proto $p sshd failed"
|
|
||||||
sleep 1;
|
|
||||||
${SSH} -q -$p -p $fwdport -F $OBJ/ssh_config somehost true || \
|
${SSH} -q -$p -p $fwdport -F $OBJ/ssh_config somehost true || \
|
||||||
fail "nomatch override permitopen proto $p"
|
fail "nomatch override permitopen proto $p"
|
||||||
stop_client
|
stop_client
|
||||||
|
Loading…
x
Reference in New Issue
Block a user