diff options
Diffstat (limited to 'regress/key-options.sh')
-rw-r--r-- | regress/key-options.sh | 68 |
1 files changed, 60 insertions, 8 deletions
diff --git a/regress/key-options.sh b/regress/key-options.sh index 2adee6833..d680737c1 100644 --- a/regress/key-options.sh +++ b/regress/key-options.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: key-options.sh,v 1.4 2017/04/30 23:34:55 djm Exp $ | 1 | # $OpenBSD: key-options.sh,v 1.8 2018/03/14 05:35:40 djm Exp $ |
2 | # Placed in the Public Domain. | 2 | # Placed in the Public Domain. |
3 | 3 | ||
4 | tid="key options" | 4 | tid="key options" |
@@ -21,12 +21,46 @@ for c in 'command="echo bar"' 'no-pty,command="echo bar"'; do | |||
21 | done | 21 | done |
22 | 22 | ||
23 | # Test no-pty | 23 | # Test no-pty |
24 | sed 's/.*/no-pty &/' $origkeys >$authkeys | 24 | expect_pty_succeed() { |
25 | verbose "key option proto no-pty" | 25 | which=$1 |
26 | r=`${SSH} -q -F $OBJ/ssh_proxy somehost tty` | 26 | opts=$2 |
27 | if [ -f "$r" ]; then | 27 | rm -f $OBJ/data |
28 | fail "key option failed no-pty (pty $r)" | 28 | sed "s/.*/$opts &/" $origkeys >$authkeys |
29 | fi | 29 | verbose "key option pty $which" |
30 | ${SSH} -ttq -F $OBJ/ssh_proxy somehost "tty > $OBJ/data; exit 0" | ||
31 | if [ $? -ne 0 ] ; then | ||
32 | fail "key option failed $which" | ||
33 | else | ||
34 | r=`cat $OBJ/data` | ||
35 | case "$r" in | ||
36 | /dev/*) ;; | ||
37 | *) fail "key option failed $which (pty $r)" ;; | ||
38 | esac | ||
39 | fi | ||
40 | } | ||
41 | expect_pty_fail() { | ||
42 | which=$1 | ||
43 | opts=$2 | ||
44 | rm -f $OBJ/data | ||
45 | sed "s/.*/$opts &/" $origkeys >$authkeys | ||
46 | verbose "key option pty $which" | ||
47 | ${SSH} -ttq -F $OBJ/ssh_proxy somehost "tty > $OBJ/data; exit 0" | ||
48 | if [ $? -eq 0 ]; then | ||
49 | r=`cat $OBJ/data` | ||
50 | if [ -e "$r" ]; then | ||
51 | fail "key option failed $which (pty $r)" | ||
52 | fi | ||
53 | case "$r" in | ||
54 | /dev/*) fail "key option failed $which (pty $r)" ;; | ||
55 | *) ;; | ||
56 | esac | ||
57 | fi | ||
58 | } | ||
59 | # First ensure that we can allocate a pty by default. | ||
60 | expect_pty_succeed "default" "" | ||
61 | expect_pty_fail "no-pty" "no-pty" | ||
62 | expect_pty_fail "restrict" "restrict" | ||
63 | expect_pty_succeed "restrict,pty" "restrict,pty" | ||
30 | 64 | ||
31 | # Test environment= | 65 | # Test environment= |
32 | echo 'PermitUserEnvironment yes' >> $OBJ/sshd_proxy | 66 | echo 'PermitUserEnvironment yes' >> $OBJ/sshd_proxy |
@@ -60,4 +94,22 @@ for f in 127.0.0.1 '127.0.0.0\/8'; do | |||
60 | fi | 94 | fi |
61 | done | 95 | done |
62 | 96 | ||
63 | rm -f "$origkeys" | 97 | check_valid_before() { |
98 | which=$1 | ||
99 | opts=$2 | ||
100 | expect=$3 | ||
101 | sed "s/.*/$opts &/" $origkeys >$authkeys | ||
102 | verbose "key option expiry-time $which" | ||
103 | ${SSH} -q -F $OBJ/ssh_proxy somehost true | ||
104 | r=$? | ||
105 | case "$expect" in | ||
106 | fail) test $r -eq 0 && fail "key option succeeded $which" ;; | ||
107 | pass) test $r -ne 0 && fail "key option failed $which" ;; | ||
108 | *) fatal "unknown expectation $expect" ;; | ||
109 | esac | ||
110 | } | ||
111 | check_valid_before "default" "" "pass" | ||
112 | check_valid_before "invalid" 'expiry-time="INVALID"' "fail" | ||
113 | check_valid_before "expired" 'expiry-time="19990101"' "fail" | ||
114 | check_valid_before "valid" 'expiry-time="20380101"' "pass" | ||
115 | |||