]> git.ipfire.org Git - thirdparty/pdns.git/blob - regression-tests.nobackend/supermaster-signed/command
updated KSK and ZSK Rollover procedures, small fixes in Algorithm Rollover procedure
[thirdparty/pdns.git] / regression-tests.nobackend / supermaster-signed / command
1 #!/usr/bin/env bash
2 set -e
3 set -x
4
5 ALGORITHM=${ALGORITHM:="hmac-md5"}
6 KEY=${KEY:="kp4/24gyYsEzbuTVJRUMoqGFmN3LYgVDzJ/3oRSP7ys="}
7 if [ "$RUNWRAPPER" = "" ]; then
8 RUNWRAPPER="authbind"
9 fi
10
11 export ALGORITHM
12 export KEY
13
14 port=$1
15 [ -z "$port" ] && port=53
16
17 trap "kill_process 2" EXIT INT TERM
18
19 tosql ()
20 {
21 ${ZONE2SQL} --transactions --$1 --named-conf=./named.conf
22 }
23
24 prepare()
25 {
26 rm -f named.conf
27 cat > named.conf<<EOF
28 options {
29 directory "zones/";
30 recursion no;
31 listen-on port 5300 {
32 127.0.0.1;
33 };
34 version "Meow!Meow!";
35 minimal-responses yes;
36 };
37 zone "example.com"{
38 type master;
39 file "example.com";
40 };
41
42 zone "test.com"{
43 type master;
44 file "test.com";
45 };
46 EOF
47 cat > pdns-gsqlite3-master.conf<<EOF
48 module-dir=../regression-tests/modules
49 launch=gsqlite3
50 gsqlite3-dnssec=yes
51 gsqlite3-database=master.db
52 EOF
53 cat > pdns-gsqlite3-slave.conf<<EOF
54 module-dir=../regression-tests/modules
55 launch=gsqlite3
56 gsqlite3-dnssec=yes
57 gsqlite3-database=slave.db
58 EOF
59 rm -f master.db slave.db
60 sqlite3 master.db < ../modules/gsqlite3backend/schema.sqlite3.sql
61 sqlite3 slave.db < ../modules/gsqlite3backend/schema.sqlite3.sql
62 # import zones
63 tosql gsqlite | sqlite3 master.db
64 # change them to master
65 sqlite3 master.db <<EOF
66 UPDATE domains SET type = 'MASTER', notified_serial = NULL;
67 EOF
68 # setup tsig keys
69 $PDNSUTIL --config-name=gsqlite3-master --config-dir=. import-tsig-key tsig.com $ALGORITHM "$KEY"
70 $PDNSUTIL --config-name=gsqlite3-slave --config-dir=. import-tsig-key tsig.com $ALGORITHM "$KEY"
71 $ZONE2SQL --transactions --gsqlite --zone=zones/example.com --zone-name=example.com | sqlite3 slave.db
72 # setup supermaster
73 sqlite3 slave.db <<EOF
74 UPDATE domains SET type = 'SLAVE', master = '127.0.0.1' WHERE name = 'example.com';
75 EOF
76 # setup metadata on master
77 $PDNSUTIL --config-name=gsqlite3-master --config-dir=. set-meta example.com TSIG-ALLOW-AXFR tsig.com
78 $PDNSUTIL --config-name=gsqlite3-master --config-dir=. set-meta test.com TSIG-ALLOW-AXFR tsig.com
79 $PDNSUTIL --config-name=gsqlite3-slave --config-dir=. set-meta example.com AXFR-MASTER-TSIG tsig.com
80 # i suppose we are done here...
81 }
82
83 start_master()
84 {
85 $RUNWRAPPER $PDNS --daemon=no --local-port=$port --config-dir=. --module-dir=../regression-tests/modules \
86 --config-name=gsqlite3-master --socket-dir=./ --no-shuffle \
87 --master=yes --local-address=127.0.0.1 \
88 --query-local-address=127.0.0.1 --cache-ttl=$cachettl --dname-processing --allow-axfr-ips= &
89 }
90
91 start_slave()
92 {
93 slaveport=53
94
95 $RUNWRAPPER $PDNS --daemon=no --local-port=$slaveport --config-dir=. --module-dir=../regression-tests/modules \
96 --config-name=gsqlite3-slave --socket-dir=./ --no-shuffle --local-address=127.0.0.2 \
97 --slave --retrieval-threads=4 --slave=yes --superslave=yes --query-local-address=127.0.0.2 \
98 --slave-cycle-interval=300 --allow-unsigned-notify=no --allow-unsigned-supermaster=no &
99 }
100
101 check_process ()
102 {
103 set +e
104 loopcount=0
105 while [ $loopcount -lt 5 ]; do
106 sleep 1
107 pids=$(cat pdns*.pid 2>/dev/null)
108 if [ ! -z "$pids" ]
109 then
110 kill -0 $pids >/dev/null 2>&1
111 if [ $? -eq 0 ]
112 then
113 set -e
114 return
115 fi
116 fi
117 let loopcount=loopcount+1
118 done
119 echo "PowerDNS did not start"
120 exit
121 }
122
123 kill_process ()
124 {
125 set +e
126 trap - EXIT INT TERM
127
128 if [ $1 -gt 1 ]
129 then
130 echo "exitvalue$1" >> failed_tests
131 fi
132
133 pids=$(cat pdns*.pid)
134
135 if [ -n "$pids" ]
136 then
137 kill $pids
138 # make sure they die.
139 loopcount=0
140 done=0
141 while [ $loopcount -lt 10 ] && [ $done -eq 0 ]
142 do
143 done=1
144 for pid in $pids
145 do
146 kill -0 $pid > /dev/null 2>&1
147 if [ $? -eq 0 ];
148 then
149 done=0
150 fi
151 done
152 let loopcount=loopcount+1
153 sleep 1
154 done
155
156 kill -9 $pids
157 fi
158
159 rm pdns*.pid
160 exit $1
161 }
162
163 sqlite3wait()
164 {
165 # make sure domains are transferred and created
166 domcount=0
167 retries=15
168 delay=1
169 domains=2
170
171 while [ $retries -ge 0 ]; do
172 domcount=`sqlite3 slave.db "select count(*) from domains"`
173 # at the moment we want three domains
174 if [ $domcount -eq $domains ]; then
175 break
176 fi
177 sleep $delay
178 let retries=retries-1
179 done
180
181 if [ $domcount -ne $domains ]; then
182 echo "Supermaster provisioning failed"
183 exit
184 fi
185 }
186
187 prepare
188 start_slave
189 check_process
190 sleep 1
191 start_master
192 # to avoid locking issues later on
193 sleep 2
194
195 # then we check that test.com has not been transferred yet.
196 for domain in test.com; do
197 reccount=`sqlite3 slave.db "select count(*) from records join domains on records.domain_id = domains.id where domains.name='$domain'"`
198 if [ $reccount -ne 0 ]; then
199 echo "Transfer of '$domain' has unexpectedly succeeded"
200 fi
201 done
202
203 # create supermaster
204 sqlite3 slave.db <<EOF
205 INSERT INTO supermasters (ip,nameserver,account) VALUES('127.0.0.1','ns1.example.com','');
206 EOF
207
208 # send notifications
209 $PDNSCONTROL --config-dir=. --config-name=gsqlite3-master --socket-dir=. notify test.com
210 sleep 2
211
212 # hopefully notifications have gone thru
213 sqlite3wait
214
215 # then we check that we got records in database for both domains
216 for domain in test.com; do
217 reccount=`sqlite3 slave.db "select count(*) from records join domains on records.domain_id = domains.id where domains.name='$domain'"`
218 if [ $reccount -lt 3 ]; then
219 echo "Transfer of '$domain' did not succeed"
220 fi
221 result=`sqlite3 slave.db "select kind,content from domainmetadata join domains on domainmetadata.domain_id = domains.id where domains.name='$domain'"`
222 if [ "$result" != "AXFR-MASTER-TSIG|tsig.com" ]; then
223 echo "Domain '$domain' did not provision correctly"
224 fi
225 done
226
227 # ensure unsigned notifications are refused
228 $NOTIFY 127.0.0.2:53 test.com 2>&1
229
230 kill_process 0