summaryrefslogtreecommitdiff
path: root/regress/usr.bin/ssh/cfgmatch.sh
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@cvs.openbsd.org>2006-07-17 12:08:03 +0000
committerDarren Tucker <dtucker@cvs.openbsd.org>2006-07-17 12:08:03 +0000
commit32526867e8eebc1ad5965c209271c3876e4c2767 (patch)
tree04dc9253db086b98f839b704c0db6b567316367e /regress/usr.bin/ssh/cfgmatch.sh
parentc9f2cd05915314961b7e5d9c274ec0e8608eac36 (diff)
Regress test for Match + PermitOpen. ok djm@
Diffstat (limited to 'regress/usr.bin/ssh/cfgmatch.sh')
-rw-r--r--regress/usr.bin/ssh/cfgmatch.sh85
1 files changed, 85 insertions, 0 deletions
diff --git a/regress/usr.bin/ssh/cfgmatch.sh b/regress/usr.bin/ssh/cfgmatch.sh
new file mode 100644
index 00000000000..899240837d5
--- /dev/null
+++ b/regress/usr.bin/ssh/cfgmatch.sh
@@ -0,0 +1,85 @@
+# $OpenBSD: cfgmatch.sh,v 1.1 2006/07/17 12:08:02 dtucker Exp $
+# Placed in the Public Domain.
+
+tid="sshd_config match"
+
+pidfile=$OBJ/remote_pid
+fwdport=3301
+fwd="-L $fwdport:127.0.0.1:$PORT"
+
+stop_client()
+{
+ pid=`cat $pidfile`
+ if [ ! -z "$pid" ]; then
+ kill $pid
+ fi
+}
+
+echo "PermitOpen 127.0.0.1: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:1" >>$OBJ/sshd_proxy
+echo "Match Address 127.0.0.1" >>$OBJ/sshd_proxy
+echo "PermitOpen 127.0.0.1:$PORT" >>$OBJ/sshd_proxy
+
+start_sshd
+
+#set -x
+
+# Test Match + PermitOpen in sshd_config. This should be permitted
+for p in 1 2; do
+ rm -f $pidfile
+ trace "match permitopen localhost proto $p"
+ ${SSH} -$p $fwd -F $OBJ/ssh_config -f somehost \
+ "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 || \
+ fail "match permitopen permit proto $p"
+ stop_client
+done
+
+# Same but from different source. This should not be permitted
+for p in 1 2; do
+ rm -f $pidfile
+ trace "match permitopen proxy proto $p"
+ ${SSH} -q -$p $fwd -F $OBJ/ssh_proxy -f somehost \
+ "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 && \
+ fail "match permitopen deny proto $p"
+ stop_client
+done
+
+# Retry previous with key option, should also be denied.
+echo -n 'permitopen="127.0.0.1:'$PORT'" ' >$OBJ/authorized_keys_$USER
+cat $OBJ/rsa.pub >> $OBJ/authorized_keys_$USER
+echo -n 'permitopen="127.0.0.1:'$PORT'" ' >>$OBJ/authorized_keys_$USER
+cat $OBJ/rsa1.pub >> $OBJ/authorized_keys_$USER
+for p in 1 2; do
+ rm -f $pidfile
+ trace "match permitopen proxy w/key opts proto $p"
+ ${SSH} -q -$p $fwd -F $OBJ/ssh_proxy -f somehost \
+ "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 && \
+ fail "match permitopen deny w/key opt proto $p"
+ stop_client
+done
+
+# Test both sshd_config and key options permitting the same dst/port pair.
+# Should be permitted.
+for p in 1 2; do
+ rm -f $pidfile
+ trace "match permitopen localhost proto $p"
+ ${SSH} -$p $fwd -F $OBJ/ssh_config -f somehost \
+ "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 || \
+ fail "match permitopen permit proto $p"
+ stop_client
+done