summaryrefslogtreecommitdiff
path: root/regress/key-options.sh
diff options
context:
space:
mode:
authorDarren Tucker <dtucker@zip.com.au>2008-06-11 09:38:12 +1000
committerDarren Tucker <dtucker@zip.com.au>2008-06-11 09:38:12 +1000
commite045e0c62ae29fb7a2ed175c973fda32e60ee43d (patch)
tree51aae239029c8f4ce2992c9fee33b32c02d41e3b /regress/key-options.sh
parent2a8b138ed852625abeb56192f8439061761bdb93 (diff)
- dtucker@cvs.openbsd.org 2008/06/10 23:13:43
[Makefile regress/key-options.sh] Add regress test for key options. ok djm@
Diffstat (limited to 'regress/key-options.sh')
-rw-r--r--regress/key-options.sh71
1 files changed, 71 insertions, 0 deletions
diff --git a/regress/key-options.sh b/regress/key-options.sh
new file mode 100644
index 000000000..b4dd47057
--- /dev/null
+++ b/regress/key-options.sh
@@ -0,0 +1,71 @@
1# $OpenBSD: key-options.sh,v 1.1 2008/06/10 23:13:43 dtucker Exp $
2# Placed in the Public Domain.
3
4tid="key options"
5
6origkeys="$OBJ/authkeys_orig"
7authkeys="$OBJ/authorized_keys_${USER}"
8cp $authkeys $origkeys
9
10# Test command= forced command
11for p in 1 2; do
12 for c in 'command="echo bar"' 'no-pty,command="echo bar"'; do
13 sed "s/.*/$c &/" $origkeys >$authkeys
14 verbose "key option proto $p $c"
15 r=`${SSH} -$p -q -F $OBJ/ssh_proxy somehost echo foo`
16 if [ "$r" = "foo" ]; then
17 fail "key option forced command not restricted"
18 fi
19 if [ "$r" != "bar" ]; then
20 fail "key option forced command not executed"
21 fi
22 done
23done
24
25# Test no-pty
26sed 's/.*/no-pty &/' $origkeys >$authkeys
27for p in 1 2; do
28 verbose "key option proto $p no-pty"
29 r=`${SSH} -$p -q -F $OBJ/ssh_proxy somehost tty`
30 if [ -f "$r" ]; then
31 fail "key option failed proto $p no-pty (pty $r)"
32 fi
33done
34
35# Test environment=
36echo 'PermitUserEnvironment yes' >> $OBJ/sshd_proxy
37sed 's/.*/environment="FOO=bar" &/' $origkeys >$authkeys
38for p in 1 2; do
39 verbose "key option proto $p environment"
40 r=`${SSH} -$p -q -F $OBJ/ssh_proxy somehost 'echo $FOO'`
41 if [ "$r" != "bar" ]; then
42 fail "key option environment not set"
43 fi
44done
45
46# Test from= restriction
47start_sshd
48for p in 1 2; do
49 for f in 127.0.0.1 '127.0.0.0\/8'; do
50 cat $origkeys >$authkeys
51 ${SSH} -$p -q -F $OBJ/ssh_proxy somehost true
52 if [ $? -ne 0 ]; then
53 fail "key option proto $p failed without restriction"
54 fi
55
56 sed 's/.*/from="'$f'" &/' $origkeys >$authkeys
57 from=`head -1 $authkeys | cut -f1 -d ' '`
58 verbose "key option proto $p $from"
59 r=`${SSH} -$p -q -F $OBJ/ssh_proxy somehost 'echo true'`
60 if [ "$r" == "true" ]; then
61 fail "key option proto $p $from not restricted"
62 fi
63
64 r=`${SSH} -$p -q -F $OBJ/ssh_config somehost 'echo true'`
65 if [ "$r" != "true" ]; then
66 fail "key option proto $p $from not allowed but should be"
67 fi
68 done
69done
70
71rm -f "$origkeys"