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