@@ -178,18 +178,19 @@ bool rectifyZone(DNSSECKeeper& dk, const std::string& zone)
178
178
if (!B.getSOA (zone, sd)) {
179
179
cerr<<" No SOA known for '" <<zone<<" ', is such a zone in the database?" <<endl;
180
180
return false ;
181
- }
181
+ }
182
182
sd.db ->list (zone, sd.domain_id );
183
183
184
184
DNSResourceRecord rr;
185
- set<string> qnames, nsset, dsnames, nonterm, insnonterm, delnonterm;
185
+ set<string> qnames, nsset, dsnames, insnonterm, delnonterm;
186
+ map<string,bool > nonterm;
186
187
bool doent=true ;
187
-
188
+
188
189
while (sd.db ->get (rr)) {
189
190
if (rr.qtype .getCode ())
190
191
{
191
192
qnames.insert (rr.qname );
192
- if (rr.qtype .getCode () == QType::NS && !pdns_iequals (rr.qname , zone))
193
+ if (rr.qtype .getCode () == QType::NS && !pdns_iequals (rr.qname , zone))
193
194
nsset.insert (rr.qname );
194
195
if (rr.qtype .getCode () == QType::DS)
195
196
dsnames.insert (rr.qname );
@@ -202,21 +203,25 @@ bool rectifyZone(DNSSECKeeper& dk, const std::string& zone)
202
203
NSEC3PARAMRecordContent ns3pr;
203
204
bool narrow;
204
205
bool haveNSEC3=dk.getNSEC3PARAM (zone, &ns3pr, &narrow);
206
+ bool isOptOut=(haveNSEC3 && ns3pr.d_flags );
205
207
if (sd.db ->doesDNSSEC ())
206
208
{
207
- if (!haveNSEC3)
209
+ if (!haveNSEC3)
208
210
cerr<<" Adding NSEC ordering information " <<endl;
209
- else if (!narrow)
210
- cerr<<" Adding NSEC3 hashed ordering information for '" <<zone<<" '" <<endl;
211
- else
211
+ else if (!narrow) {
212
+ if (!isOptOut)
213
+ cerr<<" Adding NSEC3 hashed ordering information for '" <<zone<<" '" <<endl;
214
+ else
215
+ cerr<<" Adding NSEC3 opt-out hashed ordering information for '" <<zone<<" '" <<endl;
216
+ } else
212
217
cerr<<" Erasing NSEC3 ordering since we are narrow, only setting 'auth' fields" <<endl;
213
218
}
214
219
else
215
220
cerr<<" Non DNSSEC zone, only adding empty non-terminals" <<endl;
216
-
221
+
217
222
if (doTransaction)
218
223
sd.db ->startTransaction (" " , -1 );
219
-
224
+
220
225
bool realrr=true ;
221
226
string hashed;
222
227
@@ -239,14 +244,17 @@ bool rectifyZone(DNSSECKeeper& dk, const std::string& zone)
239
244
240
245
if (haveNSEC3)
241
246
{
242
- if (!narrow) {
247
+ if (!narrow && (realrr || !isOptOut || nonterm. find (qname)-> second ) ) {
243
248
hashed=toLower (toBase32Hex (hashQNameWithSalt (ns3pr.d_iterations , ns3pr.d_salt , qname)));
244
249
if (g_verbose)
245
250
cerr<<" '" <<qname<<" ' -> '" << hashed <<" '" <<endl;
246
251
sd.db ->updateDNSSECOrderAndAuthAbsolute (sd.domain_id , qname, hashed, auth);
247
252
}
248
- else
253
+ else {
254
+ if (!realrr)
255
+ auth=false ;
249
256
sd.db ->nullifyDNSSECOrderNameAndUpdateAuth (sd.domain_id , qname, auth);
257
+ }
250
258
}
251
259
else // NSEC
252
260
{
@@ -260,33 +268,39 @@ bool rectifyZone(DNSSECKeeper& dk, const std::string& zone)
260
268
if (dsnames.count (qname))
261
269
sd.db ->setDNSSECAuthOnDsRecord (sd.domain_id , qname);
262
270
if (!auth || nsset.count (qname)) {
263
- if (haveNSEC3 && ns3pr. d_flags )
271
+ if (isOptOut )
264
272
sd.db ->nullifyDNSSECOrderNameAndAuth (sd.domain_id , qname, " NS" );
265
273
sd.db ->nullifyDNSSECOrderNameAndAuth (sd.domain_id , qname, " A" );
266
274
sd.db ->nullifyDNSSECOrderNameAndAuth (sd.domain_id , qname, " AAAA" );
267
275
}
268
276
269
- if (auth && doent)
277
+ if (doent)
270
278
{
271
279
shorter=qname;
272
280
while (!pdns_iequals (shorter, zone) && chopOff (shorter))
273
281
{
274
- if (!qnames.count (shorter) && !nonterm. count (shorter) )
282
+ if (!qnames.count (shorter))
275
283
{
276
284
if (!(maxent))
277
285
{
278
- cerr<<" Zone '" <<zone<<" ' has too many empty non terminals." <<endl;
286
+ if (!::arg ().asNum (" max-ent-entries" ))
287
+ cerr<<" Zone '" <<zone<<" ' has too many empty non terminals." <<endl;
279
288
insnonterm.clear ();
280
289
delnonterm.clear ();
281
290
doent=false ;
282
291
break ;
283
292
}
284
- nonterm. insert (shorter);
285
- if (!delnonterm.count (shorter))
293
+
294
+ if (!delnonterm.count (shorter) && !nonterm. count (shorter) )
286
295
insnonterm.insert (shorter);
287
296
else
288
297
delnonterm.erase (shorter);
289
- --maxent;
298
+
299
+ if (!nonterm.count (shorter)) {
300
+ nonterm.insert (pair<string, bool >(shorter, auth));
301
+ --maxent;
302
+ } else if (auth)
303
+ nonterm[shorter]=true ;
290
304
}
291
305
}
292
306
}
@@ -303,7 +317,11 @@ bool rectifyZone(DNSSECKeeper& dk, const std::string& zone)
303
317
if (doent)
304
318
{
305
319
realrr=false ;
306
- qnames=nonterm;
320
+ qnames.clear ();
321
+ pair<string,bool > nt;
322
+ BOOST_FOREACH (nt, nonterm){
323
+ qnames.insert (nt.first );
324
+ }
307
325
goto dononterm;
308
326
}
309
327
}
0 commit comments