diff options
Diffstat (limited to 'regress')
-rw-r--r-- | regress/Makefile | 18 | ||||
-rw-r--r-- | regress/addrmatch.sh | 11 | ||||
-rw-r--r-- | regress/agent-pkcs11.sh | 69 | ||||
-rw-r--r-- | regress/cert-hostkey.sh | 211 | ||||
-rw-r--r-- | regress/cert-userkey.sh | 176 | ||||
-rw-r--r-- | regress/cfgmatch.sh | 4 | ||||
-rw-r--r-- | regress/cipher-speed.sh | 4 | ||||
-rw-r--r-- | regress/forwarding.sh | 12 | ||||
-rw-r--r-- | regress/keygen-convert.sh | 33 | ||||
-rw-r--r-- | regress/multiplex.sh | 20 | ||||
-rw-r--r-- | regress/portnum.sh | 34 | ||||
-rw-r--r-- | regress/sftp-badcmds.sh | 16 | ||||
-rw-r--r-- | regress/sftp-batch.sh | 10 | ||||
-rw-r--r-- | regress/sftp-cmds.sh | 73 | ||||
-rw-r--r-- | regress/sftp-glob.sh | 4 | ||||
-rw-r--r-- | regress/sftp.sh | 6 | ||||
-rw-r--r-- | regress/ssh-com-sftp.sh | 4 | ||||
-rwxr-xr-x | regress/ssh2putty.sh | 1 | ||||
-rw-r--r-- | regress/test-exec.sh | 14 |
19 files changed, 638 insertions, 82 deletions
diff --git a/regress/Makefile b/regress/Makefile index 3b8ea245b..d25a64555 100644 --- a/regress/Makefile +++ b/regress/Makefile | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: Makefile,v 1.48 2008/06/28 13:57:25 djm Exp $ | 1 | # $OpenBSD: Makefile,v 1.52 2010/02/26 20:33:21 djm Exp $ |
2 | 2 | ||
3 | REGRESS_TARGETS= t1 t2 t3 t4 t5 t6 t7 t-exec | 3 | REGRESS_TARGETS= t1 t2 t3 t4 t5 t6 t7 t-exec |
4 | tests: $(REGRESS_TARGETS) | 4 | tests: $(REGRESS_TARGETS) |
@@ -34,6 +34,7 @@ LTESTS= connect \ | |||
34 | agent-ptrace \ | 34 | agent-ptrace \ |
35 | keyscan \ | 35 | keyscan \ |
36 | keygen-change \ | 36 | keygen-change \ |
37 | keygen-convert \ | ||
37 | key-options \ | 38 | key-options \ |
38 | scp \ | 39 | scp \ |
39 | sftp \ | 40 | sftp \ |
@@ -50,7 +51,10 @@ LTESTS= connect \ | |||
50 | cfgmatch \ | 51 | cfgmatch \ |
51 | addrmatch \ | 52 | addrmatch \ |
52 | localcommand \ | 53 | localcommand \ |
53 | forcecommand | 54 | forcecommand \ |
55 | portnum \ | ||
56 | cert-hostkey \ | ||
57 | cert-userkey | ||
54 | 58 | ||
55 | INTEROP_TESTS= putty-transfer putty-ciphers putty-kex conch-ciphers | 59 | INTEROP_TESTS= putty-transfer putty-ciphers putty-kex conch-ciphers |
56 | #INTEROP_TESTS+=ssh-com ssh-com-client ssh-com-keygen ssh-com-sftp | 60 | #INTEROP_TESTS+=ssh-com ssh-com-client ssh-com-keygen ssh-com-sftp |
@@ -64,7 +68,11 @@ CLEANFILES= t2.out t6.out1 t6.out2 t7.out t7.out.pub copy.1 copy.2 \ | |||
64 | ls.copy banner.in banner.out empty.in \ | 68 | ls.copy banner.in banner.out empty.in \ |
65 | scp-ssh-wrapper.scp ssh_proxy_envpass remote_pid \ | 69 | scp-ssh-wrapper.scp ssh_proxy_envpass remote_pid \ |
66 | sshd_proxy_bak rsa_ssh2_cr.prv rsa_ssh2_crnl.prv \ | 70 | sshd_proxy_bak rsa_ssh2_cr.prv rsa_ssh2_crnl.prv \ |
67 | putty.rsa2 | 71 | known_hosts-cert host_ca_key* cert_host_key* \ |
72 | putty.rsa2 sshd_proxy_orig | ||
73 | |||
74 | # Enable all malloc(3) randomisations and checks | ||
75 | TEST_ENV= "MALLOC_OPTIONS=AFGJPRX" | ||
68 | 76 | ||
69 | t1: | 77 | t1: |
70 | ssh-keygen -if ${.CURDIR}/rsa_ssh2.prv | diff - ${.CURDIR}/rsa_openssh.prv | 78 | ssh-keygen -if ${.CURDIR}/rsa_ssh2.prv | diff - ${.CURDIR}/rsa_openssh.prv |
@@ -104,13 +112,13 @@ t-exec: ${LTESTS:=.sh} | |||
104 | @if [ "x$?" = "x" ]; then exit 0; fi; \ | 112 | @if [ "x$?" = "x" ]; then exit 0; fi; \ |
105 | for TEST in ""$?; do \ | 113 | for TEST in ""$?; do \ |
106 | echo "run test $${TEST}" ... 1>&2; \ | 114 | echo "run test $${TEST}" ... 1>&2; \ |
107 | (env SUDO=${SUDO} sh ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/$${TEST}) || exit $$?; \ | 115 | (env SUDO=${SUDO} TEST_ENV=${TEST_ENV} sh ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/$${TEST}) || exit $$?; \ |
108 | done | 116 | done |
109 | 117 | ||
110 | t-exec-interop: ${INTEROP_TESTS:=.sh} | 118 | t-exec-interop: ${INTEROP_TESTS:=.sh} |
111 | @if [ "x$?" = "x" ]; then exit 0; fi; \ | 119 | @if [ "x$?" = "x" ]; then exit 0; fi; \ |
112 | for TEST in ""$?; do \ | 120 | for TEST in ""$?; do \ |
113 | echo "run test $${TEST}" ... 1>&2; \ | 121 | echo "run test $${TEST}" ... 1>&2; \ |
114 | (env SUDO=${SUDO} sh ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/$${TEST}) || exit $$?; \ | 122 | (env SUDO=${SUDO} TEST_ENV=${TEST_ENV} sh ${.CURDIR}/test-exec.sh ${.OBJDIR} ${.CURDIR}/$${TEST}) || exit $$?; \ |
115 | done | 123 | done |
116 | 124 | ||
diff --git a/regress/addrmatch.sh b/regress/addrmatch.sh index a258f7bb4..23ddd65ce 100644 --- a/regress/addrmatch.sh +++ b/regress/addrmatch.sh | |||
@@ -1,9 +1,9 @@ | |||
1 | # $OpenBSD: addrmatch.sh,v 1.1 2008/06/10 05:23:32 dtucker Exp $ | 1 | # $OpenBSD: addrmatch.sh,v 1.3 2010/02/09 04:57:36 djm Exp $ |
2 | # Placed in the Public Domain. | 2 | # Placed in the Public Domain. |
3 | 3 | ||
4 | tid="address match" | 4 | tid="address match" |
5 | 5 | ||
6 | mv $OBJ/sshd_proxy $OBJ/sshd_proxy_orig | 6 | mv $OBJ/sshd_proxy $OBJ/sshd_proxy_bak |
7 | 7 | ||
8 | run_trial() | 8 | run_trial() |
9 | { | 9 | { |
@@ -12,13 +12,13 @@ run_trial() | |||
12 | verbose "test $descr for $user $addr $host" | 12 | verbose "test $descr for $user $addr $host" |
13 | result=`${SSHD} -f $OBJ/sshd_proxy -T \ | 13 | result=`${SSHD} -f $OBJ/sshd_proxy -T \ |
14 | -C user=${user},addr=${addr},host=${host} | \ | 14 | -C user=${user},addr=${addr},host=${host} | \ |
15 | awk '/passwordauthentication/ {print $2}'` | 15 | awk '/^passwordauthentication/ {print $2}'` |
16 | if [ "$result" != "$expected" ]; then | 16 | if [ "$result" != "$expected" ]; then |
17 | fail "failed for $user $addr $host: expected $expected, got $result" | 17 | fail "failed for $user $addr $host: expected $expected, got $result" |
18 | fi | 18 | fi |
19 | } | 19 | } |
20 | 20 | ||
21 | cp $OBJ/sshd_proxy_orig $OBJ/sshd_proxy | 21 | cp $OBJ/sshd_proxy_bak $OBJ/sshd_proxy |
22 | cat >>$OBJ/sshd_proxy <<EOD | 22 | cat >>$OBJ/sshd_proxy <<EOD |
23 | PasswordAuthentication no | 23 | PasswordAuthentication no |
24 | Match Address 192.168.0.0/16,!192.168.30.0/24,10.0.0.0/8,host.example.com | 24 | Match Address 192.168.0.0/16,!192.168.30.0/24,10.0.0.0/8,host.example.com |
@@ -40,3 +40,6 @@ run_trial user ::3 somehost no "deny IP6 negated" | |||
40 | run_trial user ::4 somehost no "deny, IP6 no match" | 40 | run_trial user ::4 somehost no "deny, IP6 no match" |
41 | run_trial user 2000::1 somehost yes "permit, IP6 network" | 41 | run_trial user 2000::1 somehost yes "permit, IP6 network" |
42 | run_trial user 2001::1 somehost no "deny, IP6 network" | 42 | run_trial user 2001::1 somehost no "deny, IP6 network" |
43 | |||
44 | cp $OBJ/sshd_proxy_bak $OBJ/sshd_proxy | ||
45 | rm $OBJ/sshd_proxy_bak | ||
diff --git a/regress/agent-pkcs11.sh b/regress/agent-pkcs11.sh new file mode 100644 index 000000000..db33ab37e --- /dev/null +++ b/regress/agent-pkcs11.sh | |||
@@ -0,0 +1,69 @@ | |||
1 | # $OpenBSD: agent-pkcs11.sh,v 1.1 2010/02/08 10:52:47 markus Exp $ | ||
2 | # Placed in the Public Domain. | ||
3 | |||
4 | tid="pkcs11 agent test" | ||
5 | |||
6 | TEST_SSH_PIN="" | ||
7 | TEST_SSH_PKCS11=/usr/local/lib/soft-pkcs11.so.0.0 | ||
8 | |||
9 | # setup environment for soft-pkcs11 token | ||
10 | SOFTPKCS11RC=$OBJ/pkcs11.info | ||
11 | export SOFTPKCS11RC | ||
12 | # prevent ssh-agent from calling ssh-askpass | ||
13 | SSH_ASKPASS=/usr/bin/true | ||
14 | export SSH_ASKPASS | ||
15 | unset DISPLAY | ||
16 | |||
17 | # start command w/o tty, so ssh-add accepts pin from stdin | ||
18 | notty() { | ||
19 | perl -e 'use POSIX; POSIX::setsid(); | ||
20 | if (fork) { wait; exit($? >> 8); } else { exec(@ARGV) }' "$@" | ||
21 | } | ||
22 | |||
23 | trace "start agent" | ||
24 | eval `${SSHAGENT} -s` > /dev/null | ||
25 | r=$? | ||
26 | if [ $r -ne 0 ]; then | ||
27 | fail "could not start ssh-agent: exit code $r" | ||
28 | else | ||
29 | trace "generating key/cert" | ||
30 | rm -f $OBJ/pkcs11.key $OBJ/pkcs11.crt | ||
31 | openssl genrsa -out $OBJ/pkcs11.key 2048 > /dev/null 2>&1 | ||
32 | chmod 600 $OBJ/pkcs11.key | ||
33 | openssl req -key $OBJ/pkcs11.key -new -x509 \ | ||
34 | -out $OBJ/pkcs11.crt -text -subj '/CN=pkcs11 test' > /dev/null | ||
35 | printf "a\ta\t$OBJ/pkcs11.crt\t$OBJ/pkcs11.key" > $SOFTPKCS11RC | ||
36 | # add to authorized keys | ||
37 | ${SSHKEYGEN} -y -f $OBJ/pkcs11.key > $OBJ/authorized_keys_$USER | ||
38 | |||
39 | trace "add pkcs11 key to agent" | ||
40 | echo ${TEST_SSH_PIN} | notty ${SSHADD} -s ${TEST_SSH_PKCS11} > /dev/null 2>&1 | ||
41 | r=$? | ||
42 | if [ $r -ne 0 ]; then | ||
43 | fail "ssh-add -s failed: exit code $r" | ||
44 | fi | ||
45 | |||
46 | trace "pkcs11 list via agent" | ||
47 | ${SSHADD} -l > /dev/null 2>&1 | ||
48 | r=$? | ||
49 | if [ $r -ne 0 ]; then | ||
50 | fail "ssh-add -l failed: exit code $r" | ||
51 | fi | ||
52 | |||
53 | trace "pkcs11 connect via agent" | ||
54 | ${SSH} -2 -F $OBJ/ssh_proxy somehost exit 5 | ||
55 | r=$? | ||
56 | if [ $r -ne 5 ]; then | ||
57 | fail "ssh connect failed (exit code $r)" | ||
58 | fi | ||
59 | |||
60 | trace "remove pkcs11 keys" | ||
61 | echo ${TEST_SSH_PIN} | notty ${SSHADD} -e ${TEST_SSH_PKCS11} > /dev/null 2>&1 | ||
62 | r=$? | ||
63 | if [ $r -ne 0 ]; then | ||
64 | fail "ssh-add -e failed: exit code $r" | ||
65 | fi | ||
66 | |||
67 | trace "kill agent" | ||
68 | ${SSHAGENT} -k > /dev/null | ||
69 | fi | ||
diff --git a/regress/cert-hostkey.sh b/regress/cert-hostkey.sh new file mode 100644 index 000000000..3fda667cb --- /dev/null +++ b/regress/cert-hostkey.sh | |||
@@ -0,0 +1,211 @@ | |||
1 | # $OpenBSD: cert-hostkey.sh,v 1.3 2010/03/04 10:38:23 djm Exp $ | ||
2 | # Placed in the Public Domain. | ||
3 | |||
4 | tid="certified host keys" | ||
5 | |||
6 | rm -f $OBJ/known_hosts-cert $OBJ/host_ca_key* $OBJ/cert_host_key* | ||
7 | cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak | ||
8 | |||
9 | HOSTS='localhost-with-alias,127.0.0.1,::1' | ||
10 | |||
11 | # Create a CA key and add it to known hosts | ||
12 | ${SSHKEYGEN} -q -N '' -t rsa -f $OBJ/host_ca_key ||\ | ||
13 | fail "ssh-keygen of host_ca_key failed" | ||
14 | ( | ||
15 | echon '@cert-authority ' | ||
16 | echon "$HOSTS " | ||
17 | cat $OBJ/host_ca_key.pub | ||
18 | ) > $OBJ/known_hosts-cert | ||
19 | |||
20 | # Generate and sign host keys | ||
21 | for ktype in rsa dsa ; do | ||
22 | verbose "$tid: sign host ${ktype} cert" | ||
23 | # Generate and sign a host key | ||
24 | ${SSHKEYGEN} -q -N '' -t ${ktype} \ | ||
25 | -f $OBJ/cert_host_key_${ktype} || \ | ||
26 | fail "ssh-keygen of cert_host_key_${ktype} failed" | ||
27 | ${SSHKEYGEN} -h -q -s $OBJ/host_ca_key \ | ||
28 | -I "regress host key for $USER" \ | ||
29 | -n $HOSTS $OBJ/cert_host_key_${ktype} || | ||
30 | fail "couldn't sign cert_host_key_${ktype}" | ||
31 | done | ||
32 | |||
33 | # Basic connect tests | ||
34 | for privsep in yes no ; do | ||
35 | for ktype in rsa dsa ; do | ||
36 | verbose "$tid: host ${ktype} cert connect privsep $privsep" | ||
37 | ( | ||
38 | cat $OBJ/sshd_proxy_bak | ||
39 | echo HostKey $OBJ/cert_host_key_${ktype} | ||
40 | echo HostCertificate $OBJ/cert_host_key_${ktype}-cert.pub | ||
41 | echo UsePrivilegeSeparation $privsep | ||
42 | ) > $OBJ/sshd_proxy | ||
43 | |||
44 | ${SSH} -2 -oUserKnownHostsFile=$OBJ/known_hosts-cert \ | ||
45 | -oGlobalKnownHostsFile=$OBJ/known_hosts-cert \ | ||
46 | -F $OBJ/ssh_proxy somehost true | ||
47 | if [ $? -ne 0 ]; then | ||
48 | fail "ssh cert connect failed" | ||
49 | fi | ||
50 | done | ||
51 | done | ||
52 | |||
53 | # Revoked certificates with key present | ||
54 | ( | ||
55 | echon '@cert-authority ' | ||
56 | echon "$HOSTS " | ||
57 | cat $OBJ/host_ca_key.pub | ||
58 | echon '@revoked ' | ||
59 | echon "* " | ||
60 | cat $OBJ/cert_host_key_rsa.pub | ||
61 | echon '@revoked ' | ||
62 | echon "* " | ||
63 | cat $OBJ/cert_host_key_dsa.pub | ||
64 | ) > $OBJ/known_hosts-cert | ||
65 | for privsep in yes no ; do | ||
66 | for ktype in rsa dsa ; do | ||
67 | verbose "$tid: host ${ktype} revoked cert privsep $privsep" | ||
68 | ( | ||
69 | cat $OBJ/sshd_proxy_bak | ||
70 | echo HostKey $OBJ/cert_host_key_${ktype} | ||
71 | echo HostCertificate $OBJ/cert_host_key_${ktype}-cert.pub | ||
72 | echo UsePrivilegeSeparation $privsep | ||
73 | ) > $OBJ/sshd_proxy | ||
74 | |||
75 | ${SSH} -2 -oUserKnownHostsFile=$OBJ/known_hosts-cert \ | ||
76 | -oGlobalKnownHostsFile=$OBJ/known_hosts-cert \ | ||
77 | -F $OBJ/ssh_proxy somehost true >/dev/null 2>&1 | ||
78 | if [ $? -eq 0 ]; then | ||
79 | fail "ssh cert connect succeeded unexpectedly" | ||
80 | fi | ||
81 | done | ||
82 | done | ||
83 | |||
84 | # Revoked CA | ||
85 | ( | ||
86 | echon '@cert-authority ' | ||
87 | echon "$HOSTS " | ||
88 | cat $OBJ/host_ca_key.pub | ||
89 | echon '@revoked ' | ||
90 | echon "* " | ||
91 | cat $OBJ/host_ca_key.pub | ||
92 | ) > $OBJ/known_hosts-cert | ||
93 | for ktype in rsa dsa ; do | ||
94 | verbose "$tid: host ${ktype} revoked cert" | ||
95 | ( | ||
96 | cat $OBJ/sshd_proxy_bak | ||
97 | echo HostKey $OBJ/cert_host_key_${ktype} | ||
98 | echo HostCertificate $OBJ/cert_host_key_${ktype}-cert.pub | ||
99 | ) > $OBJ/sshd_proxy | ||
100 | ${SSH} -2 -oUserKnownHostsFile=$OBJ/known_hosts-cert \ | ||
101 | -oGlobalKnownHostsFile=$OBJ/known_hosts-cert \ | ||
102 | -F $OBJ/ssh_proxy somehost true >/dev/null 2>&1 | ||
103 | if [ $? -eq 0 ]; then | ||
104 | fail "ssh cert connect succeeded unexpectedly" | ||
105 | fi | ||
106 | done | ||
107 | |||
108 | # Create a CA key and add it to known hosts | ||
109 | ( | ||
110 | echon '@cert-authority ' | ||
111 | echon "$HOSTS " | ||
112 | cat $OBJ/host_ca_key.pub | ||
113 | ) > $OBJ/known_hosts-cert | ||
114 | |||
115 | test_one() { | ||
116 | ident=$1 | ||
117 | result=$2 | ||
118 | sign_opts=$3 | ||
119 | |||
120 | verbose "$tid: test host cert connect $ident expect $result" | ||
121 | |||
122 | ${SSHKEYGEN} -q -s $OBJ/host_ca_key -I "regress host key for $USER" \ | ||
123 | $sign_opts \ | ||
124 | $OBJ/cert_host_key_rsa || | ||
125 | fail "couldn't sign cert_host_key_rsa" | ||
126 | ( | ||
127 | cat $OBJ/sshd_proxy_bak | ||
128 | echo HostKey $OBJ/cert_host_key_rsa | ||
129 | echo HostCertificate $OBJ/cert_host_key_rsa-cert.pub | ||
130 | ) > $OBJ/sshd_proxy | ||
131 | |||
132 | ${SSH} -2 -oUserKnownHostsFile=$OBJ/known_hosts-cert \ | ||
133 | -oGlobalKnownHostsFile=$OBJ/known_hosts-cert \ | ||
134 | -F $OBJ/ssh_proxy somehost true >/dev/null 2>&1 | ||
135 | rc=$? | ||
136 | if [ "x$result" = "xsuccess" ] ; then | ||
137 | if [ $rc -ne 0 ]; then | ||
138 | fail "ssh cert connect $ident failed unexpectedly" | ||
139 | fi | ||
140 | else | ||
141 | if [ $rc -eq 0 ]; then | ||
142 | fail "ssh cert connect $ident succeeded unexpectedly" | ||
143 | fi | ||
144 | fi | ||
145 | } | ||
146 | |||
147 | test_one "user-certificate" failure "-n $HOSTS" | ||
148 | test_one "empty principals" success "-h" | ||
149 | test_one "wrong principals" failure "-h -n foo" | ||
150 | test_one "cert not yet valid" failure "-h -V20200101:20300101" | ||
151 | test_one "cert expired" failure "-h -V19800101:19900101" | ||
152 | test_one "cert valid interval" success "-h -V-1w:+2w" | ||
153 | test_one "cert has constraints" failure "-h -Oforce-command=false" | ||
154 | |||
155 | # Check downgrade of cert to raw key when no CA found | ||
156 | rm -f $OBJ/known_hosts-cert $OBJ/cert_host_key* | ||
157 | for ktype in rsa dsa ; do | ||
158 | verbose "$tid: host ${ktype} cert downgrade to raw key" | ||
159 | # Generate and sign a host key | ||
160 | ${SSHKEYGEN} -q -N '' -t ${ktype} \ | ||
161 | -f $OBJ/cert_host_key_${ktype} || \ | ||
162 | fail "ssh-keygen of cert_host_key_${ktype} failed" | ||
163 | ${SSHKEYGEN} -h -q -s $OBJ/host_ca_key -I "regress host key for $USER" \ | ||
164 | -n $HOSTS $OBJ/cert_host_key_${ktype} || | ||
165 | fail "couldn't sign cert_host_key_${ktype}" | ||
166 | ( | ||
167 | echon "$HOSTS " | ||
168 | cat $OBJ/cert_host_key_${ktype}.pub | ||
169 | ) > $OBJ/known_hosts-cert | ||
170 | ( | ||
171 | cat $OBJ/sshd_proxy_bak | ||
172 | echo HostKey $OBJ/cert_host_key_${ktype} | ||
173 | echo HostCertificate $OBJ/cert_host_key_${ktype}-cert.pub | ||
174 | ) > $OBJ/sshd_proxy | ||
175 | |||
176 | ${SSH} -2 -oUserKnownHostsFile=$OBJ/known_hosts-cert \ | ||
177 | -oGlobalKnownHostsFile=$OBJ/known_hosts-cert \ | ||
178 | -F $OBJ/ssh_proxy somehost true | ||
179 | if [ $? -ne 0 ]; then | ||
180 | fail "ssh cert connect failed" | ||
181 | fi | ||
182 | done | ||
183 | |||
184 | # Wrong certificate | ||
185 | ( | ||
186 | echon '@cert-authority ' | ||
187 | echon "$HOSTS " | ||
188 | cat $OBJ/host_ca_key.pub | ||
189 | ) > $OBJ/known_hosts-cert | ||
190 | for ktype in rsa dsa ; do | ||
191 | # Self-sign key | ||
192 | ${SSHKEYGEN} -h -q -s $OBJ/cert_host_key_${ktype} \ | ||
193 | -I "regress host key for $USER" \ | ||
194 | -n $HOSTS $OBJ/cert_host_key_${ktype} || | ||
195 | fail "couldn't sign cert_host_key_${ktype}" | ||
196 | verbose "$tid: host ${ktype} connect wrong cert" | ||
197 | ( | ||
198 | cat $OBJ/sshd_proxy_bak | ||
199 | echo HostKey $OBJ/cert_host_key_${ktype} | ||
200 | echo HostCertificate $OBJ/cert_host_key_${ktype}-cert.pub | ||
201 | ) > $OBJ/sshd_proxy | ||
202 | |||
203 | ${SSH} -2 -oUserKnownHostsFile=$OBJ/known_hosts-cert \ | ||
204 | -oGlobalKnownHostsFile=$OBJ/known_hosts-cert \ | ||
205 | -F $OBJ/ssh_proxy -q somehost true >/dev/null 2>&1 | ||
206 | if [ $? -eq 0 ]; then | ||
207 | fail "ssh cert connect $ident succeeded unexpectedly" | ||
208 | fi | ||
209 | done | ||
210 | |||
211 | rm -f $OBJ/known_hosts-cert $OBJ/host_ca_key* $OBJ/cert_host_key* | ||
diff --git a/regress/cert-userkey.sh b/regress/cert-userkey.sh new file mode 100644 index 000000000..7a58e7b75 --- /dev/null +++ b/regress/cert-userkey.sh | |||
@@ -0,0 +1,176 @@ | |||
1 | # $OpenBSD: cert-userkey.sh,v 1.3 2010/03/04 10:38:23 djm Exp $ | ||
2 | # Placed in the Public Domain. | ||
3 | |||
4 | tid="certified user keys" | ||
5 | |||
6 | rm -f $OBJ/authorized_keys_$USER $OBJ/user_ca_key* $OBJ/cert_user_key* | ||
7 | cp $OBJ/sshd_proxy $OBJ/sshd_proxy_bak | ||
8 | |||
9 | # Create a CA key | ||
10 | ${SSHKEYGEN} -q -N '' -t rsa -f $OBJ/user_ca_key ||\ | ||
11 | fail "ssh-keygen of user_ca_key failed" | ||
12 | |||
13 | # Generate and sign user keys | ||
14 | for ktype in rsa dsa ; do | ||
15 | verbose "$tid: sign user ${ktype} cert" | ||
16 | ${SSHKEYGEN} -q -N '' -t ${ktype} \ | ||
17 | -f $OBJ/cert_user_key_${ktype} || \ | ||
18 | fail "ssh-keygen of cert_user_key_${ktype} failed" | ||
19 | ${SSHKEYGEN} -q -s $OBJ/user_ca_key -I \ | ||
20 | "regress user key for $USER" \ | ||
21 | -n $USER $OBJ/cert_user_key_${ktype} || | ||
22 | fail "couldn't sign cert_user_key_${ktype}" | ||
23 | done | ||
24 | |||
25 | basic_tests() { | ||
26 | auth=$1 | ||
27 | if test "x$auth" = "xauthorized_keys" ; then | ||
28 | # Add CA to authorized_keys | ||
29 | ( | ||
30 | echon 'cert-authority ' | ||
31 | cat $OBJ/user_ca_key.pub | ||
32 | ) > $OBJ/authorized_keys_$USER | ||
33 | else | ||
34 | echo > $OBJ/authorized_keys_$USER | ||
35 | extra_sshd="TrustedUserCAKeys $OBJ/user_ca_key.pub" | ||
36 | fi | ||
37 | |||
38 | for ktype in rsa dsa ; do | ||
39 | for privsep in yes no ; do | ||
40 | _prefix="${ktype} privsep $privsep $auth" | ||
41 | # Simple connect | ||
42 | verbose "$tid: ${_prefix} connect" | ||
43 | ( | ||
44 | cat $OBJ/sshd_proxy_bak | ||
45 | echo "UsePrivilegeSeparation $privsep" | ||
46 | echo "$extra_sshd" | ||
47 | ) > $OBJ/sshd_proxy | ||
48 | |||
49 | ${SSH} -2i $OBJ/cert_user_key_${ktype} \ | ||
50 | -F $OBJ/ssh_proxy somehost true | ||
51 | if [ $? -ne 0 ]; then | ||
52 | fail "ssh cert connect failed" | ||
53 | fi | ||
54 | |||
55 | # Revoked keys | ||
56 | verbose "$tid: ${_prefix} revoked key" | ||
57 | ( | ||
58 | cat $OBJ/sshd_proxy_bak | ||
59 | echo "UsePrivilegeSeparation $privsep" | ||
60 | echo "RevokedKeys $OBJ/cert_user_key_${ktype}.pub" | ||
61 | echo "$extra_sshd" | ||
62 | ) > $OBJ/sshd_proxy | ||
63 | ${SSH} -2i $OBJ/cert_user_key_${ktype} \ | ||
64 | -F $OBJ/ssh_proxy somehost true >/dev/null 2>&1 | ||
65 | if [ $? -eq 0 ]; then | ||
66 | fail "ssh cert connect succeeded unexpecedly" | ||
67 | fi | ||
68 | done | ||
69 | |||
70 | # Revoked CA | ||
71 | verbose "$tid: ${ktype} $auth revoked CA key" | ||
72 | ( | ||
73 | cat $OBJ/sshd_proxy_bak | ||
74 | echo "RevokedKeys $OBJ/user_ca_key.pub" | ||
75 | echo "$extra_sshd" | ||
76 | ) > $OBJ/sshd_proxy | ||
77 | ${SSH} -2i $OBJ/cert_user_key_${ktype} -F $OBJ/ssh_proxy \ | ||
78 | somehost true >/dev/null 2>&1 | ||
79 | if [ $? -eq 0 ]; then | ||
80 | fail "ssh cert connect succeeded unexpecedly" | ||
81 | fi | ||
82 | done | ||
83 | |||
84 | verbose "$tid: $auth CA does not authenticate" | ||
85 | ( | ||
86 | cat $OBJ/sshd_proxy_bak | ||
87 | echo "$extra_sshd" | ||
88 | ) > $OBJ/sshd_proxy | ||
89 | verbose "$tid: ensure CA key does not authenticate user" | ||
90 | ${SSH} -2i $OBJ/user_ca_key \ | ||
91 | -F $OBJ/ssh_proxy somehost true >/dev/null 2>&1 | ||
92 | if [ $? -eq 0 ]; then | ||
93 | fail "ssh cert connect with CA key succeeded unexpectedly" | ||
94 | fi | ||
95 | } | ||
96 | |||
97 | basic_tests authorized_keys | ||
98 | basic_tests TrustedUserCAKeys | ||
99 | |||
100 | test_one() { | ||
101 | ident=$1 | ||
102 | result=$2 | ||
103 | sign_opts=$3 | ||
104 | auth_choice=$4 | ||
105 | |||
106 | if test "x$auth_choice" = "x" ; then | ||
107 | auth_choice="authorized_keys TrustedUserCAKeys" | ||
108 | fi | ||
109 | |||
110 | for auth in $auth_choice ; do | ||
111 | cat $OBJ/sshd_proxy_bak > $OBJ/sshd_proxy | ||
112 | if test "x$auth" = "xauthorized_keys" ; then | ||
113 | # Add CA to authorized_keys | ||
114 | ( | ||
115 | echon 'cert-authority ' | ||
116 | cat $OBJ/user_ca_key.pub | ||
117 | ) > $OBJ/authorized_keys_$USER | ||
118 | else | ||
119 | echo > $OBJ/authorized_keys_$USER | ||
120 | echo "TrustedUserCAKeys $OBJ/user_ca_key.pub" >> \ | ||
121 | $OBJ/sshd_proxy | ||
122 | |||
123 | fi | ||
124 | |||
125 | verbose "$tid: $ident auth $auth expect $result" | ||
126 | ${SSHKEYGEN} -q -s $OBJ/user_ca_key \ | ||
127 | -I "regress user key for $USER" \ | ||
128 | $sign_opts \ | ||
129 | $OBJ/cert_user_key_rsa || | ||
130 | fail "couldn't sign cert_user_key_rsa" | ||
131 | |||
132 | ${SSH} -2i $OBJ/cert_user_key_rsa -F $OBJ/ssh_proxy \ | ||
133 | somehost true >/dev/null 2>&1 | ||
134 | rc=$? | ||
135 | if [ "x$result" = "xsuccess" ] ; then | ||
136 | if [ $rc -ne 0 ]; then | ||
137 | fail "$ident failed unexpectedly" | ||
138 | fi | ||
139 | else | ||
140 | if [ $rc -eq 0 ]; then | ||
141 | fail "$ident succeeded unexpectedly" | ||
142 | fi | ||
143 | fi | ||
144 | done | ||
145 | } | ||
146 | |||
147 | test_one "correct principal" success "-n ${USER}" | ||
148 | test_one "host-certificate" failure "-n ${USER} -h" | ||
149 | test_one "wrong principals" failure "-n foo" | ||
150 | test_one "cert not yet valid" failure "-n ${USER} -V20200101:20300101" | ||
151 | test_one "cert expired" failure "-n ${USER} -V19800101:19900101" | ||
152 | test_one "cert valid interval" success "-n ${USER} -V-1w:+2w" | ||
153 | test_one "wrong source-address" failure "-n ${USER} -Osource-address=10.0.0.0/8" | ||
154 | test_one "force-command" failure "-n ${USER} -Oforce-command=false" | ||
155 | |||
156 | # Behaviour is different here: TrustedUserCAKeys doesn't allow empty principals | ||
157 | test_one "empty principals" success "" authorized_keys | ||
158 | test_one "empty principals" failure "" TrustedUserCAKeys | ||
159 | |||
160 | # Wrong certificate | ||
161 | for ktype in rsa dsa ; do | ||
162 | # Self-sign | ||
163 | ${SSHKEYGEN} -q -s $OBJ/cert_user_key_${ktype} -I \ | ||
164 | "regress user key for $USER" \ | ||
165 | -n $USER $OBJ/cert_user_key_${ktype} || | ||
166 | fail "couldn't sign cert_user_key_${ktype}" | ||
167 | verbose "$tid: user ${ktype} connect wrong cert" | ||
168 | ${SSH} -2i $OBJ/cert_user_key_${ktype} -F $OBJ/ssh_proxy \ | ||
169 | somehost true >/dev/null 2>&1 | ||
170 | if [ $? -eq 0 ]; then | ||
171 | fail "ssh cert connect $ident succeeded unexpectedly" | ||
172 | fi | ||
173 | done | ||
174 | |||
175 | rm -f $OBJ/authorized_keys_$USER $OBJ/user_ca_key* $OBJ/cert_user_key* | ||
176 | |||
diff --git a/regress/cfgmatch.sh b/regress/cfgmatch.sh index 35c5e52a1..96badd51b 100644 --- a/regress/cfgmatch.sh +++ b/regress/cfgmatch.sh | |||
@@ -57,9 +57,9 @@ for p in 1 2; do | |||
57 | done | 57 | done |
58 | 58 | ||
59 | # Retry previous with key option, should also be denied. | 59 | # Retry previous with key option, should also be denied. |
60 | echo -n 'permitopen="127.0.0.1:'$PORT'" ' >$OBJ/authorized_keys_$USER | 60 | echon 'permitopen="127.0.0.1:'$PORT'" ' >$OBJ/authorized_keys_$USER |
61 | cat $OBJ/rsa.pub >> $OBJ/authorized_keys_$USER | 61 | cat $OBJ/rsa.pub >> $OBJ/authorized_keys_$USER |
62 | echo -n 'permitopen="127.0.0.1:'$PORT'" ' >>$OBJ/authorized_keys_$USER | 62 | echon 'permitopen="127.0.0.1:'$PORT'" ' >>$OBJ/authorized_keys_$USER |
63 | cat $OBJ/rsa1.pub >> $OBJ/authorized_keys_$USER | 63 | cat $OBJ/rsa1.pub >> $OBJ/authorized_keys_$USER |
64 | for p in 1 2; do | 64 | for p in 1 2; do |
65 | rm -f $pidfile | 65 | rm -f $pidfile |
diff --git a/regress/cipher-speed.sh b/regress/cipher-speed.sh index d39a829d4..85de6d585 100644 --- a/regress/cipher-speed.sh +++ b/regress/cipher-speed.sh | |||
@@ -19,7 +19,7 @@ ciphers="aes128-cbc 3des-cbc blowfish-cbc cast128-cbc | |||
19 | for c in $ciphers; do for m in $macs; do | 19 | for c in $ciphers; do for m in $macs; do |
20 | trace "proto 2 cipher $c mac $m" | 20 | trace "proto 2 cipher $c mac $m" |
21 | for x in $tries; do | 21 | for x in $tries; do |
22 | echo -n "$c/$m:\t" | 22 | echon "$c/$m:\t" |
23 | ( ${SSH} -o 'compression no' \ | 23 | ( ${SSH} -o 'compression no' \ |
24 | -F $OBJ/ssh_proxy -2 -m $m -c $c somehost \ | 24 | -F $OBJ/ssh_proxy -2 -m $m -c $c somehost \ |
25 | exec sh -c \'"dd of=/dev/null obs=32k"\' \ | 25 | exec sh -c \'"dd of=/dev/null obs=32k"\' \ |
@@ -35,7 +35,7 @@ ciphers="3des blowfish" | |||
35 | for c in $ciphers; do | 35 | for c in $ciphers; do |
36 | trace "proto 1 cipher $c" | 36 | trace "proto 1 cipher $c" |
37 | for x in $tries; do | 37 | for x in $tries; do |
38 | echo -n "$c:\t" | 38 | echon "$c:\t" |
39 | ( ${SSH} -o 'compression no' \ | 39 | ( ${SSH} -o 'compression no' \ |
40 | -F $OBJ/ssh_proxy -1 -c $c somehost \ | 40 | -F $OBJ/ssh_proxy -1 -c $c somehost \ |
41 | exec sh -c \'"dd of=/dev/null obs=32k"\' \ | 41 | exec sh -c \'"dd of=/dev/null obs=32k"\' \ |
diff --git a/regress/forwarding.sh b/regress/forwarding.sh index 9ffbb3dd4..6dec991a6 100644 --- a/regress/forwarding.sh +++ b/regress/forwarding.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: forwarding.sh,v 1.6 2006/07/11 18:51:21 markus Exp $ | 1 | # $OpenBSD: forwarding.sh,v 1.7 2010/01/11 02:53:44 dtucker Exp $ |
2 | # Placed in the Public Domain. | 2 | # Placed in the Public Domain. |
3 | 3 | ||
4 | tid="local and remote forwarding" | 4 | tid="local and remote forwarding" |
@@ -93,3 +93,13 @@ for p in 1 2; do | |||
93 | fi | 93 | fi |
94 | sleep 10 | 94 | sleep 10 |
95 | done | 95 | done |
96 | |||
97 | for p in 2; do | ||
98 | trace "stdio forwarding proto $p" | ||
99 | cmd="${SSH} -$p -F $OBJ/ssh_config" | ||
100 | $cmd -o "ProxyCommand $cmd -q -W localhost:$PORT somehost" \ | ||
101 | somehost true | ||
102 | if [ $? != 0 ]; then | ||
103 | fail "stdio forwarding proto $p" | ||
104 | fi | ||
105 | done | ||
diff --git a/regress/keygen-convert.sh b/regress/keygen-convert.sh new file mode 100644 index 000000000..ad0e9c637 --- /dev/null +++ b/regress/keygen-convert.sh | |||
@@ -0,0 +1,33 @@ | |||
1 | # $OpenBSD: keygen-convert.sh,v 1.1 2009/11/09 04:20:04 dtucker Exp $ | ||
2 | # Placed in the Public Domain. | ||
3 | |||
4 | tid="convert keys" | ||
5 | |||
6 | for t in rsa dsa; do | ||
7 | # generate user key for agent | ||
8 | trace "generating $t key" | ||
9 | rm -f $OBJ/$t-key | ||
10 | ${SSHKEYGEN} -q -N "" -t $t -f $OBJ/$t-key | ||
11 | |||
12 | trace "export $t private to rfc4716 public" | ||
13 | ${SSHKEYGEN} -q -e -f $OBJ/$t-key >$OBJ/$t-key-rfc || \ | ||
14 | fail "export $t private to rfc4716 public" | ||
15 | |||
16 | trace "export $t public to rfc4716 public" | ||
17 | ${SSHKEYGEN} -q -e -f $OBJ/$t-key.pub >$OBJ/$t-key-rfc.pub || \ | ||
18 | fail "$t public to rfc4716 public" | ||
19 | |||
20 | cmp $OBJ/$t-key-rfc $OBJ/$t-key-rfc.pub || \ | ||
21 | fail "$t rfc4716 exports differ between public and private" | ||
22 | |||
23 | trace "import $t rfc4716 public" | ||
24 | ${SSHKEYGEN} -q -i -f $OBJ/$t-key-rfc >$OBJ/$t-rfc-imported || \ | ||
25 | fail "$t import rfc4716 public" | ||
26 | |||
27 | cut -f1,2 -d " " $OBJ/$t-key.pub >$OBJ/$t-key-nocomment.pub | ||
28 | cmp $OBJ/$t-key-nocomment.pub $OBJ/$t-rfc-imported || \ | ||
29 | fail "$t imported differs from original" | ||
30 | |||
31 | rm -f $OBJ/$t-key $OBJ/$t-key.pub $OBJ/$t-key-rfc $OBJ/$t-key-rfc.pub \ | ||
32 | $OBJ/$t-rfc-imported $OBJ/$t-key-nocomment.pub | ||
33 | done | ||
diff --git a/regress/multiplex.sh b/regress/multiplex.sh index 4fba7b5ac..8a98a6e54 100644 --- a/regress/multiplex.sh +++ b/regress/multiplex.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: multiplex.sh,v 1.11 2005/04/25 09:54:09 dtucker Exp $ | 1 | # $OpenBSD: multiplex.sh,v 1.12 2009/05/05 07:51:36 dtucker Exp $ |
2 | # Placed in the Public Domain. | 2 | # Placed in the Public Domain. |
3 | 3 | ||
4 | CTL=/tmp/openssh.regress.ctl-sock.$$ | 4 | CTL=/tmp/openssh.regress.ctl-sock.$$ |
@@ -26,7 +26,7 @@ sleep 5 | |||
26 | 26 | ||
27 | verbose "test $tid: envpass" | 27 | verbose "test $tid: envpass" |
28 | trace "env passing over multiplexed connection" | 28 | trace "env passing over multiplexed connection" |
29 | _XXX_TEST=blah ${SSH} -oSendEnv="_XXX_TEST" -S$CTL otherhost sh << 'EOF' | 29 | _XXX_TEST=blah ${SSH} -F $OBJ/ssh_config -oSendEnv="_XXX_TEST" -S$CTL otherhost sh << 'EOF' |
30 | test X"$_XXX_TEST" = X"blah" | 30 | test X"$_XXX_TEST" = X"blah" |
31 | EOF | 31 | EOF |
32 | if [ $? -ne 0 ]; then | 32 | if [ $? -ne 0 ]; then |
@@ -36,26 +36,26 @@ fi | |||
36 | verbose "test $tid: transfer" | 36 | verbose "test $tid: transfer" |
37 | rm -f ${COPY} | 37 | rm -f ${COPY} |
38 | trace "ssh transfer over multiplexed connection and check result" | 38 | trace "ssh transfer over multiplexed connection and check result" |
39 | ${SSH} -S$CTL otherhost cat ${DATA} > ${COPY} | 39 | ${SSH} -F $OBJ/ssh_config -S$CTL otherhost cat ${DATA} > ${COPY} |
40 | test -f ${COPY} || fail "ssh -Sctl: failed copy ${DATA}" | 40 | test -f ${COPY} || fail "ssh -Sctl: failed copy ${DATA}" |
41 | cmp ${DATA} ${COPY} || fail "ssh -Sctl: corrupted copy of ${DATA}" | 41 | cmp ${DATA} ${COPY} || fail "ssh -Sctl: corrupted copy of ${DATA}" |
42 | 42 | ||
43 | rm -f ${COPY} | 43 | rm -f ${COPY} |
44 | trace "ssh transfer over multiplexed connection and check result" | 44 | trace "ssh transfer over multiplexed connection and check result" |
45 | ${SSH} -S $CTL otherhost cat ${DATA} > ${COPY} | 45 | ${SSH} -F $OBJ/ssh_config -S $CTL otherhost cat ${DATA} > ${COPY} |
46 | test -f ${COPY} || fail "ssh -S ctl: failed copy ${DATA}" | 46 | test -f ${COPY} || fail "ssh -S ctl: failed copy ${DATA}" |
47 | cmp ${DATA} ${COPY} || fail "ssh -S ctl: corrupted copy of ${DATA}" | 47 | cmp ${DATA} ${COPY} || fail "ssh -S ctl: corrupted copy of ${DATA}" |
48 | 48 | ||
49 | rm -f ${COPY} | 49 | rm -f ${COPY} |
50 | trace "sftp transfer over multiplexed connection and check result" | 50 | trace "sftp transfer over multiplexed connection and check result" |
51 | echo "get ${DATA} ${COPY}" | \ | 51 | echo "get ${DATA} ${COPY}" | \ |
52 | ${SFTP} -S ${SSH} -oControlPath=$CTL otherhost >$LOG 2>&1 | 52 | ${SFTP} -S ${SSH} -F $OBJ/ssh_config -oControlPath=$CTL otherhost >$LOG 2>&1 |
53 | test -f ${COPY} || fail "sftp: failed copy ${DATA}" | 53 | test -f ${COPY} || fail "sftp: failed copy ${DATA}" |
54 | cmp ${DATA} ${COPY} || fail "sftp: corrupted copy of ${DATA}" | 54 | cmp ${DATA} ${COPY} || fail "sftp: corrupted copy of ${DATA}" |
55 | 55 | ||
56 | rm -f ${COPY} | 56 | rm -f ${COPY} |
57 | trace "scp transfer over multiplexed connection and check result" | 57 | trace "scp transfer over multiplexed connection and check result" |
58 | ${SCP} -S ${SSH} -oControlPath=$CTL otherhost:${DATA} ${COPY} >$LOG 2>&1 | 58 | ${SCP} -S ${SSH} -F $OBJ/ssh_config -oControlPath=$CTL otherhost:${DATA} ${COPY} >$LOG 2>&1 |
59 | test -f ${COPY} || fail "scp: failed copy ${DATA}" | 59 | test -f ${COPY} || fail "scp: failed copy ${DATA}" |
60 | cmp ${DATA} ${COPY} || fail "scp: corrupted copy of ${DATA}" | 60 | cmp ${DATA} ${COPY} || fail "scp: corrupted copy of ${DATA}" |
61 | 61 | ||
@@ -64,7 +64,7 @@ rm -f ${COPY} | |||
64 | for s in 0 1 4 5 44; do | 64 | for s in 0 1 4 5 44; do |
65 | trace "exit status $s over multiplexed connection" | 65 | trace "exit status $s over multiplexed connection" |
66 | verbose "test $tid: status $s" | 66 | verbose "test $tid: status $s" |
67 | ${SSH} -S $CTL otherhost exit $s | 67 | ${SSH} -F $OBJ/ssh_config -S $CTL otherhost exit $s |
68 | r=$? | 68 | r=$? |
69 | if [ $r -ne $s ]; then | 69 | if [ $r -ne $s ]; then |
70 | fail "exit code mismatch for protocol $p: $r != $s" | 70 | fail "exit code mismatch for protocol $p: $r != $s" |
@@ -72,7 +72,7 @@ for s in 0 1 4 5 44; do | |||
72 | 72 | ||
73 | # same with early close of stdout/err | 73 | # same with early close of stdout/err |
74 | trace "exit status $s with early close over multiplexed connection" | 74 | trace "exit status $s with early close over multiplexed connection" |
75 | ${SSH} -S $CTL -n otherhost \ | 75 | ${SSH} -F $OBJ/ssh_config -S $CTL -n otherhost \ |
76 | exec sh -c \'"sleep 2; exec > /dev/null 2>&1; sleep 3; exit $s"\' | 76 | exec sh -c \'"sleep 2; exec > /dev/null 2>&1; sleep 3; exit $s"\' |
77 | r=$? | 77 | r=$? |
78 | if [ $r -ne $s ]; then | 78 | if [ $r -ne $s ]; then |
@@ -81,10 +81,10 @@ for s in 0 1 4 5 44; do | |||
81 | done | 81 | done |
82 | 82 | ||
83 | trace "test check command" | 83 | trace "test check command" |
84 | ${SSH} -S $CTL -Ocheck otherhost || fail "check command failed" | 84 | ${SSH} -F $OBJ/ssh_config -S $CTL -Ocheck otherhost || fail "check command failed" |
85 | 85 | ||
86 | trace "test exit command" | 86 | trace "test exit command" |
87 | ${SSH} -S $CTL -Oexit otherhost || fail "send exit command failed" | 87 | ${SSH} -F $OBJ/ssh_config -S $CTL -Oexit otherhost || fail "send exit command failed" |
88 | 88 | ||
89 | # Wait for master to exit | 89 | # Wait for master to exit |
90 | sleep 2 | 90 | sleep 2 |
diff --git a/regress/portnum.sh b/regress/portnum.sh new file mode 100644 index 000000000..1de0680fe --- /dev/null +++ b/regress/portnum.sh | |||
@@ -0,0 +1,34 @@ | |||
1 | # $OpenBSD: portnum.sh,v 1.1 2009/08/13 00:57:17 djm Exp $ | ||
2 | # Placed in the Public Domain. | ||
3 | |||
4 | tid="port number parsing" | ||
5 | |||
6 | badport() { | ||
7 | port=$1 | ||
8 | verbose "$tid: invalid port $port" | ||
9 | if ${SSH} -F $OBJ/ssh_proxy -p $port somehost true 2>/dev/null ; then | ||
10 | fail "$tid accepted invalid port $port" | ||
11 | fi | ||
12 | } | ||
13 | goodport() { | ||
14 | port=$1 | ||
15 | verbose "$tid: valid port $port" | ||
16 | if ${SSH} -F $OBJ/ssh_proxy -p $port somehost true 2>/dev/null ; then | ||
17 | : | ||
18 | else | ||
19 | fail "$tid rejected valid port $port" | ||
20 | fi | ||
21 | } | ||
22 | |||
23 | badport 0 | ||
24 | badport 65536 | ||
25 | badport 131073 | ||
26 | badport 2000blah | ||
27 | badport blah2000 | ||
28 | |||
29 | goodport 1 | ||
30 | goodport 22 | ||
31 | goodport 2222 | ||
32 | goodport 22222 | ||
33 | goodport 65535 | ||
34 | |||
diff --git a/regress/sftp-badcmds.sh b/regress/sftp-badcmds.sh index b48b1cb01..08009f26b 100644 --- a/regress/sftp-badcmds.sh +++ b/regress/sftp-badcmds.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: sftp-badcmds.sh,v 1.3 2008/03/24 21:46:54 djm Exp $ | 1 | # $OpenBSD: sftp-badcmds.sh,v 1.4 2009/08/13 01:11:55 djm Exp $ |
2 | # Placed in the Public Domain. | 2 | # Placed in the Public Domain. |
3 | 3 | ||
4 | tid="sftp invalid commands" | 4 | tid="sftp invalid commands" |
@@ -13,13 +13,13 @@ rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd | |||
13 | 13 | ||
14 | rm -f ${COPY} | 14 | rm -f ${COPY} |
15 | verbose "$tid: get nonexistent" | 15 | verbose "$tid: get nonexistent" |
16 | echo "get $NONEXIST $COPY" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 16 | echo "get $NONEXIST $COPY" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
17 | || fail "get nonexistent failed" | 17 | || fail "get nonexistent failed" |
18 | test -f ${COPY} && fail "existing copy after get nonexistent" | 18 | test -f ${COPY} && fail "existing copy after get nonexistent" |
19 | 19 | ||
20 | rm -f ${COPY}.dd/* | 20 | rm -f ${COPY}.dd/* |
21 | verbose "$tid: glob get to nonexistent directory" | 21 | verbose "$tid: glob get to nonexistent directory" |
22 | echo "get /bin/l* $NONEXIST" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 22 | echo "get /bin/l* $NONEXIST" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
23 | || fail "get nonexistent failed" | 23 | || fail "get nonexistent failed" |
24 | for x in $GLOBFILES; do | 24 | for x in $GLOBFILES; do |
25 | test -f ${COPY}.dd/$x && fail "existing copy after get nonexistent" | 25 | test -f ${COPY}.dd/$x && fail "existing copy after get nonexistent" |
@@ -27,13 +27,13 @@ done | |||
27 | 27 | ||
28 | rm -f ${COPY} | 28 | rm -f ${COPY} |
29 | verbose "$tid: put nonexistent" | 29 | verbose "$tid: put nonexistent" |
30 | echo "put $NONEXIST $COPY" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 30 | echo "put $NONEXIST $COPY" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
31 | || fail "put nonexistent failed" | 31 | || fail "put nonexistent failed" |
32 | test -f ${COPY} && fail "existing copy after put nonexistent" | 32 | test -f ${COPY} && fail "existing copy after put nonexistent" |
33 | 33 | ||
34 | rm -f ${COPY}.dd/* | 34 | rm -f ${COPY}.dd/* |
35 | verbose "$tid: glob put to nonexistent directory" | 35 | verbose "$tid: glob put to nonexistent directory" |
36 | echo "put /bin/l* ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 36 | echo "put /bin/l* ${COPY}.dd" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
37 | || fail "put nonexistent failed" | 37 | || fail "put nonexistent failed" |
38 | for x in $GLOBFILES; do | 38 | for x in $GLOBFILES; do |
39 | test -f ${COPY}.dd/$x && fail "existing copy after nonexistent" | 39 | test -f ${COPY}.dd/$x && fail "existing copy after nonexistent" |
@@ -41,7 +41,7 @@ done | |||
41 | 41 | ||
42 | rm -f ${COPY} | 42 | rm -f ${COPY} |
43 | verbose "$tid: rename nonexistent" | 43 | verbose "$tid: rename nonexistent" |
44 | echo "rename $NONEXIST ${COPY}.1" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 44 | echo "rename $NONEXIST ${COPY}.1" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
45 | || fail "rename nonexist failed" | 45 | || fail "rename nonexist failed" |
46 | test -f ${COPY}.1 && fail "file exists after rename nonexistent" | 46 | test -f ${COPY}.1 && fail "file exists after rename nonexistent" |
47 | 47 | ||
@@ -49,7 +49,7 @@ rm -rf ${COPY} ${COPY}.dd | |||
49 | cp $DATA $COPY | 49 | cp $DATA $COPY |
50 | mkdir ${COPY}.dd | 50 | mkdir ${COPY}.dd |
51 | verbose "$tid: rename target exists (directory)" | 51 | verbose "$tid: rename target exists (directory)" |
52 | echo "rename $COPY ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 52 | echo "rename $COPY ${COPY}.dd" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
53 | || fail "rename target exists (directory) failed" | 53 | || fail "rename target exists (directory) failed" |
54 | test -f ${COPY} || fail "oldname missing after rename target exists (directory)" | 54 | test -f ${COPY} || fail "oldname missing after rename target exists (directory)" |
55 | test -d ${COPY}.dd || fail "newname missing after rename target exists (directory)" | 55 | test -d ${COPY}.dd || fail "newname missing after rename target exists (directory)" |
@@ -59,7 +59,7 @@ rm -f ${COPY}.dd/* | |||
59 | rm -rf ${COPY} | 59 | rm -rf ${COPY} |
60 | cp ${DATA2} ${COPY} | 60 | cp ${DATA2} ${COPY} |
61 | verbose "$tid: glob put files to local file" | 61 | verbose "$tid: glob put files to local file" |
62 | echo "put /bin/l* $COPY" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 | 62 | echo "put /bin/l* $COPY" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 |
63 | cmp ${DATA2} ${COPY} || fail "put successed when it should have failed" | 63 | cmp ${DATA2} ${COPY} || fail "put successed when it should have failed" |
64 | 64 | ||
65 | rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd | 65 | rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd |
diff --git a/regress/sftp-batch.sh b/regress/sftp-batch.sh index 365c47cfc..a51ef0782 100644 --- a/regress/sftp-batch.sh +++ b/regress/sftp-batch.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: sftp-batch.sh,v 1.3 2004/01/13 09:49:06 djm Exp $ | 1 | # $OpenBSD: sftp-batch.sh,v 1.4 2009/08/13 01:11:55 djm Exp $ |
2 | # Placed in the Public Domain. | 2 | # Placed in the Public Domain. |
3 | 3 | ||
4 | tid="sftp batchfile" | 4 | tid="sftp batchfile" |
@@ -37,19 +37,19 @@ cat << EOF > ${BATCH}.fail.2 | |||
37 | EOF | 37 | EOF |
38 | 38 | ||
39 | verbose "$tid: good commands" | 39 | verbose "$tid: good commands" |
40 | ${SFTP} -b ${BATCH}.pass.1 -P ${SFTPSERVER} >/dev/null 2>&1 \ | 40 | ${SFTP} -b ${BATCH}.pass.1 -D ${SFTPSERVER} >/dev/null 2>&1 \ |
41 | || fail "good commands failed" | 41 | || fail "good commands failed" |
42 | 42 | ||
43 | verbose "$tid: bad commands" | 43 | verbose "$tid: bad commands" |
44 | ${SFTP} -b ${BATCH}.fail.1 -P ${SFTPSERVER} >/dev/null 2>&1 \ | 44 | ${SFTP} -b ${BATCH}.fail.1 -D ${SFTPSERVER} >/dev/null 2>&1 \ |
45 | && fail "bad commands succeeded" | 45 | && fail "bad commands succeeded" |
46 | 46 | ||
47 | verbose "$tid: comments and blanks" | 47 | verbose "$tid: comments and blanks" |
48 | ${SFTP} -b ${BATCH}.pass.2 -P ${SFTPSERVER} >/dev/null 2>&1 \ | 48 | ${SFTP} -b ${BATCH}.pass.2 -D ${SFTPSERVER} >/dev/null 2>&1 \ |
49 | || fail "comments & blanks failed" | 49 | || fail "comments & blanks failed" |
50 | 50 | ||
51 | verbose "$tid: junk command" | 51 | verbose "$tid: junk command" |
52 | ${SFTP} -b ${BATCH}.fail.2 -P ${SFTPSERVER} >/dev/null 2>&1 \ | 52 | ${SFTP} -b ${BATCH}.fail.2 -D ${SFTPSERVER} >/dev/null 2>&1 \ |
53 | && fail "junk command succeeded" | 53 | && fail "junk command succeeded" |
54 | 54 | ||
55 | rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${BATCH}.* | 55 | rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${BATCH}.* |
diff --git a/regress/sftp-cmds.sh b/regress/sftp-cmds.sh index 3b453c5e8..c4d6ae2de 100644 --- a/regress/sftp-cmds.sh +++ b/regress/sftp-cmds.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: sftp-cmds.sh,v 1.9 2007/12/12 05:04:03 djm Exp $ | 1 | # $OpenBSD: sftp-cmds.sh,v 1.10 2009/08/13 01:11:55 djm Exp $ |
2 | # Placed in the Public Domain. | 2 | # Placed in the Public Domain. |
3 | 3 | ||
4 | # XXX - TODO: | 4 | # XXX - TODO: |
@@ -40,56 +40,56 @@ SPACECOPY_ARG="${COPY}\ this\ has\ spaces.txt" | |||
40 | # File with glob metacharacters | 40 | # File with glob metacharacters |
41 | GLOBMETACOPY="${COPY} [metachar].txt" | 41 | GLOBMETACOPY="${COPY} [metachar].txt" |
42 | 42 | ||
43 | rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${COPY}.dd2 | 43 | rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${COPY}.dd2 ${BATCH}.* |
44 | mkdir ${COPY}.dd | 44 | mkdir ${COPY}.dd |
45 | 45 | ||
46 | verbose "$tid: lls" | 46 | verbose "$tid: lls" |
47 | (echo "lcd ${OBJ}" ; echo "lls") | ${SFTP} -P ${SFTPSERVER} 2>&1 | \ | 47 | (echo "lcd ${OBJ}" ; echo "lls") | ${SFTP} -D ${SFTPSERVER} 2>&1 | \ |
48 | grep copy.dd >/dev/null 2>&1 || fail "lls failed" | 48 | grep copy.dd >/dev/null 2>&1 || fail "lls failed" |
49 | 49 | ||
50 | verbose "$tid: lls w/path" | 50 | verbose "$tid: lls w/path" |
51 | echo "lls ${OBJ}" | ${SFTP} -P ${SFTPSERVER} 2>&1 | \ | 51 | echo "lls ${OBJ}" | ${SFTP} -D ${SFTPSERVER} 2>&1 | \ |
52 | grep copy.dd >/dev/null 2>&1 || fail "lls w/path failed" | 52 | grep copy.dd >/dev/null 2>&1 || fail "lls w/path failed" |
53 | 53 | ||
54 | verbose "$tid: ls" | 54 | verbose "$tid: ls" |
55 | echo "ls ${OBJ}" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 55 | echo "ls ${OBJ}" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
56 | || fail "ls failed" | 56 | || fail "ls failed" |
57 | # XXX always successful | 57 | # XXX always successful |
58 | 58 | ||
59 | verbose "$tid: shell" | 59 | verbose "$tid: shell" |
60 | echo "!echo hi there" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 60 | echo "!echo hi there" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
61 | || fail "shell failed" | 61 | || fail "shell failed" |
62 | # XXX always successful | 62 | # XXX always successful |
63 | 63 | ||
64 | verbose "$tid: pwd" | 64 | verbose "$tid: pwd" |
65 | echo "pwd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 65 | echo "pwd" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
66 | || fail "pwd failed" | 66 | || fail "pwd failed" |
67 | # XXX always successful | 67 | # XXX always successful |
68 | 68 | ||
69 | verbose "$tid: lpwd" | 69 | verbose "$tid: lpwd" |
70 | echo "lpwd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 70 | echo "lpwd" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
71 | || fail "lpwd failed" | 71 | || fail "lpwd failed" |
72 | # XXX always successful | 72 | # XXX always successful |
73 | 73 | ||
74 | verbose "$tid: quit" | 74 | verbose "$tid: quit" |
75 | echo "quit" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 75 | echo "quit" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
76 | || fail "quit failed" | 76 | || fail "quit failed" |
77 | # XXX always successful | 77 | # XXX always successful |
78 | 78 | ||
79 | verbose "$tid: help" | 79 | verbose "$tid: help" |
80 | echo "help" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 80 | echo "help" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
81 | || fail "help failed" | 81 | || fail "help failed" |
82 | # XXX always successful | 82 | # XXX always successful |
83 | 83 | ||
84 | rm -f ${COPY} | 84 | rm -f ${COPY} |
85 | verbose "$tid: get" | 85 | verbose "$tid: get" |
86 | echo "get $DATA $COPY" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 86 | echo "get $DATA $COPY" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
87 | || fail "get failed" | 87 | || fail "get failed" |
88 | cmp $DATA ${COPY} || fail "corrupted copy after get" | 88 | cmp $DATA ${COPY} || fail "corrupted copy after get" |
89 | 89 | ||
90 | rm -f ${COPY} | 90 | rm -f ${COPY} |
91 | verbose "$tid: get quoted" | 91 | verbose "$tid: get quoted" |
92 | echo "get \"$DATA\" $COPY" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 92 | echo "get \"$DATA\" $COPY" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
93 | || fail "get failed" | 93 | || fail "get failed" |
94 | cmp $DATA ${COPY} || fail "corrupted copy after get" | 94 | cmp $DATA ${COPY} || fail "corrupted copy after get" |
95 | 95 | ||
@@ -97,8 +97,8 @@ if [ "$os" != "cygwin" ]; then | |||
97 | rm -f ${QUOTECOPY} | 97 | rm -f ${QUOTECOPY} |
98 | cp $DATA ${QUOTECOPY} | 98 | cp $DATA ${QUOTECOPY} |
99 | verbose "$tid: get filename with quotes" | 99 | verbose "$tid: get filename with quotes" |
100 | echo "get \"$QUOTECOPY_ARG\" ${COPY}" | \ | 100 | echo "get \"$QUOTECOPY_ARG\" ${COPY}" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
101 | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ || fail "get failed" | 101 | || fail "get failed" |
102 | cmp ${COPY} ${QUOTECOPY} || fail "corrupted copy after get with quotes" | 102 | cmp ${COPY} ${QUOTECOPY} || fail "corrupted copy after get with quotes" |
103 | rm -f ${QUOTECOPY} ${COPY} | 103 | rm -f ${QUOTECOPY} ${COPY} |
104 | fi | 104 | fi |
@@ -106,7 +106,7 @@ fi | |||
106 | rm -f "$SPACECOPY" ${COPY} | 106 | rm -f "$SPACECOPY" ${COPY} |
107 | cp $DATA "$SPACECOPY" | 107 | cp $DATA "$SPACECOPY" |
108 | verbose "$tid: get filename with spaces" | 108 | verbose "$tid: get filename with spaces" |
109 | echo "get ${SPACECOPY_ARG} ${COPY}" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 109 | echo "get ${SPACECOPY_ARG} ${COPY}" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
110 | || fail "get failed" | 110 | || fail "get failed" |
111 | cmp ${COPY} "$SPACECOPY" || fail "corrupted copy after get with spaces" | 111 | cmp ${COPY} "$SPACECOPY" || fail "corrupted copy after get with spaces" |
112 | 112 | ||
@@ -114,19 +114,19 @@ rm -f "$GLOBMETACOPY" ${COPY} | |||
114 | cp $DATA "$GLOBMETACOPY" | 114 | cp $DATA "$GLOBMETACOPY" |
115 | verbose "$tid: get filename with glob metacharacters" | 115 | verbose "$tid: get filename with glob metacharacters" |
116 | echo "get \"${GLOBMETACOPY}\" ${COPY}" | \ | 116 | echo "get \"${GLOBMETACOPY}\" ${COPY}" | \ |
117 | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 || fail "get failed" | 117 | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 || fail "get failed" |
118 | cmp ${COPY} "$GLOBMETACOPY" || \ | 118 | cmp ${COPY} "$GLOBMETACOPY" || \ |
119 | fail "corrupted copy after get with glob metacharacters" | 119 | fail "corrupted copy after get with glob metacharacters" |
120 | 120 | ||
121 | rm -f ${COPY}.dd/* | 121 | rm -f ${COPY}.dd/* |
122 | verbose "$tid: get to directory" | 122 | verbose "$tid: get to directory" |
123 | echo "get $DATA ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 123 | echo "get $DATA ${COPY}.dd" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
124 | || fail "get failed" | 124 | || fail "get failed" |
125 | cmp $DATA ${COPY}.dd/`basename $DATA` || fail "corrupted copy after get" | 125 | cmp $DATA ${COPY}.dd/`basename $DATA` || fail "corrupted copy after get" |
126 | 126 | ||
127 | rm -f ${COPY}.dd/* | 127 | rm -f ${COPY}.dd/* |
128 | verbose "$tid: glob get to directory" | 128 | verbose "$tid: glob get to directory" |
129 | echo "get /bin/l* ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 129 | echo "get /bin/l* ${COPY}.dd" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
130 | || fail "get failed" | 130 | || fail "get failed" |
131 | for x in $GLOBFILES; do | 131 | for x in $GLOBFILES; do |
132 | cmp /bin/$x ${COPY}.dd/$x || fail "corrupted copy after get" | 132 | cmp /bin/$x ${COPY}.dd/$x || fail "corrupted copy after get" |
@@ -134,13 +134,13 @@ done | |||
134 | 134 | ||
135 | rm -f ${COPY}.dd/* | 135 | rm -f ${COPY}.dd/* |
136 | verbose "$tid: get to local dir" | 136 | verbose "$tid: get to local dir" |
137 | (echo "lcd ${COPY}.dd"; echo "get $DATA" ) | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 137 | (echo "lcd ${COPY}.dd"; echo "get $DATA" ) | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
138 | || fail "get failed" | 138 | || fail "get failed" |
139 | cmp $DATA ${COPY}.dd/`basename $DATA` || fail "corrupted copy after get" | 139 | cmp $DATA ${COPY}.dd/`basename $DATA` || fail "corrupted copy after get" |
140 | 140 | ||
141 | rm -f ${COPY}.dd/* | 141 | rm -f ${COPY}.dd/* |
142 | verbose "$tid: glob get to local dir" | 142 | verbose "$tid: glob get to local dir" |
143 | (echo "lcd ${COPY}.dd"; echo "get /bin/l*") | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 143 | (echo "lcd ${COPY}.dd"; echo "get /bin/l*") | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
144 | || fail "get failed" | 144 | || fail "get failed" |
145 | for x in $GLOBFILES; do | 145 | for x in $GLOBFILES; do |
146 | cmp /bin/$x ${COPY}.dd/$x || fail "corrupted copy after get" | 146 | cmp /bin/$x ${COPY}.dd/$x || fail "corrupted copy after get" |
@@ -149,32 +149,32 @@ done | |||
149 | rm -f ${COPY} | 149 | rm -f ${COPY} |
150 | verbose "$tid: put" | 150 | verbose "$tid: put" |
151 | echo "put $DATA $COPY" | \ | 151 | echo "put $DATA $COPY" | \ |
152 | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 || fail "put failed" | 152 | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 || fail "put failed" |
153 | cmp $DATA ${COPY} || fail "corrupted copy after put" | 153 | cmp $DATA ${COPY} || fail "corrupted copy after put" |
154 | 154 | ||
155 | if [ "$os" != "cygwin" ]; then | 155 | if [ "$os" != "cygwin" ]; then |
156 | rm -f ${QUOTECOPY} | 156 | rm -f ${QUOTECOPY} |
157 | verbose "$tid: put filename with quotes" | 157 | verbose "$tid: put filename with quotes" |
158 | echo "put $DATA \"$QUOTECOPY_ARG\"" | \ | 158 | echo "put $DATA \"$QUOTECOPY_ARG\"" | \ |
159 | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 || fail "put failed" | 159 | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 || fail "put failed" |
160 | cmp $DATA ${QUOTECOPY} || fail "corrupted copy after put with quotes" | 160 | cmp $DATA ${QUOTECOPY} || fail "corrupted copy after put with quotes" |
161 | fi | 161 | fi |
162 | 162 | ||
163 | rm -f "$SPACECOPY" | 163 | rm -f "$SPACECOPY" |
164 | verbose "$tid: put filename with spaces" | 164 | verbose "$tid: put filename with spaces" |
165 | echo "put $DATA ${SPACECOPY_ARG}" | \ | 165 | echo "put $DATA ${SPACECOPY_ARG}" | \ |
166 | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 || fail "put failed" | 166 | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 || fail "put failed" |
167 | cmp $DATA "$SPACECOPY" || fail "corrupted copy after put with spaces" | 167 | cmp $DATA "$SPACECOPY" || fail "corrupted copy after put with spaces" |
168 | 168 | ||
169 | rm -f ${COPY}.dd/* | 169 | rm -f ${COPY}.dd/* |
170 | verbose "$tid: put to directory" | 170 | verbose "$tid: put to directory" |
171 | echo "put $DATA ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 171 | echo "put $DATA ${COPY}.dd" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
172 | || fail "put failed" | 172 | || fail "put failed" |
173 | cmp $DATA ${COPY}.dd/`basename $DATA` || fail "corrupted copy after put" | 173 | cmp $DATA ${COPY}.dd/`basename $DATA` || fail "corrupted copy after put" |
174 | 174 | ||
175 | rm -f ${COPY}.dd/* | 175 | rm -f ${COPY}.dd/* |
176 | verbose "$tid: glob put to directory" | 176 | verbose "$tid: glob put to directory" |
177 | echo "put /bin/l? ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 177 | echo "put /bin/l? ${COPY}.dd" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
178 | || fail "put failed" | 178 | || fail "put failed" |
179 | for x in $GLOBFILES; do | 179 | for x in $GLOBFILES; do |
180 | cmp /bin/$x ${COPY}.dd/$x || fail "corrupted copy after put" | 180 | cmp /bin/$x ${COPY}.dd/$x || fail "corrupted copy after put" |
@@ -182,60 +182,61 @@ done | |||
182 | 182 | ||
183 | rm -f ${COPY}.dd/* | 183 | rm -f ${COPY}.dd/* |
184 | verbose "$tid: put to local dir" | 184 | verbose "$tid: put to local dir" |
185 | (echo "cd ${COPY}.dd"; echo "put $DATA") | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 185 | (echo "cd ${COPY}.dd"; echo "put $DATA") | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
186 | || fail "put failed" | 186 | || fail "put failed" |
187 | cmp $DATA ${COPY}.dd/`basename $DATA` || fail "corrupted copy after put" | 187 | cmp $DATA ${COPY}.dd/`basename $DATA` || fail "corrupted copy after put" |
188 | 188 | ||
189 | rm -f ${COPY}.dd/* | 189 | rm -f ${COPY}.dd/* |
190 | verbose "$tid: glob put to local dir" | 190 | verbose "$tid: glob put to local dir" |
191 | (echo "cd ${COPY}.dd"; echo "put /bin/l?") | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 191 | (echo "cd ${COPY}.dd"; echo "put /bin/l?") | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
192 | || fail "put failed" | 192 | || fail "put failed" |
193 | for x in $GLOBFILES; do | 193 | for x in $GLOBFILES; do |
194 | cmp /bin/$x ${COPY}.dd/$x || fail "corrupted copy after put" | 194 | cmp /bin/$x ${COPY}.dd/$x || fail "corrupted copy after put" |
195 | done | 195 | done |
196 | 196 | ||
197 | verbose "$tid: rename" | 197 | verbose "$tid: rename" |
198 | echo "rename $COPY ${COPY}.1" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 198 | echo "rename $COPY ${COPY}.1" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
199 | || fail "rename failed" | 199 | || fail "rename failed" |
200 | test -f ${COPY}.1 || fail "missing file after rename" | 200 | test -f ${COPY}.1 || fail "missing file after rename" |
201 | cmp $DATA ${COPY}.1 >/dev/null 2>&1 || fail "corrupted copy after rename" | 201 | cmp $DATA ${COPY}.1 >/dev/null 2>&1 || fail "corrupted copy after rename" |
202 | 202 | ||
203 | verbose "$tid: rename directory" | 203 | verbose "$tid: rename directory" |
204 | echo "rename ${COPY}.dd ${COPY}.dd2" | \ | 204 | echo "rename ${COPY}.dd ${COPY}.dd2" | \ |
205 | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 || \ | 205 | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 || \ |
206 | fail "rename directory failed" | 206 | fail "rename directory failed" |
207 | test -d ${COPY}.dd && fail "oldname exists after rename directory" | 207 | test -d ${COPY}.dd && fail "oldname exists after rename directory" |
208 | test -d ${COPY}.dd2 || fail "missing newname after rename directory" | 208 | test -d ${COPY}.dd2 || fail "missing newname after rename directory" |
209 | 209 | ||
210 | verbose "$tid: ln" | 210 | verbose "$tid: ln" |
211 | echo "ln ${COPY}.1 ${COPY}.2" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 || fail "ln failed" | 211 | echo "ln ${COPY}.1 ${COPY}.2" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 || fail "ln failed" |
212 | test -h ${COPY}.2 || fail "missing file after ln" | 212 | test -h ${COPY}.2 || fail "missing file after ln" |
213 | 213 | ||
214 | verbose "$tid: mkdir" | 214 | verbose "$tid: mkdir" |
215 | echo "mkdir ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 215 | echo "mkdir ${COPY}.dd" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
216 | || fail "mkdir failed" | 216 | || fail "mkdir failed" |
217 | test -d ${COPY}.dd || fail "missing directory after mkdir" | 217 | test -d ${COPY}.dd || fail "missing directory after mkdir" |
218 | 218 | ||
219 | # XXX do more here | 219 | # XXX do more here |
220 | verbose "$tid: chdir" | 220 | verbose "$tid: chdir" |
221 | echo "chdir ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 221 | echo "chdir ${COPY}.dd" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
222 | || fail "chdir failed" | 222 | || fail "chdir failed" |
223 | 223 | ||
224 | verbose "$tid: rmdir" | 224 | verbose "$tid: rmdir" |
225 | echo "rmdir ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 225 | echo "rmdir ${COPY}.dd" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
226 | || fail "rmdir failed" | 226 | || fail "rmdir failed" |
227 | test -d ${COPY}.1 && fail "present directory after rmdir" | 227 | test -d ${COPY}.1 && fail "present directory after rmdir" |
228 | 228 | ||
229 | verbose "$tid: lmkdir" | 229 | verbose "$tid: lmkdir" |
230 | echo "lmkdir ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 230 | echo "lmkdir ${COPY}.dd" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
231 | || fail "lmkdir failed" | 231 | || fail "lmkdir failed" |
232 | test -d ${COPY}.dd || fail "missing directory after lmkdir" | 232 | test -d ${COPY}.dd || fail "missing directory after lmkdir" |
233 | 233 | ||
234 | # XXX do more here | 234 | # XXX do more here |
235 | verbose "$tid: lchdir" | 235 | verbose "$tid: lchdir" |
236 | echo "lchdir ${COPY}.dd" | ${SFTP} -P ${SFTPSERVER} >/dev/null 2>&1 \ | 236 | echo "lchdir ${COPY}.dd" | ${SFTP} -D ${SFTPSERVER} >/dev/null 2>&1 \ |
237 | || fail "lchdir failed" | 237 | || fail "lchdir failed" |
238 | 238 | ||
239 | rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${COPY}.dd2 | 239 | rm -rf ${COPY} ${COPY}.1 ${COPY}.2 ${COPY}.dd ${COPY}.dd2 ${BATCH}.* |
240 | rm -rf ${QUOTECOPY} "$SPACECOPY" "$GLOBMETACOPY" | 240 | rm -rf ${QUOTECOPY} "$SPACECOPY" "$GLOBMETACOPY" |
241 | 241 | ||
242 | |||
diff --git a/regress/sftp-glob.sh b/regress/sftp-glob.sh index 60116a748..72bb17d75 100644 --- a/regress/sftp-glob.sh +++ b/regress/sftp-glob.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: sftp-glob.sh,v 1.3 2007/10/26 05:30:01 djm Exp $ | 1 | # $OpenBSD: sftp-glob.sh,v 1.4 2009/08/13 01:11:55 djm Exp $ |
2 | # Placed in the Public Domain. | 2 | # Placed in the Public Domain. |
3 | 3 | ||
4 | tid="sftp glob" | 4 | tid="sftp glob" |
@@ -10,7 +10,7 @@ sftp_ls() { | |||
10 | unexpected=$4 | 10 | unexpected=$4 |
11 | verbose "$tid: $errtag" | 11 | verbose "$tid: $errtag" |
12 | printf "ls -l %s" "${target}" | \ | 12 | printf "ls -l %s" "${target}" | \ |
13 | ${SFTP} -b - -P ${SFTPSERVER} 2>/dev/null | \ | 13 | ${SFTP} -b - -D ${SFTPSERVER} 2>/dev/null | \ |
14 | grep -v "^sftp>" > ${RESULTS} | 14 | grep -v "^sftp>" > ${RESULTS} |
15 | if [ $? -ne 0 ]; then | 15 | if [ $? -ne 0 ]; then |
16 | fail "$errtag failed" | 16 | fail "$errtag failed" |
diff --git a/regress/sftp.sh b/regress/sftp.sh index 0e22f8f6b..f84fa6f4e 100644 --- a/regress/sftp.sh +++ b/regress/sftp.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: sftp.sh,v 1.2 2002/03/27 22:39:52 markus Exp $ | 1 | # $OpenBSD: sftp.sh,v 1.3 2009/08/13 01:11:55 djm Exp $ |
2 | # Placed in the Public Domain. | 2 | # Placed in the Public Domain. |
3 | 3 | ||
4 | tid="basic sftp put/get" | 4 | tid="basic sftp put/get" |
@@ -19,8 +19,8 @@ REQUESTS="1 2 10" | |||
19 | for B in ${BUFFERSIZE}; do | 19 | for B in ${BUFFERSIZE}; do |
20 | for R in ${REQUESTS}; do | 20 | for R in ${REQUESTS}; do |
21 | verbose "test $tid: buffer_size $B num_requests $R" | 21 | verbose "test $tid: buffer_size $B num_requests $R" |
22 | rm -f ${COPY}.1 ${COPY}.2 | 22 | rm -f ${COPY}.1 ${COPY}.2 |
23 | ${SFTP} -P ${SFTPSERVER} -B $B -R $R -b $SFTPCMDFILE \ | 23 | ${SFTP} -D ${SFTPSERVER} -B $B -R $R -b $SFTPCMDFILE \ |
24 | > /dev/null 2>&1 | 24 | > /dev/null 2>&1 |
25 | r=$? | 25 | r=$? |
26 | if [ $r -ne 0 ]; then | 26 | if [ $r -ne 0 ]; then |
diff --git a/regress/ssh-com-sftp.sh b/regress/ssh-com-sftp.sh index 936b4cca7..be6f4e0dc 100644 --- a/regress/ssh-com-sftp.sh +++ b/regress/ssh-com-sftp.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: ssh-com-sftp.sh,v 1.5 2004/02/24 17:06:52 markus Exp $ | 1 | # $OpenBSD: ssh-com-sftp.sh,v 1.6 2009/08/20 18:43:07 djm Exp $ |
2 | # Placed in the Public Domain. | 2 | # Placed in the Public Domain. |
3 | 3 | ||
4 | tid="basic sftp put/get with ssh.com server" | 4 | tid="basic sftp put/get with ssh.com server" |
@@ -51,7 +51,7 @@ for v in ${VERSIONS}; do | |||
51 | for R in ${REQUESTS}; do | 51 | for R in ${REQUESTS}; do |
52 | verbose "test $tid: buffer_size $B num_requests $R" | 52 | verbose "test $tid: buffer_size $B num_requests $R" |
53 | rm -f ${COPY}.1 ${COPY}.2 | 53 | rm -f ${COPY}.1 ${COPY}.2 |
54 | ${SFTP} -P ${server} -B $B -R $R -b $SFTPCMDFILE \ | 54 | ${SFTP} -D ${server} -B $B -R $R -b $SFTPCMDFILE \ |
55 | > /dev/null 2>&1 | 55 | > /dev/null 2>&1 |
56 | r=$? | 56 | r=$? |
57 | if [ $r -ne 0 ]; then | 57 | if [ $r -ne 0 ]; then |
diff --git a/regress/ssh2putty.sh b/regress/ssh2putty.sh index dfdeeff4a..691db1690 100755 --- a/regress/ssh2putty.sh +++ b/regress/ssh2putty.sh | |||
@@ -1,4 +1,5 @@ | |||
1 | #!/bin/sh | 1 | #!/bin/sh |
2 | # $OpenBSD: ssh2putty.sh,v 1.2 2009/10/06 23:51:49 dtucker Exp $ | ||
2 | 3 | ||
3 | if test "x$1" = "x" -o "x$2" = "x" -o "x$3" = "x" ; then | 4 | if test "x$1" = "x" -o "x$2" = "x" -o "x$3" = "x" ; then |
4 | echo "Usage: ssh2putty hostname port ssh-private-key" | 5 | echo "Usage: ssh2putty hostname port ssh-private-key" |
diff --git a/regress/test-exec.sh b/regress/test-exec.sh index b54448912..b3a19389d 100644 --- a/regress/test-exec.sh +++ b/regress/test-exec.sh | |||
@@ -1,4 +1,4 @@ | |||
1 | # $OpenBSD: test-exec.sh,v 1.35 2008/06/28 13:57:25 djm Exp $ | 1 | # $OpenBSD: test-exec.sh,v 1.37 2010/02/24 06:21:56 djm Exp $ |
2 | # Placed in the Public Domain. | 2 | # Placed in the Public Domain. |
3 | 3 | ||
4 | #SUDO=sudo | 4 | #SUDO=sudo |
@@ -172,9 +172,17 @@ cleanup () | |||
172 | echo no sshd running | 172 | echo no sshd running |
173 | else | 173 | else |
174 | if [ $pid -lt 2 ]; then | 174 | if [ $pid -lt 2 ]; then |
175 | echo bad pid for ssd: $pid | 175 | echo bad pid for ssh: $pid |
176 | else | 176 | else |
177 | $SUDO kill $pid | 177 | $SUDO kill $pid |
178 | trace "wait for sshd to exit" | ||
179 | i=0; | ||
180 | while [ -f $PIDFILE -a $i -lt 5 ]; do | ||
181 | i=`expr $i + 1` | ||
182 | sleep $i | ||
183 | done | ||
184 | test -f $PIDFILE && \ | ||
185 | fatal "sshd didn't exit port $PORT pid $pid" | ||
178 | fi | 186 | fi |
179 | fi | 187 | fi |
180 | fi | 188 | fi |
@@ -222,6 +230,7 @@ trap fatal 3 2 | |||
222 | cat << EOF > $OBJ/sshd_config | 230 | cat << EOF > $OBJ/sshd_config |
223 | StrictModes no | 231 | StrictModes no |
224 | Port $PORT | 232 | Port $PORT |
233 | Protocol 2,1 | ||
225 | AddressFamily inet | 234 | AddressFamily inet |
226 | ListenAddress 127.0.0.1 | 235 | ListenAddress 127.0.0.1 |
227 | #ListenAddress ::1 | 236 | #ListenAddress ::1 |
@@ -247,6 +256,7 @@ echo 'StrictModes no' >> $OBJ/sshd_proxy | |||
247 | # create client config | 256 | # create client config |
248 | cat << EOF > $OBJ/ssh_config | 257 | cat << EOF > $OBJ/ssh_config |
249 | Host * | 258 | Host * |
259 | Protocol 2,1 | ||
250 | Hostname 127.0.0.1 | 260 | Hostname 127.0.0.1 |
251 | HostKeyAlias localhost-with-alias | 261 | HostKeyAlias localhost-with-alias |
252 | Port $PORT | 262 | Port $PORT |