summaryrefslogtreecommitdiff
path: root/regress/key-options.sh
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2017-04-30 23:34:55 +0000
committerDamien Miller <djm@mindrot.org>2017-05-01 11:59:42 +1000
commitdd369320d2435b630a5974ab270d686dcd92d024 (patch)
tree97ae4bb34d835fbafad12180862195a9e9192d28 /regress/key-options.sh
parent557f921aad004be15805e09fd9572969eb3d9321 (diff)
upstream commit
eliminate explicit specification of protocol in tests and loops over protocol. We only support SSHv2 now. Upstream-Regress-ID: 0082838a9b8a382b7ee9cbf0c1b9db727784fadd
Diffstat (limited to 'regress/key-options.sh')
-rw-r--r--regress/key-options.sh52
1 files changed, 22 insertions, 30 deletions
diff --git a/regress/key-options.sh b/regress/key-options.sh
index 7a68ad358..2adee6833 100644
--- a/regress/key-options.sh
+++ b/regress/key-options.sh
@@ -1,4 +1,4 @@
1# $OpenBSD: key-options.sh,v 1.3 2015/03/03 22:35:19 markus Exp $ 1# $OpenBSD: key-options.sh,v 1.4 2017/04/30 23:34:55 djm Exp $
2# Placed in the Public Domain. 2# Placed in the Public Domain.
3 3
4tid="key options" 4tid="key options"
@@ -8,64 +8,56 @@ authkeys="$OBJ/authorized_keys_${USER}"
8cp $authkeys $origkeys 8cp $authkeys $origkeys
9 9
10# Test command= forced command 10# Test command= forced command
11for p in ${SSH_PROTOCOLS}; do 11for c in 'command="echo bar"' 'no-pty,command="echo bar"'; do
12 for c in 'command="echo bar"' 'no-pty,command="echo bar"'; do
13 sed "s/.*/$c &/" $origkeys >$authkeys 12 sed "s/.*/$c &/" $origkeys >$authkeys
14 verbose "key option proto $p $c" 13 verbose "key option $c"
15 r=`${SSH} -$p -q -F $OBJ/ssh_proxy somehost echo foo` 14 r=`${SSH} -q -F $OBJ/ssh_proxy somehost echo foo`
16 if [ "$r" = "foo" ]; then 15 if [ "$r" = "foo" ]; then
17 fail "key option forced command not restricted" 16 fail "key option forced command not restricted"
18 fi 17 fi
19 if [ "$r" != "bar" ]; then 18 if [ "$r" != "bar" ]; then
20 fail "key option forced command not executed" 19 fail "key option forced command not executed"
21 fi 20 fi
22 done
23done 21done
24 22
25# Test no-pty 23# Test no-pty
26sed 's/.*/no-pty &/' $origkeys >$authkeys 24sed 's/.*/no-pty &/' $origkeys >$authkeys
27for p in ${SSH_PROTOCOLS}; do 25verbose "key option proto no-pty"
28 verbose "key option proto $p no-pty" 26r=`${SSH} -q -F $OBJ/ssh_proxy somehost tty`
29 r=`${SSH} -$p -q -F $OBJ/ssh_proxy somehost tty` 27if [ -f "$r" ]; then
30 if [ -f "$r" ]; then 28 fail "key option failed no-pty (pty $r)"
31 fail "key option failed proto $p no-pty (pty $r)" 29fi
32 fi
33done
34 30
35# Test environment= 31# Test environment=
36echo 'PermitUserEnvironment yes' >> $OBJ/sshd_proxy 32echo 'PermitUserEnvironment yes' >> $OBJ/sshd_proxy
37sed 's/.*/environment="FOO=bar" &/' $origkeys >$authkeys 33sed 's/.*/environment="FOO=bar" &/' $origkeys >$authkeys
38for p in ${SSH_PROTOCOLS}; do 34verbose "key option environment"
39 verbose "key option proto $p environment" 35r=`${SSH} -q -F $OBJ/ssh_proxy somehost 'echo $FOO'`
40 r=`${SSH} -$p -q -F $OBJ/ssh_proxy somehost 'echo $FOO'` 36if [ "$r" != "bar" ]; then
41 if [ "$r" != "bar" ]; then 37 fail "key option environment not set"
42 fail "key option environment not set" 38fi
43 fi
44done
45 39
46# Test from= restriction 40# Test from= restriction
47start_sshd 41start_sshd
48for p in ${SSH_PROTOCOLS}; do 42for f in 127.0.0.1 '127.0.0.0\/8'; do
49 for f in 127.0.0.1 '127.0.0.0\/8'; do
50 cat $origkeys >$authkeys 43 cat $origkeys >$authkeys
51 ${SSH} -$p -q -F $OBJ/ssh_proxy somehost true 44 ${SSH} -q -F $OBJ/ssh_proxy somehost true
52 if [ $? -ne 0 ]; then 45 if [ $? -ne 0 ]; then
53 fail "key option proto $p failed without restriction" 46 fail "key option failed without restriction"
54 fi 47 fi
55 48
56 sed 's/.*/from="'"$f"'" &/' $origkeys >$authkeys 49 sed 's/.*/from="'"$f"'" &/' $origkeys >$authkeys
57 from=`head -1 $authkeys | cut -f1 -d ' '` 50 from=`head -1 $authkeys | cut -f1 -d ' '`
58 verbose "key option proto $p $from" 51 verbose "key option $from"
59 r=`${SSH} -$p -q -F $OBJ/ssh_proxy somehost 'echo true'` 52 r=`${SSH} -q -F $OBJ/ssh_proxy somehost 'echo true'`
60 if [ "$r" = "true" ]; then 53 if [ "$r" = "true" ]; then
61 fail "key option proto $p $from not restricted" 54 fail "key option $from not restricted"
62 fi 55 fi
63 56
64 r=`${SSH} -$p -q -F $OBJ/ssh_config somehost 'echo true'` 57 r=`${SSH} -q -F $OBJ/ssh_config somehost 'echo true'`
65 if [ "$r" != "true" ]; then 58 if [ "$r" != "true" ]; then
66 fail "key option proto $p $from not allowed but should be" 59 fail "key option $from not allowed but should be"
67 fi 60 fi
68 done
69done 61done
70 62
71rm -f "$origkeys" 63rm -f "$origkeys"