summaryrefslogtreecommitdiff
path: root/regress/cfginclude.sh
diff options
context:
space:
mode:
authordjm@openbsd.org <djm@openbsd.org>2016-04-15 00:31:10 +0000
committerDamien Miller <djm@mindrot.org>2016-04-15 11:16:13 +1000
commit35f22dad263cce5c61d933ae439998cb965b8748 (patch)
tree61e9d0ef521c020ecbde6ef9a7638058bb4ffbe5 /regress/cfginclude.sh
parent6b8a1a87005818d4700ce8b42faef746e82c1f51 (diff)
upstream commit
regression test for ssh_config Include directive Upstream-Regress-ID: 46a38c8101f635461c506d1aac2d96af80f97f1e
Diffstat (limited to 'regress/cfginclude.sh')
-rw-r--r--regress/cfginclude.sh290
1 files changed, 290 insertions, 0 deletions
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