]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - testdata/07-confroot.tdir/07-confroot.test
Vendor import of Unbound 1.9.0.
[FreeBSD/FreeBSD.git] / testdata / 07-confroot.tdir / 07-confroot.test
1 # #-- 07-confroot.test --#
2 # source the master var file when it's there
3 [ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
4 # use .tpkg.var.test for in test variable passing
5 [ -f .tpkg.var.test ] && source .tpkg.var.test
6
7 PRE="../.."
8
9 if uname | grep "MINGW" >/dev/null; then
10         # no chroot, no need to test.
11         # (test fails on / en \ comparisons, by the way).
12         echo "no chroot on windows, end test"
13         exit 0
14 fi
15
16 # create config file
17 cwd=`pwd -P`
18 subdir=$cwd/subdir
19 user=`whoami`
20 mkdir subdir
21 if test $? -ne 0; then
22         echo "could not create subdir"
23         exit 1
24 fi
25
26 cat > test.conf <<EOF
27 server:
28         chroot: $cwd
29         directory: $subdir
30         username: $user
31
32         pidfile: "/unbound.pid"
33         root-hints: "root.ca"
34         root-hints: "$subdir/root.cb"
35         root-hints: "/subdir/root.cc"
36
37         logfile: "output.log"
38
39         trust-anchor-file: "$subdir/trustanchor.conf"
40         trust-anchor-file: "/subdir/trustanchor.conf"
41         trust-anchor-file: "trustanchor.conf"
42
43         trusted-keys-file: "trustkeys.conf"
44         trusted-keys-file: "$subdir/trustkeys2.conf"
45         trusted-keys-file: "/subdir/trustkeys3.conf"
46 EOF
47
48 # fake root file
49 echo ". NS a.root-servers.net." > subdir/root.ca
50 echo "a.root-servers.net. IN A 127.0.0.1" >> subdir/root.ca
51 echo ". CH NS b.root-servers.net." > subdir/root.cb
52 echo "b.root-servers.net. CH A 127.0.0.1" >> subdir/root.cb
53 echo ". HS NS c.root-servers.net." > subdir/root.cc
54 echo "c.root-servers.net. HS A 127.0.0.1" >> subdir/root.cc
55 echo "" > subdir/trustkeys.conf
56 echo "" > subdir/trustkeys2.conf
57 echo "" > subdir/trustkeys3.conf
58 echo "" > subdir/trustanchor.conf
59 echo "" > subdir/trustanchor2.conf
60 echo "" > subdir/trustanchor3.conf
61
62 $PRE/unbound-checkconf test.conf
63 if test $? -ne 0; then
64         echo "Checkconf of config with chroot inside it failed"
65         exit 1
66 fi
67 echo "OK 1"
68
69 ### NEXT TEST
70
71 cat > test.conf <<EOF
72 server:
73         chroot: $cwd
74         directory: "subdir"
75         username: $user
76
77         pidfile: "/unbound.pid"
78         root-hints: "root.ca"
79         root-hints: "$subdir/root.cb"
80         root-hints: "/subdir/root.cc"
81
82         logfile: "output.log"
83
84         trust-anchor-file: "$subdir/trustanchor.conf"
85         trust-anchor-file: "/subdir/trustanchor.conf"
86         trust-anchor-file: "trustanchor.conf"
87
88         trusted-keys-file: "trustkeys.conf"
89         trusted-keys-file: "$subdir/trustkeys2.conf"
90         trusted-keys-file: "/subdir/trustkeys3.conf"
91 EOF
92
93 $PRE/unbound-checkconf test.conf
94 if test $? -ne 0; then
95         echo "Checkconf of config with chroot inside it failed"
96         exit 1
97 fi
98 echo "OK 2"
99
100 ### NEXT TEST
101
102 cat > test.conf <<EOF
103 server:
104         chroot: $cwd
105         directory: "/subdir"
106         username: $user
107
108         pidfile: "/unbound.pid"
109         root-hints: "root.ca"
110         root-hints: "$subdir/root.cb"
111         root-hints: "/subdir/root.cc"
112
113         logfile: "output.log"
114
115         trust-anchor-file: "$subdir/trustanchor.conf"
116         trust-anchor-file: "/subdir/trustanchor.conf"
117         trust-anchor-file: "trustanchor.conf"
118
119         trusted-keys-file: "trustkeys.conf"
120         trusted-keys-file: "$subdir/trustkeys2.conf"
121         trusted-keys-file: "/subdir/trustkeys3.conf"
122 EOF
123
124 $PRE/unbound-checkconf test.conf
125 if test $? -ne 0; then
126         echo "Checkconf of config with chroot inside it failed"
127         exit 1
128 fi
129 echo "OK 3"
130
131 ### NEXT TEST
132
133 cat > test.conf <<EOF
134 server:
135         chroot: "."
136         directory: "./subdir"
137         username: $user
138
139         pidfile: "/unbound.pid"
140         root-hints: "root.ca"
141         #root-hints: "$subdir/root.cb"
142         root-hints: "/subdir/root.cc"
143
144         logfile: "output.log"
145
146         #trust-anchor-file: "$subdir/trustanchor.conf"
147         trust-anchor-file: "/subdir/trustanchor.conf"
148         trust-anchor-file: "trustanchor.conf"
149
150         trusted-keys-file: "trustkeys.conf"
151         #trusted-keys-file: "$subdir/trustkeys2.conf"
152         trusted-keys-file: "/subdir/trustkeys3.conf"
153 EOF
154
155 $PRE/unbound-checkconf test.conf
156 if test $? -ne 0; then
157         echo "Checkconf of config with chroot inside it failed"
158         exit 1
159 fi
160 echo "OK 4"
161
162 ### NEXT TEST
163
164 cat > test.conf <<EOF
165 server:
166         chroot: ""
167         directory: "subdir"
168         username: $user
169
170         pidfile: "/unbound.pid"
171         root-hints: "root.ca"
172         root-hints: "$subdir/root.cb"
173         #root-hints: "/subdir/root.cc"
174
175         logfile: "output.log"
176
177         trust-anchor-file: "$subdir/trustanchor.conf"
178         #trust-anchor-file: "/subdir/trustanchor.conf"
179         trust-anchor-file: "trustanchor.conf"
180
181         trusted-keys-file: "trustkeys.conf"
182         trusted-keys-file: "$subdir/trustkeys2.conf"
183         #trusted-keys-file: "/subdir/trustkeys3.conf"
184 EOF
185
186 $PRE/unbound-checkconf test.conf
187 if test $? -ne 0; then
188         echo "Checkconf of config with chroot inside it failed"
189         exit 1
190 fi
191 echo "OK 5"
192
193 ### NEXT TEST
194
195 cat > test.conf <<EOF
196 server:
197         chroot: ""
198         directory: ""
199         username: $user
200
201         pidfile: "/unbound.pid"
202         #root-hints: "root.ca"
203         root-hints: "$subdir/root.cb"
204         root-hints: "subdir/root.cc"
205
206         logfile: "output.log"
207
208         trust-anchor-file: "$subdir/trustanchor.conf"
209         trust-anchor-file: "subdir/trustanchor.conf"
210         #trust-anchor-file: "trustanchor.conf"
211
212         #trusted-keys-file: "trustkeys.conf"
213         trusted-keys-file: "$subdir/trustkeys2.conf"
214         trusted-keys-file: "subdir/trustkeys3.conf"
215 EOF
216
217 $PRE/unbound-checkconf test.conf
218 if test $? -ne 0; then
219         echo "Checkconf of config with chroot inside it failed"
220         exit 1
221 fi
222 echo "OK 6"
223
224 ### NEXT TEST
225
226 cat > test.conf <<EOF
227 server:
228         chroot: "."
229         directory: ""
230         username: $user
231
232         pidfile: "/nosubdir/unbound.pid"
233         #root-hints: "root.ca"
234         #root-hints: "$subdir/root.cb"
235         root-hints: "subdir/root.cc"
236
237         logfile: "output.log"
238
239         #trust-anchor-file: "$subdir/trustanchor.conf"
240         trust-anchor-file: "subdir/trustanchor.conf"
241         #trust-anchor-file: "trustanchor.conf"
242
243         #trusted-keys-file: "trustkeys.conf"
244         #trusted-keys-file: "$subdir/trustkeys2.conf"
245         trusted-keys-file: "subdir/trustkeys3.conf"
246 EOF
247
248 $PRE/unbound-checkconf test.conf
249 if test $? -ne 1; then
250         echo "Checkconf of config with chroot inside it failed"
251         exit 1
252 fi
253 echo "OK 7"
254
255 ### NEXT TEST
256
257 cat > test.conf <<EOF
258 server:
259         chroot: $cwd
260         directory: ""
261         username: $user
262
263         pidfile: "/unbound.pid"
264         #root-hints: "root.ca"
265         root-hints: "$subdir/root.cb"
266         root-hints: "/subdir/root.cc"
267
268         logfile: "output.log"
269
270         trust-anchor-file: "$subdir/trustanchor.conf"
271         trust-anchor-file: "/subdir/trustanchor.conf"
272         #trust-anchor-file: "trustanchor.conf"
273
274         #trusted-keys-file: "trustkeys.conf"
275         trusted-keys-file: "$subdir/trustkeys2.conf"
276         trusted-keys-file: "/subdir/trustkeys3.conf"
277 EOF
278
279 $PRE/unbound-checkconf test.conf
280 if test $? -ne 0; then
281         echo "Checkconf of config with chroot inside it failed"
282         exit 1
283 fi
284 echo "OK 8"
285
286
287 exit 0