summaryrefslogtreecommitdiff
path: root/regress
diff options
context:
space:
mode:
Diffstat (limited to 'regress')
-rw-r--r--regress/Makefile8
-rw-r--r--regress/cfginclude.sh290
2 files changed, 295 insertions, 3 deletions
diff --git a/regress/Makefile b/regress/Makefile
index 839fb8eca..4e32eab8a 100644
--- a/regress/Makefile
+++ b/regress/Makefile
@@ -1,4 +1,4 @@
1# $OpenBSD: Makefile,v 1.84 2016/03/04 02:30:36 djm Exp $ 1# $OpenBSD: Makefile,v 1.85 2016/04/15 00:31:10 djm Exp $
2 2
3REGRESS_TARGETS= unit t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t-exec 3REGRESS_TARGETS= unit t1 t2 t3 t4 t5 t6 t7 t8 t9 t10 t11 t12 t-exec
4tests: prep $(REGRESS_TARGETS) 4tests: prep $(REGRESS_TARGETS)
@@ -75,7 +75,8 @@ LTESTS= connect \
75 keygen-knownhosts \ 75 keygen-knownhosts \
76 hostkey-rotate \ 76 hostkey-rotate \
77 principals-command \ 77 principals-command \
78 cert-file 78 cert-file \
79 cfginclude
79 80
80 81
81# dhgex \ 82# dhgex \
@@ -106,7 +107,8 @@ CLEANFILES= t2.out t3.out t6.out1 t6.out2 t7.out t7.out.pub copy.1 copy.2 \
106 sftp-server.sh sftp-server.log sftp.log setuid-allowed \ 107 sftp-server.sh sftp-server.log sftp.log setuid-allowed \
107 data ed25519-agent ed25519-agent.pub key.ed25519-512 \ 108 data ed25519-agent ed25519-agent.pub key.ed25519-512 \
108 key.ed25519-512.pub netcat host_krl_* host_revoked_* \ 109 key.ed25519-512.pub netcat host_krl_* host_revoked_* \
109 kh.* user_*key* agent-key.* known_hosts.* hkr.* 110 kh.* user_*key* agent-key.* known_hosts.* hkr.* \
111 scp-ssh-wrapper.scp ssh_proxy_bak ssh_config.*
110 112
111SUDO_CLEAN+= /var/run/testdata_${USER} /var/run/keycommand_${USER} 113SUDO_CLEAN+= /var/run/testdata_${USER} /var/run/keycommand_${USER}
112 114
diff --git a/regress/cfginclude.sh b/regress/cfginclude.sh
new file mode 100644
index 000000000..3232fa9f0
--- /dev/null
+++ b/regress/cfginclude.sh
@@ -0,0 +1,290 @@
1# $OpenBSD: cfginclude.sh,v 1.1 2016/04/15 00:31:10 djm Exp $
2# Placed in the Public Domain.
3
4tid="config include"
5
6cat > $OBJ/ssh_config.i << _EOF
7Match host a
8 Hostname aa
9
10Match host b
11 Hostname bb
12 Include $OBJ/ssh_config.i.*
13
14Match host c
15 Include $OBJ/ssh_config.i.*
16 Hostname cc
17
18Match host m
19 Include $OBJ/ssh_config.i.*
20
21Host d
22 Hostname dd
23
24Host e
25 Hostname ee
26 Include $OBJ/ssh_config.i.*
27
28Host f
29 Include $OBJ/ssh_config.i.*
30 Hostname ff
31
32Host n
33 Include $OBJ/ssh_config.i.*
34_EOF
35
36cat > $OBJ/ssh_config.i.0 << _EOF
37Match host xxxxxx
38_EOF
39
40cat > $OBJ/ssh_config.i.1 << _EOF
41Match host a
42 Hostname aaa
43
44Match host b
45 Hostname bbb
46
47Match host c
48 Hostname ccc
49
50Host d
51 Hostname ddd
52
53Host e
54 Hostname eee
55
56Host f
57 Hostname fff
58_EOF
59
60cat > $OBJ/ssh_config.i.2 << _EOF
61Match host a
62 Hostname aaaa
63
64Match host b
65 Hostname bbbb
66
67Match host c
68 Hostname cccc
69
70Host d
71 Hostname dddd
72
73Host e
74 Hostname eeee
75
76Host f
77 Hostname ffff
78
79Match all
80 Hostname xxxx
81_EOF
82
83trial() {
84 _host="$1"
85 _exp="$2"
86 ${REAL_SSH} -F $OBJ/ssh_config.i -G "$_host" > $OBJ/ssh_config.out ||
87 fatal "ssh config parse failed"
88 _got=`grep -i '^hostname ' $OBJ/ssh_config.out | awk '{print $2}'`
89 if test "x$_exp" != "x$_got" ; then
90 fail "host $_host include fail: expected $_exp got $_got"
91 fi
92}
93
94trial a aa
95trial b bb
96trial c ccc
97trial d dd
98trial e ee
99trial f fff
100trial m xxxx
101trial n xxxx
102trial x x
103
104# Prepare an included config with an error.
105
106cat > $OBJ/ssh_config.i.3 << _EOF
107Hostname xxxx
108 Junk
109_EOF
110
111${REAL_SSH} -F $OBJ/ssh_config.i -G a 2>/dev/null && \
112 fail "ssh include allowed invalid config"
113
114${REAL_SSH} -F $OBJ/ssh_config.i -G x 2>/dev/null && \
115 fail "ssh include allowed invalid config"
116
117rm -f $OBJ/ssh_config.i.*
118
119# Ensure that a missing include is not fatal.
120cat > $OBJ/ssh_config.i << _EOF
121Include $OBJ/ssh_config.i.*
122Hostname aa
123_EOF
124
125trial a aa
126
127# Ensure that Match/Host in an included config does not affect parent.
128cat > $OBJ/ssh_config.i.x << _EOF
129Match host x
130_EOF
131
132trial a aa
133
134cat > $OBJ/ssh_config.i.x << _EOF
135Host x
136_EOF
137
138trial a aa
139
140# cleanup
141rm -f $OBJ/ssh_config.i $OBJ/ssh_config.i.* $OBJ/ssh_config.out
142# $OpenBSD: cfginclude.sh,v 1.1 2016/04/15 00:31:10 djm Exp $
143# Placed in the Public Domain.
144
145tid="config include"
146
147cat > $OBJ/ssh_config.i << _EOF
148Match host a
149 Hostname aa
150
151Match host b
152 Hostname bb
153 Include $OBJ/ssh_config.i.*
154
155Match host c
156 Include $OBJ/ssh_config.i.*
157 Hostname cc
158
159Match host m
160 Include $OBJ/ssh_config.i.*
161
162Host d
163 Hostname dd
164
165Host e
166 Hostname ee
167 Include $OBJ/ssh_config.i.*
168
169Host f
170 Include $OBJ/ssh_config.i.*
171 Hostname ff
172
173Host n
174 Include $OBJ/ssh_config.i.*
175_EOF
176
177cat > $OBJ/ssh_config.i.0 << _EOF
178Match host xxxxxx
179_EOF
180
181cat > $OBJ/ssh_config.i.1 << _EOF
182Match host a
183 Hostname aaa
184
185Match host b
186 Hostname bbb
187
188Match host c
189 Hostname ccc
190
191Host d
192 Hostname ddd
193
194Host e
195 Hostname eee
196
197Host f
198 Hostname fff
199_EOF
200
201cat > $OBJ/ssh_config.i.2 << _EOF
202Match host a
203 Hostname aaaa
204
205Match host b
206 Hostname bbbb
207
208Match host c
209 Hostname cccc
210
211Host d
212 Hostname dddd
213
214Host e
215 Hostname eeee
216
217Host f
218 Hostname ffff
219
220Match all
221 Hostname xxxx
222_EOF
223
224trial() {
225 _host="$1"
226 _exp="$2"
227 ${REAL_SSH} -F $OBJ/ssh_config.i -G "$_host" > $OBJ/ssh_config.out ||
228 fatal "ssh config parse failed"
229 _got=`grep -i '^hostname ' $OBJ/ssh_config.out | awk '{print $2}'`
230 if test "x$_exp" != "x$_got" ; then
231 fail "host $_host include fail: expected $_exp got $_got"
232 fi
233}
234
235trial a aa
236trial b bb
237trial c ccc
238trial d dd
239trial e ee
240trial f fff
241trial m xxxx
242trial n xxxx
243trial x x
244
245# Prepare an included config with an error.
246
247cat > $OBJ/ssh_config.i.3 << _EOF
248Hostname xxxx
249 Junk
250_EOF
251
252${REAL_SSH} -F $OBJ/ssh_config.i -G a 2>/dev/null && \
253 fail "ssh include allowed invalid config"
254
255${REAL_SSH} -F $OBJ/ssh_config.i -G x 2>/dev/null && \
256 fail "ssh include allowed invalid config"
257
258rm -f $OBJ/ssh_config.i.*
259
260# Ensure that a missing include is not fatal.
261cat > $OBJ/ssh_config.i << _EOF
262Include $OBJ/ssh_config.i.*
263Hostname aa
264_EOF
265
266trial a aa
267
268# Ensure that Match/Host in an included config does not affect parent.
269cat > $OBJ/ssh_config.i.x << _EOF
270Match host x
271_EOF
272
273trial a aa
274
275cat > $OBJ/ssh_config.i.x << _EOF
276Host x
277_EOF
278
279trial a aa
280
281# Ensure that recursive includes are bounded.
282cat > $OBJ/ssh_config.i << _EOF
283Include $OBJ/ssh_config.i
284_EOF
285
286${REAL_SSH} -F $OBJ/ssh_config.i -G a 2>/dev/null && \
287 fail "ssh include allowed infinite recursion?" # or hang...
288
289# cleanup
290rm -f $OBJ/ssh_config.i $OBJ/ssh_config.i.* $OBJ/ssh_config.out