• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

PowerDNS / pdns / 14662673067

25 Apr 2025 10:37AM UTC coverage: 63.59% (+2.3%) from 61.259%
14662673067

Pull #15470

github

web-flow
Merge 095d3c982 into d990c4ba0
Pull Request #15470: More low-hanging fruits from the views work

41913 of 100696 branches covered (41.62%)

Branch coverage included in aggregate %.

88 of 94 new or added lines in 13 files covered. (93.62%)

27 existing lines in 7 files now uncovered.

129482 of 168836 relevant lines covered (76.69%)

4324111.12 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

60.9
/modules/bindbackend/bindbackend2.cc
1
/*
2
 * This file is part of PowerDNS or dnsdist.
3
 * Copyright -- PowerDNS.COM B.V. and its contributors
4
 *
5
 * This program is free software; you can redistribute it and/or modify
6
 * it under the terms of version 2 of the GNU General Public License as
7
 * published by the Free Software Foundation.
8
 *
9
 * In addition, for the avoidance of any doubt, permission is granted to
10
 * link this program with OpenSSL and to (re)distribute the binaries
11
 * produced as the result of such linking.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21
 */
22

23
#ifdef HAVE_CONFIG_H
24
#include "config.h"
25
#endif
26
#include <cerrno>
27
#include <string>
28
#include <set>
29
#include <sys/types.h>
30
#include <sys/stat.h>
31
#include <unistd.h>
32
#include <fstream>
33
#include <fcntl.h>
34
#include <sstream>
35
#include <boost/algorithm/string.hpp>
36
#include <system_error>
37
#include <unordered_map>
38
#include <unordered_set>
39

40
#include "pdns/dnsseckeeper.hh"
41
#include "pdns/dnssecinfra.hh"
42
#include "pdns/base32.hh"
43
#include "pdns/namespaces.hh"
44
#include "pdns/dns.hh"
45
#include "pdns/dnsbackend.hh"
46
#include "bindbackend2.hh"
47
#include "pdns/dnspacket.hh"
48
#include "pdns/zoneparser-tng.hh"
49
#include "pdns/bindparserclasses.hh"
50
#include "pdns/logger.hh"
51
#include "pdns/arguments.hh"
52
#include "pdns/qtype.hh"
53
#include "pdns/misc.hh"
54
#include "pdns/dynlistener.hh"
55
#include "pdns/lock.hh"
56
#include "pdns/auth-zonecache.hh"
57
#include "pdns/auth-caches.hh"
58

59
/*
60
   All instances of this backend share one s_state, which is indexed by zone name and zone id.
61
   The s_state is protected by a read/write lock, and the goal it to only interact with it briefly.
62
   When a query comes in, we take a read lock and COPY the best zone to answer from s_state (BB2DomainInfo object)
63
   All answers are served from this copy.
64

65
   To interact with s_state, use safeGetBBDomainInfo (search on name or id), safePutBBDomainInfo (to update)
66
   or safeRemoveBBDomainInfo. These all lock as they should.
67

68
   Several functions need to traverse s_state to get data for the rest of PowerDNS. When doing so,
69
   you need to manually take the lock (read).
70

71
   Parsing zones happens with parseZone(), which fills a BB2DomainInfo object. This can then be stored with safePutBBDomainInfo.
72

73
   Finally, the BB2DomainInfo contains all records as a LookButDontTouch object. This makes sure you only look, but don't touch, since
74
   the records might be in use in other places.
75
*/
76

77
SharedLockGuarded<Bind2Backend::state_t> Bind2Backend::s_state;
78
int Bind2Backend::s_first = 1;
79
bool Bind2Backend::s_ignore_broken_records = false;
80

81
std::mutex Bind2Backend::s_autosecondary_config_lock; // protects writes to config file
82
std::mutex Bind2Backend::s_startup_lock;
83
string Bind2Backend::s_binddirectory;
84

85
BB2DomainInfo::BB2DomainInfo()
86
{
15,169✔
87
  d_loaded = false;
15,169✔
88
  d_lastcheck = 0;
15,169✔
89
  d_checknow = false;
15,169✔
90
  d_status = "Unknown";
15,169✔
91
}
15,169✔
92

93
void BB2DomainInfo::setCheckInterval(time_t seconds)
94
{
2,667✔
95
  d_checkinterval = seconds;
2,667✔
96
}
2,667✔
97

98
bool BB2DomainInfo::current()
99
{
4,083✔
100
  if (d_checknow) {
4,083✔
101
    return false;
6✔
102
  }
6✔
103

104
  if (!d_checkinterval)
4,077!
105
    return true;
4,077✔
106

107
  if (time(nullptr) - d_lastcheck < d_checkinterval)
×
108
    return true;
×
109

110
  if (d_filename.empty())
×
111
    return true;
×
112

113
  return (getCtime() == d_ctime);
×
114
}
×
115

116
time_t BB2DomainInfo::getCtime()
117
{
×
118
  struct stat buf;
×
119

120
  if (d_filename.empty() || stat(d_filename.c_str(), &buf) < 0)
×
121
    return 0;
×
122
  d_lastcheck = time(nullptr);
×
123
  return buf.st_ctime;
×
124
}
×
125

126
void BB2DomainInfo::setCtime()
127
{
2,673✔
128
  struct stat buf;
2,673✔
129
  if (stat(d_filename.c_str(), &buf) < 0)
2,673!
130
    return;
×
131
  d_ctime = buf.st_ctime;
2,673✔
132
}
2,673✔
133

134
bool Bind2Backend::safeGetBBDomainInfo(int id, BB2DomainInfo* bbd)
135
{
10,667✔
136
  auto state = s_state.read_lock();
10,667✔
137
  state_t::const_iterator iter = state->find(id);
10,667✔
138
  if (iter == state->end()) {
10,667!
139
    return false;
×
140
  }
×
141
  *bbd = *iter;
10,667✔
142
  return true;
10,667✔
143
}
10,667✔
144

145
bool Bind2Backend::safeGetBBDomainInfo(const ZoneName& name, BB2DomainInfo* bbd)
146
{
4,505✔
147
  auto state = s_state.read_lock();
4,505✔
148
  const auto& nameindex = boost::multi_index::get<NameTag>(*state);
4,505✔
149
  auto iter = nameindex.find(name);
4,505✔
150
  if (iter == nameindex.end()) {
4,505✔
151
    return false;
3,251✔
152
  }
3,251✔
153
  *bbd = *iter;
1,254✔
154
  return true;
1,254✔
155
}
4,505✔
156

157
bool Bind2Backend::safeRemoveBBDomainInfo(const ZoneName& name)
158
{
×
159
  auto state = s_state.write_lock();
×
160
  using nameindex_t = state_t::index<NameTag>::type;
×
161
  nameindex_t& nameindex = boost::multi_index::get<NameTag>(*state);
×
162

163
  nameindex_t::iterator iter = nameindex.find(name);
×
164
  if (iter == nameindex.end()) {
×
165
    return false;
×
166
  }
×
167
  nameindex.erase(iter);
×
168
  return true;
×
169
}
×
170

171
void Bind2Backend::safePutBBDomainInfo(const BB2DomainInfo& bbd)
172
{
2,817✔
173
  auto state = s_state.write_lock();
2,817✔
174
  replacing_insert(*state, bbd);
2,817✔
175
}
2,817✔
176

177
void Bind2Backend::setNotified(uint32_t id, uint32_t serial)
178
{
×
179
  BB2DomainInfo bbd;
×
180
  if (!safeGetBBDomainInfo(id, &bbd))
×
181
    return;
×
182
  bbd.d_lastnotified = serial;
×
183
  safePutBBDomainInfo(bbd);
×
184
}
×
185

186
void Bind2Backend::setLastCheck(uint32_t domain_id, time_t lastcheck)
187
{
72✔
188
  BB2DomainInfo bbd;
72✔
189
  if (safeGetBBDomainInfo(domain_id, &bbd)) {
72!
190
    bbd.d_lastcheck = lastcheck;
72✔
191
    safePutBBDomainInfo(bbd);
72✔
192
  }
72✔
193
}
72✔
194

195
void Bind2Backend::setStale(uint32_t domain_id)
196
{
×
197
  setLastCheck(domain_id, 0);
×
198
}
×
199

200
void Bind2Backend::setFresh(uint32_t domain_id)
201
{
72✔
202
  setLastCheck(domain_id, time(nullptr));
72✔
203
}
72✔
204

205
bool Bind2Backend::startTransaction(const ZoneName& qname, int domainId)
206
{
221✔
207
  if (domainId < 0) {
221✔
208
    d_transaction_tmpname.clear();
149✔
209
    d_transaction_id = domainId;
149✔
210
    return false;
149✔
211
  }
149✔
212
  if (domainId == 0) {
72!
213
    throw DBException("domain_id 0 is invalid for this backend.");
×
214
  }
×
215

216
  d_transaction_id = domainId;
72✔
217
  d_transaction_qname = qname;
72✔
218
  BB2DomainInfo bbd;
72✔
219
  if (safeGetBBDomainInfo(domainId, &bbd)) {
72!
220
    d_transaction_tmpname = bbd.d_filename + "XXXXXX";
72✔
221
    int fd = mkstemp(&d_transaction_tmpname.at(0));
72✔
222
    if (fd == -1) {
72!
223
      throw DBException("Unable to create a unique temporary zonefile '" + d_transaction_tmpname + "': " + stringerror());
×
224
    }
×
225

226
    d_of = std::make_unique<ofstream>(d_transaction_tmpname);
72✔
227
    if (!*d_of) {
72!
228
      unlink(d_transaction_tmpname.c_str());
×
229
      close(fd);
×
230
      fd = -1;
×
231
      d_of.reset();
×
232
      throw DBException("Unable to open temporary zonefile '" + d_transaction_tmpname + "': " + stringerror());
×
233
    }
×
234
    close(fd);
72✔
235
    fd = -1;
72✔
236

237
    *d_of << "; Written by PowerDNS, don't edit!" << endl;
72✔
238
    *d_of << "; Zone '" << bbd.d_name << "' retrieved from primary " << endl
72✔
239
          << "; at " << nowTime() << endl; // insert primary info here again
72✔
240

241
    return true;
72✔
242
  }
72✔
243
  return false;
×
244
}
72✔
245

246
bool Bind2Backend::commitTransaction()
247
{
221✔
248
  if (d_transaction_id < 0)
221✔
249
    return false;
149✔
250
  d_of.reset();
72✔
251

252
  BB2DomainInfo bbd;
72✔
253
  if (safeGetBBDomainInfo(d_transaction_id, &bbd)) {
72!
254
    if (rename(d_transaction_tmpname.c_str(), bbd.d_filename.c_str()) < 0)
72!
255
      throw DBException("Unable to commit (rename to: '" + bbd.d_filename + "') AXFRed zone: " + stringerror());
×
256
    queueReloadAndStore(bbd.d_id);
72✔
257
  }
72✔
258

259
  d_transaction_id = 0;
72✔
260

261
  return true;
72✔
262
}
72✔
263

264
bool Bind2Backend::abortTransaction()
265
{
×
266
  // -1 = dnssec speciality
267
  // 0  = invalid transact
268
  // >0 = actual transaction
269
  if (d_transaction_id > 0) {
×
270
    unlink(d_transaction_tmpname.c_str());
×
271
    d_of.reset();
×
272
    d_transaction_id = 0;
×
273
  }
×
274

275
  return true;
×
276
}
×
277

278
bool Bind2Backend::feedRecord(const DNSResourceRecord& rr, const DNSName& /* ordername */, bool /* ordernameIsNSEC3 */)
279
{
202,785✔
280
  if (d_transaction_id < 1) {
202,785!
281
    throw DBException("Bind2Backend::feedRecord() called outside of transaction");
×
282
  }
×
283

284
  string qname;
202,785✔
285
  if (d_transaction_qname.empty()) {
202,785!
286
    qname = rr.qname.toString();
×
287
  }
×
288
  else if (rr.qname.isPartOf(d_transaction_qname)) {
202,785!
289
    if (rr.qname == d_transaction_qname.operator const DNSName&()) {
202,785✔
290
      qname = "@";
633✔
291
    }
633✔
292
    else {
202,152✔
293
      DNSName relName = rr.qname.makeRelative(d_transaction_qname);
202,152✔
294
      qname = relName.toStringNoDot();
202,152✔
295
    }
202,152✔
296
  }
202,785✔
297
  else {
×
298
    throw DBException("out-of-zone data '" + rr.qname.toLogString() + "' during AXFR of zone '" + d_transaction_qname.toLogString() + "'");
×
299
  }
×
300

301
  shared_ptr<DNSRecordContent> drc(DNSRecordContent::make(rr.qtype.getCode(), QClass::IN, rr.content));
202,785✔
302
  string content = drc->getZoneRepresentation();
202,785✔
303

304
  // SOA needs stripping too! XXX FIXME - also, this should not be here I think
305
  switch (rr.qtype.getCode()) {
202,785✔
306
  case QType::MX:
56✔
307
  case QType::SRV:
76✔
308
  case QType::CNAME:
208✔
309
  case QType::DNAME:
212✔
310
  case QType::NS:
432✔
311
    stripDomainSuffix(&content, d_transaction_qname.toString());
432✔
312
    // fallthrough
313
  default:
202,785✔
314
    if (d_of && *d_of) {
202,785!
315
      *d_of << qname << "\t" << rr.ttl << "\t" << rr.qtype.toString() << "\t" << content << endl;
202,785✔
316
    }
202,785✔
317
  }
202,785✔
318
  return true;
202,785✔
319
}
202,785✔
320

321
void Bind2Backend::getUpdatedPrimaries(vector<DomainInfo>& changedDomains, std::unordered_set<DNSName>& /* catalogs */, CatalogHashMap& /* catalogHashes */)
322
{
×
323
  vector<DomainInfo> consider;
×
324
  {
×
325
    auto state = s_state.read_lock();
×
326

327
    for (const auto& i : *state) {
×
328
      if (i.d_kind != DomainInfo::Primary && this->alsoNotify.empty() && i.d_also_notify.empty())
×
329
        continue;
×
330

331
      DomainInfo di;
×
332
      di.id = i.d_id;
×
333
      di.zone = i.d_name;
×
334
      di.last_check = i.d_lastcheck;
×
335
      di.notified_serial = i.d_lastnotified;
×
336
      di.backend = this;
×
337
      di.kind = DomainInfo::Primary;
×
338
      consider.push_back(std::move(di));
×
339
    }
×
340
  }
×
341

342
  SOAData soadata;
×
343
  for (DomainInfo& di : consider) {
×
344
    soadata.serial = 0;
×
345
    try {
×
346
      this->getSOA(di.zone, soadata); // we might not *have* a SOA yet, but this might trigger a load of it
×
347
    }
×
348
    catch (...) {
×
349
      continue;
×
350
    }
×
351
    if (di.notified_serial != soadata.serial) {
×
352
      BB2DomainInfo bbd;
×
353
      if (safeGetBBDomainInfo(di.id, &bbd)) {
×
354
        bbd.d_lastnotified = soadata.serial;
×
355
        safePutBBDomainInfo(bbd);
×
356
      }
×
357
      if (di.notified_serial) { // don't do notification storm on startup
×
358
        di.serial = soadata.serial;
×
359
        changedDomains.push_back(std::move(di));
×
360
      }
×
361
    }
×
362
  }
×
363
}
×
364

365
void Bind2Backend::getAllDomains(vector<DomainInfo>* domains, bool getSerial, bool /* include_disabled */)
366
{
90✔
367
  SOAData soadata;
90✔
368

369
  // prevent deadlock by using getSOA() later on
370
  {
90✔
371
    auto state = s_state.read_lock();
90✔
372
    domains->reserve(state->size());
90✔
373

374
    for (const auto& i : *state) {
250✔
375
      DomainInfo di;
185✔
376
      di.id = i.d_id;
185✔
377
      di.zone = i.d_name;
185✔
378
      di.last_check = i.d_lastcheck;
185✔
379
      di.kind = i.d_kind;
185✔
380
      di.primaries = i.d_primaries;
185✔
381
      di.backend = this;
185✔
382
      domains->push_back(std::move(di));
185✔
383
    };
185✔
384
  }
90✔
385

386
  if (getSerial) {
90✔
387
    for (DomainInfo& di : *domains) {
1,313✔
388
      // do not corrupt di if domain supplied by another backend.
389
      if (di.backend != this)
1,313!
390
        continue;
1,313✔
391
      try {
×
392
        this->getSOA(di.zone, soadata);
×
393
      }
×
394
      catch (...) {
×
395
        continue;
×
396
      }
×
397
      di.serial = soadata.serial;
×
398
    }
×
399
  }
40✔
400
}
90✔
401

402
void Bind2Backend::getUnfreshSecondaryInfos(vector<DomainInfo>* unfreshDomains)
403
{
8✔
404
  vector<DomainInfo> domains;
8✔
405
  {
8✔
406
    auto state = s_state.read_lock();
8✔
407
    domains.reserve(state->size());
8✔
408
    for (const auto& i : *state) {
72✔
409
      if (i.d_kind != DomainInfo::Secondary)
72!
410
        continue;
×
411
      DomainInfo sd;
72✔
412
      sd.id = i.d_id;
72✔
413
      sd.zone = i.d_name;
72✔
414
      sd.primaries = i.d_primaries;
72✔
415
      sd.last_check = i.d_lastcheck;
72✔
416
      sd.backend = this;
72✔
417
      sd.kind = DomainInfo::Secondary;
72✔
418
      domains.push_back(std::move(sd));
72✔
419
    }
72✔
420
  }
8✔
421
  unfreshDomains->reserve(domains.size());
8✔
422

423
  for (DomainInfo& sd : domains) {
72✔
424
    SOAData soadata;
72✔
425
    soadata.refresh = 0;
72✔
426
    soadata.serial = 0;
72✔
427
    try {
72✔
428
      getSOA(sd.zone, soadata); // we might not *have* a SOA yet
72✔
429
    }
72✔
430
    catch (...) {
72✔
431
    }
72✔
432
    sd.serial = soadata.serial;
72✔
433
    // coverity[store_truncates_time_t]
434
    if (sd.last_check + soadata.refresh < (unsigned int)time(nullptr))
72!
435
      unfreshDomains->push_back(std::move(sd));
72✔
436
  }
72✔
437
}
8✔
438

439
bool Bind2Backend::getDomainInfo(const ZoneName& domain, DomainInfo& info, bool getSerial)
440
{
1,002✔
441
  BB2DomainInfo bbd;
1,002✔
442
  if (!safeGetBBDomainInfo(domain, &bbd))
1,002✔
443
    return false;
557✔
444

445
  info.id = bbd.d_id;
445✔
446
  info.zone = domain;
445✔
447
  info.primaries = bbd.d_primaries;
445✔
448
  info.last_check = bbd.d_lastcheck;
445✔
449
  info.backend = this;
445✔
450
  info.kind = bbd.d_kind;
445✔
451
  info.serial = 0;
445✔
452
  if (getSerial) {
445✔
453
    try {
135✔
454
      SOAData sd;
135✔
455
      sd.serial = 0;
135✔
456

457
      getSOA(bbd.d_name, sd); // we might not *have* a SOA yet
135✔
458
      info.serial = sd.serial;
135✔
459
    }
135✔
460
    catch (...) {
135✔
461
    }
72✔
462
  }
135✔
463

464
  return true;
445✔
465
}
445✔
466

467
void Bind2Backend::alsoNotifies(const ZoneName& domain, set<string>* ips)
468
{
4✔
469
  // combine global list with local list
470
  for (const auto& i : this->alsoNotify) {
4!
471
    (*ips).insert(i);
×
472
  }
×
473
  // check metadata too if available
474
  vector<string> meta;
4✔
475
  if (getDomainMetadata(domain, "ALSO-NOTIFY", meta)) {
4!
476
    for (const auto& str : meta) {
×
477
      (*ips).insert(str);
×
478
    }
×
479
  }
×
480
  auto state = s_state.read_lock();
4✔
481
  for (const auto& i : *state) {
4!
482
    if (i.d_name == domain) {
×
483
      for (const auto& it : i.d_also_notify) {
×
484
        (*ips).insert(it);
×
485
      }
×
486
      return;
×
487
    }
×
488
  }
×
489
}
4✔
490

491
// only parses, does NOT add to s_state!
492
void Bind2Backend::parseZoneFile(BB2DomainInfo* bbd)
493
{
2,739✔
494
  NSEC3PARAMRecordContent ns3pr;
2,739✔
495
  bool nsec3zone = false;
2,739✔
496
  if (d_hybrid) {
2,739!
497
    DNSSECKeeper dk;
×
498
    nsec3zone = dk.getNSEC3PARAM(bbd->d_name, &ns3pr);
×
499
  }
×
500
  else
2,739✔
501
    nsec3zone = getNSEC3PARAMuncached(bbd->d_name, &ns3pr);
2,739✔
502

503
  auto records = std::make_shared<recordstorage_t>();
2,739✔
504
  ZoneParserTNG zpt(bbd->d_filename, bbd->d_name, s_binddirectory, d_upgradeContent);
2,739✔
505
  zpt.setMaxGenerateSteps(::arg().asNum("max-generate-steps"));
2,739✔
506
  zpt.setMaxIncludes(::arg().asNum("max-include-depth"));
2,739✔
507
  DNSResourceRecord rr;
2,739✔
508
  string hashed;
2,739✔
509
  while (zpt.get(rr)) {
3,277,135✔
510
    if (rr.qtype.getCode() == QType::NSEC || rr.qtype.getCode() == QType::NSEC3 || rr.qtype.getCode() == QType::NSEC3PARAM)
3,274,396!
511
      continue; // we synthesise NSECs on demand
×
512

513
    insertRecord(records, bbd->d_name, rr.qname, rr.qtype, rr.content, rr.ttl, "");
3,274,396✔
514
  }
3,274,396✔
515
  fixupOrderAndAuth(records, bbd->d_name, nsec3zone, ns3pr);
2,739✔
516
  doEmptyNonTerminals(records, bbd->d_name, nsec3zone, ns3pr);
2,739✔
517
  bbd->setCtime();
2,739✔
518
  bbd->d_loaded = true;
2,739✔
519
  bbd->d_checknow = false;
2,739✔
520
  bbd->d_status = "parsed into memory at " + nowTime();
2,739✔
521
  bbd->d_records = LookButDontTouch<recordstorage_t>(std::move(records));
2,739✔
522
  bbd->d_nsec3zone = nsec3zone;
2,739✔
523
  bbd->d_nsec3param = std::move(ns3pr);
2,739✔
524
}
2,739✔
525

526
/** THIS IS AN INTERNAL FUNCTION! It does moadnsparser prio impedance matching
527
    Much of the complication is due to the efforts to benefit from std::string reference counting copy on write semantics */
528
void Bind2Backend::insertRecord(std::shared_ptr<recordstorage_t>& records, const ZoneName& zoneName, const DNSName& qname, const QType& qtype, const string& content, int ttl, const std::string& hashed, const bool* auth)
529
{
3,279,012✔
530
  Bind2DNSRecord bdr;
3,279,012✔
531
  bdr.qname = qname;
3,279,012✔
532

533
  if (zoneName.empty())
3,279,012!
534
    ;
×
535
  else if (bdr.qname.isPartOf(zoneName))
3,279,012✔
536
    bdr.qname.makeUsRelative(zoneName);
3,278,710✔
537
  else {
302✔
538
    string msg = "Trying to insert non-zone data, name='" + bdr.qname.toLogString() + "', qtype=" + qtype.toString() + ", zone='" + zoneName.toLogString() + "'";
302✔
539
    if (s_ignore_broken_records) {
302!
540
      g_log << Logger::Warning << msg << " ignored" << endl;
302✔
541
      return;
302✔
542
    }
302✔
NEW
543
    throw PDNSException(std::move(msg));
×
544
  }
302✔
545

546
  //  bdr.qname.swap(bdr.qname);
547

548
  if (!records->empty() && bdr.qname == boost::prior(records->end())->qname)
3,278,710✔
549
    bdr.qname = boost::prior(records->end())->qname;
8,866✔
550

551
  bdr.qname = bdr.qname;
3,278,710✔
552
  bdr.qtype = qtype.getCode();
3,278,710✔
553
  bdr.content = content;
3,278,710✔
554
  bdr.nsec3hash = hashed;
3,278,710✔
555

556
  if (auth != nullptr) // Set auth on empty non-terminals
3,278,710✔
557
    bdr.auth = *auth;
4,616✔
558
  else
3,274,094✔
559
    bdr.auth = true;
3,274,094✔
560

561
  bdr.ttl = ttl;
3,278,710✔
562
  records->insert(std::move(bdr));
3,278,710✔
563
}
3,278,710✔
564

565
string Bind2Backend::DLReloadNowHandler(const vector<string>& parts, Utility::pid_t /* ppid */)
566
{
×
567
  ostringstream ret;
×
568

569
  for (auto i = parts.begin() + 1; i < parts.end(); ++i) {
×
570
    BB2DomainInfo bbd;
×
571
    ZoneName zone(*i);
×
572
    if (safeGetBBDomainInfo(zone, &bbd)) {
×
573
      Bind2Backend bb2;
×
574
      bb2.queueReloadAndStore(bbd.d_id);
×
575
      if (!safeGetBBDomainInfo(zone, &bbd)) // Read the *new* domain status
×
576
        ret << *i << ": [missing]\n";
×
577
      else
×
578
        ret << *i << ": " << (bbd.d_wasRejectedLastReload ? "[rejected]" : "") << "\t" << bbd.d_status << "\n";
×
579
      purgeAuthCaches(zone.toString() + "$");
×
580
      DNSSECKeeper::clearMetaCache(zone);
×
581
    }
×
582
    else
×
583
      ret << *i << " no such domain\n";
×
584
  }
×
585
  if (ret.str().empty())
×
586
    ret << "no domains reloaded";
×
587
  return ret.str();
×
588
}
×
589

590
string Bind2Backend::DLDomStatusHandler(const vector<string>& parts, Utility::pid_t /* ppid */)
591
{
27✔
592
  ostringstream ret;
27✔
593

594
  if (parts.size() > 1) {
27!
595
    for (auto i = parts.begin() + 1; i < parts.end(); ++i) {
×
596
      BB2DomainInfo bbd;
×
597
      if (safeGetBBDomainInfo(ZoneName(*i), &bbd)) {
×
598
        ret << *i << ": " << (bbd.d_loaded ? "" : "[rejected]") << "\t" << bbd.d_status << "\n";
×
599
      }
×
600
      else {
×
601
        ret << *i << " no such domain\n";
×
602
      }
×
603
    }
×
604
  }
×
605
  else {
27✔
606
    auto state = s_state.read_lock();
27✔
607
    for (const auto& i : *state) {
235✔
608
      ret << i.d_name << ": " << (i.d_loaded ? "" : "[rejected]") << "\t" << i.d_status << "\n";
235✔
609
    }
235✔
610
  }
27✔
611

612
  if (ret.str().empty())
27!
613
    ret << "no domains passed";
×
614

615
  return ret.str();
27✔
616
}
27✔
617

618
static void printDomainExtendedStatus(ostringstream& ret, const BB2DomainInfo& info)
619
{
×
620
  ret << info.d_name << ": " << std::endl;
×
621
  ret << "\t Status: " << info.d_status << std::endl;
×
622
  ret << "\t Internal ID: " << info.d_id << std::endl;
×
623
  ret << "\t On-disk file: " << info.d_filename << " (" << info.d_ctime << ")" << std::endl;
×
624
  ret << "\t Kind: ";
×
625
  switch (info.d_kind) {
×
626
  case DomainInfo::Primary:
×
627
    ret << "Primary";
×
628
    break;
×
629
  case DomainInfo::Secondary:
×
630
    ret << "Secondary";
×
631
    break;
×
632
  default:
×
633
    ret << "Native";
×
634
  }
×
635
  ret << std::endl;
×
636
  ret << "\t Primaries: " << std::endl;
×
637
  for (const auto& primary : info.d_primaries) {
×
638
    ret << "\t\t - " << primary.toStringWithPort() << std::endl;
×
639
  }
×
640
  ret << "\t Also Notify: " << std::endl;
×
641
  for (const auto& also : info.d_also_notify) {
×
642
    ret << "\t\t - " << also << std::endl;
×
643
  }
×
644
  ret << "\t Number of records: " << info.d_records.getEntriesCount() << std::endl;
×
645
  ret << "\t Loaded: " << info.d_loaded << std::endl;
×
646
  ret << "\t Check now: " << info.d_checknow << std::endl;
×
647
  ret << "\t Check interval: " << info.getCheckInterval() << std::endl;
×
648
  ret << "\t Last check: " << info.d_lastcheck << std::endl;
×
649
  ret << "\t Last notified: " << info.d_lastnotified << std::endl;
×
650
}
×
651

652
string Bind2Backend::DLDomExtendedStatusHandler(const vector<string>& parts, Utility::pid_t /* ppid */)
653
{
×
654
  ostringstream ret;
×
655

656
  if (parts.size() > 1) {
×
657
    for (auto i = parts.begin() + 1; i < parts.end(); ++i) {
×
658
      BB2DomainInfo bbd;
×
659
      if (safeGetBBDomainInfo(ZoneName(*i), &bbd)) {
×
660
        printDomainExtendedStatus(ret, bbd);
×
661
      }
×
662
      else {
×
663
        ret << *i << " no such domain" << std::endl;
×
664
      }
×
665
    }
×
666
  }
×
667
  else {
×
668
    auto rstate = s_state.read_lock();
×
669
    for (const auto& state : *rstate) {
×
670
      printDomainExtendedStatus(ret, state);
×
671
    }
×
672
  }
×
673

674
  if (ret.str().empty()) {
×
675
    ret << "no domains passed" << std::endl;
×
676
  }
×
677

678
  return ret.str();
×
679
}
×
680

681
string Bind2Backend::DLListRejectsHandler(const vector<string>& /* parts */, Utility::pid_t /* ppid */)
682
{
×
683
  ostringstream ret;
×
684
  auto rstate = s_state.read_lock();
×
685
  for (const auto& i : *rstate) {
×
686
    if (!i.d_loaded)
×
687
      ret << i.d_name << "\t" << i.d_status << endl;
×
688
  }
×
689
  return ret.str();
×
690
}
×
691

692
string Bind2Backend::DLAddDomainHandler(const vector<string>& parts, Utility::pid_t /* ppid */)
693
{
12✔
694
  if (parts.size() < 3)
12!
695
    return "ERROR: Domain name and zone filename are required";
×
696

697
  ZoneName domainname(parts[1]);
12✔
698
  const string& filename = parts[2];
12✔
699
  BB2DomainInfo bbd;
12✔
700
  if (safeGetBBDomainInfo(domainname, &bbd))
12✔
701
    return "Already loaded";
6✔
702

703
  if (!boost::starts_with(filename, "/") && ::arg()["chroot"].empty())
6!
704
    return "Unable to load zone " + domainname.toLogString() + " from " + filename + " as the filename is not absolute.";
×
705

706
  struct stat buf;
6✔
707
  if (stat(filename.c_str(), &buf) != 0)
6!
708
    return "Unable to load zone " + domainname.toLogString() + " from " + filename + ": " + strerror(errno);
×
709

710
  Bind2Backend bb2; // createdomainentry needs access to our configuration
6✔
711
  bbd = bb2.createDomainEntry(domainname, filename);
6✔
712
  bbd.d_filename = filename;
6✔
713
  bbd.d_checknow = true;
6✔
714
  bbd.d_loaded = true;
6✔
715
  bbd.d_lastcheck = 0;
6✔
716
  bbd.d_status = "parsing into memory";
6✔
717
  bbd.setCtime();
6✔
718

719
  safePutBBDomainInfo(bbd);
6✔
720

721
  g_zoneCache.add(domainname, bbd.d_id); // make new zone visible
6✔
722

723
  g_log << Logger::Warning << "Zone " << domainname << " loaded" << endl;
6✔
724
  return "Loaded zone " + domainname.toLogString() + " from " + filename;
6✔
725
}
6✔
726

727
Bind2Backend::Bind2Backend(const string& suffix, bool loadZones)
728
{
3,133✔
729
  d_getAllDomainMetadataQuery_stmt = nullptr;
3,133✔
730
  d_getDomainMetadataQuery_stmt = nullptr;
3,133✔
731
  d_deleteDomainMetadataQuery_stmt = nullptr;
3,133✔
732
  d_insertDomainMetadataQuery_stmt = nullptr;
3,133✔
733
  d_getDomainKeysQuery_stmt = nullptr;
3,133✔
734
  d_deleteDomainKeyQuery_stmt = nullptr;
3,133✔
735
  d_insertDomainKeyQuery_stmt = nullptr;
3,133✔
736
  d_GetLastInsertedKeyIdQuery_stmt = nullptr;
3,133✔
737
  d_activateDomainKeyQuery_stmt = nullptr;
3,133✔
738
  d_deactivateDomainKeyQuery_stmt = nullptr;
3,133✔
739
  d_getTSIGKeyQuery_stmt = nullptr;
3,133✔
740
  d_setTSIGKeyQuery_stmt = nullptr;
3,133✔
741
  d_deleteTSIGKeyQuery_stmt = nullptr;
3,133✔
742
  d_getTSIGKeysQuery_stmt = nullptr;
3,133✔
743

744
  setArgPrefix("bind" + suffix);
3,133✔
745
  d_logprefix = "[bind" + suffix + "backend]";
3,133✔
746
  d_hybrid = mustDo("hybrid");
3,133✔
747
  if (d_hybrid && g_zoneCache.isEnabled()) {
3,133!
748
    throw PDNSException("bind-hybrid and the zone cache currently interoperate badly. Please disable the zone cache or stop using bind-hybrid");
×
749
  }
×
750

751
  d_transaction_id = 0;
3,133✔
752
  s_ignore_broken_records = mustDo("ignore-broken-records");
3,133✔
753
  d_upgradeContent = ::arg().mustDo("upgrade-unknown-types");
3,133✔
754

755
  if (!loadZones && d_hybrid)
3,133!
756
    return;
×
757

758
  std::lock_guard<std::mutex> l(s_startup_lock);
3,133✔
759

760
  setupDNSSEC();
3,133✔
761
  if (s_first == 0) {
3,133✔
762
    return;
2,375✔
763
  }
2,375✔
764

765
  if (loadZones) {
758✔
766
    loadConfig();
315✔
767
    s_first = 0;
315✔
768
  }
315✔
769

770
  DynListener::registerFunc("BIND-RELOAD-NOW", &DLReloadNowHandler, "bindbackend: reload domains", "<domains>");
758✔
771
  DynListener::registerFunc("BIND-DOMAIN-STATUS", &DLDomStatusHandler, "bindbackend: list status of all domains", "[domains]");
758✔
772
  DynListener::registerFunc("BIND-DOMAIN-EXTENDED-STATUS", &DLDomExtendedStatusHandler, "bindbackend: list the extended status of all domains", "[domains]");
758✔
773
  DynListener::registerFunc("BIND-LIST-REJECTS", &DLListRejectsHandler, "bindbackend: list rejected domains");
758✔
774
  DynListener::registerFunc("BIND-ADD-ZONE", &DLAddDomainHandler, "bindbackend: add zone", "<domain> <filename>");
758✔
775
}
758✔
776

777
Bind2Backend::~Bind2Backend()
778
{
3,009✔
779
  freeStatements();
3,009✔
780
} // deallocate statements
3,009✔
781

782
void Bind2Backend::rediscover(string* status)
783
{
×
784
  loadConfig(status);
×
785
}
×
786

787
void Bind2Backend::reload()
788
{
×
789
  auto state = s_state.write_lock();
×
790
  for (const auto& i : *state) {
×
791
    i.d_checknow = true; // being a bit cheeky here, don't index state_t on this (mutable)
×
792
  }
×
793
}
×
794

795
void Bind2Backend::fixupOrderAndAuth(std::shared_ptr<recordstorage_t>& records, const ZoneName& zoneName, bool nsec3zone, const NSEC3PARAMRecordContent& ns3pr)
796
{
2,667✔
797
  bool skip;
2,667✔
798
  DNSName shorter;
2,667✔
799
  set<DNSName> nssets, dssets;
2,667✔
800

801
  for (const auto& bdr : *records) {
3,274,094✔
802
    if (!bdr.qname.isRoot() && bdr.qtype == QType::NS)
3,274,094✔
803
      nssets.insert(bdr.qname);
3,010✔
804
    else if (bdr.qtype == QType::DS)
3,271,084✔
805
      dssets.insert(bdr.qname);
499✔
806
  }
3,274,094✔
807

808
  for (auto iter = records->begin(); iter != records->end(); iter++) {
3,276,761✔
809
    skip = false;
3,274,094✔
810
    shorter = iter->qname;
3,274,094✔
811

812
    if (!iter->qname.isRoot() && shorter.chopOff() && !iter->qname.isRoot()) {
3,274,094!
813
      do {
3,272,545✔
814
        if (nssets.count(shorter) != 0u) {
3,272,545✔
815
          skip = true;
1,359✔
816
          break;
1,359✔
817
        }
1,359✔
818
      } while (shorter.chopOff() && !iter->qname.isRoot());
3,272,545!
819
    }
3,262,957✔
820

821
    iter->auth = (!skip && (iter->qtype == QType::DS || iter->qtype == QType::RRSIG || (nssets.count(iter->qname) == 0u)));
3,274,094✔
822

823
    if (!skip && nsec3zone && iter->qtype != QType::RRSIG && (iter->auth || (iter->qtype == QType::NS && (ns3pr.d_flags == 0u)) || (dssets.count(iter->qname) != 0u))) {
3,274,094✔
824
      Bind2DNSRecord bdr = *iter;
1,439,445✔
825
      bdr.nsec3hash = toBase32Hex(hashQNameWithSalt(ns3pr, bdr.qname + zoneName.operator const DNSName&()));
1,439,445✔
826
      records->replace(iter, bdr);
1,439,445✔
827
    }
1,439,445✔
828

829
    // cerr<<iter->qname<<"\t"<<QType(iter->qtype).toString()<<"\t"<<iter->nsec3hash<<"\t"<<iter->auth<<endl;
830
  }
3,274,094✔
831
}
2,667✔
832

833
void Bind2Backend::doEmptyNonTerminals(std::shared_ptr<recordstorage_t>& records, const ZoneName& zoneName, bool nsec3zone, const NSEC3PARAMRecordContent& ns3pr)
834
{
2,667✔
835
  bool auth = false;
2,667✔
836
  DNSName shorter;
2,667✔
837
  std::unordered_set<DNSName> qnames;
2,667✔
838
  std::unordered_map<DNSName, bool> nonterm;
2,667✔
839

840
  uint32_t maxent = ::arg().asNum("max-ent-entries");
2,667✔
841

842
  for (const auto& bdr : *records)
2,667✔
843
    qnames.insert(bdr.qname);
3,274,094✔
844

845
  for (const auto& bdr : *records) {
3,274,094✔
846

847
    if (!bdr.auth && bdr.qtype == QType::NS)
3,274,094✔
848
      auth = (!nsec3zone || (ns3pr.d_flags == 0u));
3,010✔
849
    else
3,271,084✔
850
      auth = bdr.auth;
3,271,084✔
851

852
    shorter = bdr.qname;
3,274,094✔
853
    while (shorter.chopOff()) {
6,547,998✔
854
      if (qnames.count(shorter) == 0u) {
3,273,904✔
855
        if (!(maxent)) {
9,422!
856
          g_log << Logger::Error << "Zone '" << zoneName << "' has too many empty non terminals." << endl;
×
857
          return;
×
858
        }
×
859

860
        if (nonterm.count(shorter) == 0u) {
9,422✔
861
          nonterm.emplace(shorter, auth);
4,616✔
862
          --maxent;
4,616✔
863
        }
4,616✔
864
        else if (auth)
4,806✔
865
          nonterm[shorter] = true;
4,710✔
866
      }
9,422✔
867
    }
3,273,904✔
868
  }
3,274,094✔
869

870
  DNSResourceRecord rr;
2,667✔
871
  rr.qtype = "#0";
2,667✔
872
  rr.content = "";
2,667✔
873
  rr.ttl = 0;
2,667✔
874
  for (auto& nt : nonterm) {
4,619✔
875
    string hashed;
4,616✔
876
    rr.qname = nt.first + zoneName.operator const DNSName&();
4,616✔
877
    if (nsec3zone && nt.second)
4,616✔
878
      hashed = toBase32Hex(hashQNameWithSalt(ns3pr, rr.qname));
1,782✔
879
    insertRecord(records, zoneName, rr.qname, rr.qtype, rr.content, rr.ttl, hashed, &nt.second);
4,616✔
880

881
    // cerr<<rr.qname<<"\t"<<rr.qtype.toString()<<"\t"<<hashed<<"\t"<<nt.second<<endl;
882
  }
4,616✔
883
}
2,667✔
884

885
void Bind2Backend::loadConfig(string* status) // NOLINT(readability-function-cognitive-complexity) 13379 https://github.com/PowerDNS/pdns/issues/13379 Habbie: zone2sql.cc, bindbackend2.cc: reduce complexity
886
{
315✔
887
  static int domain_id = 1;
315✔
888

889
  if (!getArg("config").empty()) {
315!
890
    BindParser BP;
315✔
891
    try {
315✔
892
      BP.parse(getArg("config"));
315✔
893
    }
315✔
894
    catch (PDNSException& ae) {
315✔
895
      g_log << Logger::Error << "Error parsing bind configuration: " << ae.reason << endl;
×
896
      throw;
×
897
    }
×
898

899
    vector<BindDomainInfo> domains = BP.getDomains();
315✔
900
    this->alsoNotify = BP.getAlsoNotify();
315✔
901

902
    s_binddirectory = BP.getDirectory();
315✔
903
    //    ZP.setDirectory(d_binddirectory);
904

905
    g_log << Logger::Warning << d_logprefix << " Parsing " << domains.size() << " domain(s), will report when done" << endl;
315✔
906

907
    set<ZoneName> oldnames;
315✔
908
    set<ZoneName> newnames;
315✔
909
    {
315✔
910
      auto state = s_state.read_lock();
315✔
911
      for (const BB2DomainInfo& bbd : *state) {
315!
912
        oldnames.insert(bbd.d_name);
×
913
      }
×
914
    }
315✔
915
    int rejected = 0;
315✔
916
    int newdomains = 0;
315✔
917

918
    struct stat st;
315✔
919

920
    for (auto& domain : domains) {
2,795✔
921
      if (stat(domain.filename.c_str(), &st) == 0) {
2,661✔
922
        domain.d_dev = st.st_dev;
2,589✔
923
        domain.d_ino = st.st_ino;
2,589✔
924
      }
2,589✔
925
    }
2,661✔
926

927
    sort(domains.begin(), domains.end()); // put stuff in inode order
315✔
928
    for (const auto& domain : domains) {
2,795✔
929
      if (!(domain.hadFileDirective)) {
2,661!
930
        g_log << Logger::Warning << d_logprefix << " Zone '" << domain.name << "' has no 'file' directive set in " << getArg("config") << endl;
×
931
        rejected++;
×
932
        continue;
×
933
      }
×
934

935
      if (domain.type.empty()) {
2,661!
936
        g_log << Logger::Notice << d_logprefix << " Zone '" << domain.name << "' has no type specified, assuming 'native'" << endl;
×
937
      }
×
938
      if (domain.type != "primary" && domain.type != "secondary" && domain.type != "native" && !domain.type.empty() && domain.type != "master" && domain.type != "slave") {
2,661!
939
        g_log << Logger::Warning << d_logprefix << " Warning! Skipping zone '" << domain.name << "' because type '" << domain.type << "' is invalid" << endl;
×
940
        rejected++;
×
941
        continue;
×
942
      }
×
943

944
      BB2DomainInfo bbd;
2,661✔
945
      bool isNew = false;
2,661✔
946

947
      if (!safeGetBBDomainInfo(domain.name, &bbd)) {
2,661!
948
        isNew = true;
2,661✔
949
        bbd.d_id = domain_id++;
2,661✔
950
        bbd.setCheckInterval(getArgAsNum("check-interval"));
2,661✔
951
        bbd.d_lastnotified = 0;
2,661✔
952
        bbd.d_loaded = false;
2,661✔
953
      }
2,661✔
954

955
      // overwrite what we knew about the domain
956
      bbd.d_name = domain.name;
2,661✔
957
      bool filenameChanged = (bbd.d_filename != domain.filename);
2,661✔
958
      bool addressesChanged = (bbd.d_primaries != domain.primaries || bbd.d_also_notify != domain.alsoNotify);
2,661!
959
      bbd.d_filename = domain.filename;
2,661✔
960
      bbd.d_primaries = domain.primaries;
2,661✔
961
      bbd.d_also_notify = domain.alsoNotify;
2,661✔
962

963
      DomainInfo::DomainKind kind = DomainInfo::Native;
2,661✔
964
      if (domain.type == "primary" || domain.type == "master") {
2,661!
965
        kind = DomainInfo::Primary;
2,589✔
966
      }
2,589✔
967
      if (domain.type == "secondary" || domain.type == "slave") {
2,661!
968
        kind = DomainInfo::Secondary;
72✔
969
      }
72✔
970

971
      bool kindChanged = (bbd.d_kind != kind);
2,661✔
972
      bbd.d_kind = kind;
2,661✔
973

974
      newnames.insert(bbd.d_name);
2,661✔
975
      if (filenameChanged || !bbd.d_loaded || !bbd.current()) {
2,661!
976
        g_log << Logger::Info << d_logprefix << " parsing '" << domain.name << "' from file '" << domain.filename << "'" << endl;
2,661✔
977

978
        try {
2,661✔
979
          parseZoneFile(&bbd);
2,661✔
980
        }
2,661✔
981
        catch (PDNSException& ae) {
2,661✔
982
          ostringstream msg;
×
983
          msg << " error at " + nowTime() + " parsing '" << domain.name << "' from file '" << domain.filename << "': " << ae.reason;
×
984

985
          if (status != nullptr)
×
986
            *status += msg.str();
×
987
          bbd.d_status = msg.str();
×
988

989
          g_log << Logger::Warning << d_logprefix << msg.str() << endl;
×
990
          rejected++;
×
991
        }
×
992
        catch (std::system_error& ae) {
2,661✔
993
          ostringstream msg;
72✔
994
          if (ae.code().value() == ENOENT && isNew && domain.type == "slave")
72!
995
            msg << " error at " + nowTime() << " no file found for new secondary domain '" << domain.name << "'. Has not been AXFR'd yet";
×
996
          else
72✔
997
            msg << " error at " + nowTime() + " parsing '" << domain.name << "' from file '" << domain.filename << "': " << ae.what();
72✔
998

999
          if (status != nullptr)
72!
1000
            *status += msg.str();
×
1001
          bbd.d_status = msg.str();
72✔
1002
          g_log << Logger::Warning << d_logprefix << msg.str() << endl;
72✔
1003
          rejected++;
72✔
1004
        }
72✔
1005
        catch (std::exception& ae) {
2,661✔
1006
          ostringstream msg;
×
1007
          msg << " error at " + nowTime() + " parsing '" << domain.name << "' from file '" << domain.filename << "': " << ae.what();
×
1008

1009
          if (status != nullptr)
×
1010
            *status += msg.str();
×
1011
          bbd.d_status = msg.str();
×
1012

1013
          g_log << Logger::Warning << d_logprefix << msg.str() << endl;
×
1014
          rejected++;
×
1015
        }
×
1016
        safePutBBDomainInfo(bbd);
2,661✔
1017
      }
2,661✔
1018
      else if (addressesChanged || kindChanged) {
×
1019
        safePutBBDomainInfo(bbd);
×
1020
      }
×
1021
    }
2,661✔
1022
    vector<ZoneName> diff;
315✔
1023

1024
    set_difference(oldnames.begin(), oldnames.end(), newnames.begin(), newnames.end(), back_inserter(diff));
315✔
1025
    unsigned int remdomains = diff.size();
315✔
1026

1027
    for (const ZoneName& name : diff) {
315!
1028
      safeRemoveBBDomainInfo(name);
×
1029
    }
×
1030

1031
    // count number of entirely new domains
1032
    diff.clear();
315✔
1033
    set_difference(newnames.begin(), newnames.end(), oldnames.begin(), oldnames.end(), back_inserter(diff));
315✔
1034
    newdomains = diff.size();
315✔
1035

1036
    ostringstream msg;
315✔
1037
    msg << " Done parsing domains, " << rejected << " rejected, " << newdomains << " new, " << remdomains << " removed";
315✔
1038
    if (status != nullptr)
315!
1039
      *status = msg.str();
×
1040

1041
    g_log << Logger::Error << d_logprefix << msg.str() << endl;
315✔
1042
  }
315✔
1043
}
315✔
1044

1045
void Bind2Backend::queueReloadAndStore(unsigned int id)
1046
{
78✔
1047
  BB2DomainInfo bbold;
78✔
1048
  try {
78✔
1049
    if (!safeGetBBDomainInfo(id, &bbold))
78!
1050
      return;
×
1051
    bbold.d_checknow = false;
78✔
1052
    BB2DomainInfo bbnew(bbold);
78✔
1053
    /* make sure that nothing will be able to alter the existing records,
1054
       we will load them from the zone file instead */
1055
    bbnew.d_records = LookButDontTouch<recordstorage_t>();
78✔
1056
    parseZoneFile(&bbnew);
78✔
1057
    bbnew.d_wasRejectedLastReload = false;
78✔
1058
    safePutBBDomainInfo(bbnew);
78✔
1059
    g_log << Logger::Warning << "Zone '" << bbnew.d_name << "' (" << bbnew.d_filename << ") reloaded" << endl;
78✔
1060
  }
78✔
1061
  catch (PDNSException& ae) {
78✔
1062
    ostringstream msg;
×
1063
    msg << " error at " + nowTime() + " parsing '" << bbold.d_name << "' from file '" << bbold.d_filename << "': " << ae.reason;
×
1064
    g_log << Logger::Warning << "Error parsing '" << bbold.d_name << "' from file '" << bbold.d_filename << "': " << ae.reason << endl;
×
1065
    bbold.d_status = msg.str();
×
1066
    bbold.d_lastcheck = time(nullptr);
×
1067
    bbold.d_wasRejectedLastReload = true;
×
1068
    safePutBBDomainInfo(bbold);
×
1069
  }
×
1070
  catch (std::exception& ae) {
78✔
1071
    ostringstream msg;
×
1072
    msg << " error at " + nowTime() + " parsing '" << bbold.d_name << "' from file '" << bbold.d_filename << "': " << ae.what();
×
1073
    g_log << Logger::Warning << "Error parsing '" << bbold.d_name << "' from file '" << bbold.d_filename << "': " << ae.what() << endl;
×
1074
    bbold.d_status = msg.str();
×
1075
    bbold.d_lastcheck = time(nullptr);
×
1076
    bbold.d_wasRejectedLastReload = true;
×
1077
    safePutBBDomainInfo(bbold);
×
1078
  }
×
1079
}
78✔
1080

1081
bool Bind2Backend::findBeforeAndAfterUnhashed(std::shared_ptr<const recordstorage_t>& records, const DNSName& qname, DNSName& /* unhashed */, DNSName& before, DNSName& after)
1082
{
2,602✔
1083
  // for(const auto& record: *records)
1084
  //   cerr<<record.qname<<"\t"<<makeHexDump(record.qname.toDNSString())<<endl;
1085

1086
  recordstorage_t::const_iterator iterBefore, iterAfter;
2,602✔
1087

1088
  iterBefore = iterAfter = records->upper_bound(qname.makeLowerCase());
2,602✔
1089

1090
  if (iterBefore != records->begin())
2,602!
1091
    --iterBefore;
2,602✔
1092
  while ((!iterBefore->auth && iterBefore->qtype != QType::NS) || !iterBefore->qtype)
3,131✔
1093
    --iterBefore;
529✔
1094
  before = iterBefore->qname;
2,602✔
1095

1096
  if (iterAfter == records->end()) {
2,602✔
1097
    iterAfter = records->begin();
376✔
1098
  }
376✔
1099
  else {
2,226✔
1100
    while ((!iterAfter->auth && iterAfter->qtype != QType::NS) || !iterAfter->qtype) {
3,318✔
1101
      ++iterAfter;
1,092✔
1102
      if (iterAfter == records->end()) {
1,092!
1103
        iterAfter = records->begin();
×
1104
        break;
×
1105
      }
×
1106
    }
1,092✔
1107
  }
2,226✔
1108
  after = iterAfter->qname;
2,602✔
1109

1110
  return true;
2,602✔
1111
}
2,602✔
1112

1113
bool Bind2Backend::getBeforeAndAfterNamesAbsolute(uint32_t id, const DNSName& qname, DNSName& unhashed, DNSName& before, DNSName& after)
1114
{
6,756✔
1115
  BB2DomainInfo bbd;
6,756✔
1116
  if (!safeGetBBDomainInfo(id, &bbd))
6,756!
1117
    return false;
×
1118

1119
  shared_ptr<const recordstorage_t> records = bbd.d_records.get();
6,756✔
1120
  if (!bbd.d_nsec3zone) {
6,756✔
1121
    return findBeforeAndAfterUnhashed(records, qname, unhashed, before, after);
2,602✔
1122
  }
2,602✔
1123
  else {
4,154✔
1124
    const auto& hashindex = boost::multi_index::get<NSEC3Tag>(*records);
4,154✔
1125

1126
    // for(auto iter = first; iter != hashindex.end(); iter++)
1127
    //  cerr<<iter->nsec3hash<<endl;
1128

1129
    auto first = hashindex.upper_bound("");
4,154✔
1130
    auto iter = hashindex.upper_bound(qname.toStringNoDot());
4,154✔
1131

1132
    if (iter == hashindex.end()) {
4,154✔
1133
      --iter;
338✔
1134
      before = DNSName(iter->nsec3hash);
338✔
1135
      after = DNSName(first->nsec3hash);
338✔
1136
    }
338✔
1137
    else {
3,816✔
1138
      after = DNSName(iter->nsec3hash);
3,816✔
1139
      if (iter != first)
3,816✔
1140
        --iter;
3,734✔
1141
      else
82✔
1142
        iter = --hashindex.end();
82✔
1143
      before = DNSName(iter->nsec3hash);
3,816✔
1144
    }
3,816✔
1145
    unhashed = iter->qname + bbd.d_name.operator const DNSName&();
4,154✔
1146

1147
    return true;
4,154✔
1148
  }
4,154✔
1149
}
6,756✔
1150

1151
void Bind2Backend::lookup(const QType& qtype, const DNSName& qname, int zoneId, DNSPacket* /* pkt_p */)
1152
{
4,107✔
1153
  d_handle.reset();
4,107✔
1154

1155
  static bool mustlog = ::arg().mustDo("query-logging");
4,107✔
1156

1157
  bool found = false;
4,107✔
1158
  ZoneName domain;
4,107✔
1159
  BB2DomainInfo bbd;
4,107✔
1160

1161
  if (mustlog)
4,107!
1162
    g_log << Logger::Warning << "Lookup for '" << qtype.toString() << "' of '" << qname << "' within zoneID " << zoneId << endl;
×
1163

1164
  if (zoneId >= 0) {
4,107✔
1165
    if ((found = (safeGetBBDomainInfo(zoneId, &bbd) && qname.isPartOf(bbd.d_name)))) {
3,286!
1166
      domain = std::move(bbd.d_name);
3,286✔
1167
    }
3,286✔
1168
  }
3,286✔
1169
  else {
821✔
1170
    domain = ZoneName(qname);
821✔
1171
    do {
824✔
1172
      found = safeGetBBDomainInfo(domain, &bbd);
824✔
1173
    } while (!found && qtype != QType::SOA && domain.chopOff());
824✔
1174
  }
821✔
1175

1176
  if (!found) {
4,107✔
1177
    if (mustlog)
24!
1178
      g_log << Logger::Warning << "Found no authoritative zone for '" << qname << "' and/or id " << zoneId << endl;
×
1179
    d_handle.d_list = false;
24✔
1180
    return;
24✔
1181
  }
24✔
1182

1183
  if (mustlog)
4,083!
1184
    g_log << Logger::Warning << "Found a zone '" << domain << "' (with id " << bbd.d_id << ") that might contain data " << endl;
×
1185

1186
  d_handle.id = bbd.d_id;
4,083✔
1187
  d_handle.qname = qname.makeRelative(domain); // strip domain name
4,083✔
1188
  d_handle.qtype = qtype;
4,083✔
1189
  d_handle.domain = std::move(domain);
4,083✔
1190

1191
  if (!bbd.current()) {
4,083✔
1192
    g_log << Logger::Warning << "Zone '" << d_handle.domain << "' (" << bbd.d_filename << ") needs reloading" << endl;
6✔
1193
    queueReloadAndStore(bbd.d_id);
6✔
1194
    if (!safeGetBBDomainInfo(d_handle.domain, &bbd))
6!
1195
      throw DBException("Zone '" + bbd.d_name.toLogString() + "' (" + bbd.d_filename + ") gone after reload"); // if we don't throw here, we crash for some reason
×
1196
  }
6✔
1197

1198
  if (!bbd.d_loaded) {
4,083✔
1199
    d_handle.reset();
216✔
1200
    throw DBException("Zone for '" + d_handle.domain.toLogString() + "' in '" + bbd.d_filename + "' not loaded (file missing, corrupt or primary dead)"); // fsck
216✔
1201
  }
216✔
1202

1203
  d_handle.d_records = bbd.d_records.get();
3,867✔
1204

1205
  if (d_handle.d_records->empty())
3,867!
1206
    DLOG(g_log << "Query with no results" << endl);
×
1207

1208
  d_handle.mustlog = mustlog;
3,867✔
1209

1210
  const auto& hashedidx = boost::multi_index::get<UnorderedNameTag>(*d_handle.d_records);
3,867✔
1211
  auto range = hashedidx.equal_range(d_handle.qname);
3,867✔
1212

1213
  d_handle.d_list = false;
3,867✔
1214
  d_handle.d_iter = range.first;
3,867✔
1215
  d_handle.d_end_iter = range.second;
3,867✔
1216
}
3,867✔
1217

1218
Bind2Backend::handle::handle()
1219
{
3,133✔
1220
  mustlog = false;
3,133✔
1221
}
3,133✔
1222

1223
bool Bind2Backend::get(DNSResourceRecord& r)
1224
{
197,862✔
1225
  if (!d_handle.d_records) {
197,862✔
1226
    if (d_handle.mustlog)
24!
1227
      g_log << Logger::Warning << "There were no answers" << endl;
×
1228
    return false;
24✔
1229
  }
24✔
1230

1231
  if (!d_handle.get(r)) {
197,838✔
1232
    if (d_handle.mustlog)
4,198!
1233
      g_log << Logger::Warning << "End of answers" << endl;
×
1234

1235
    d_handle.reset();
4,198✔
1236

1237
    return false;
4,198✔
1238
  }
4,198✔
1239
  if (d_handle.mustlog)
193,640!
1240
    g_log << Logger::Warning << "Returning: '" << r.qtype.toString() << "' of '" << r.qname << "', content: '" << r.content << "'" << endl;
×
1241
  return true;
193,640✔
1242
}
197,838✔
1243

1244
bool Bind2Backend::handle::get(DNSResourceRecord& r)
1245
{
197,838✔
1246
  if (d_list)
197,838✔
1247
    return get_list(r);
188,900✔
1248
  else
8,938✔
1249
    return get_normal(r);
8,938✔
1250
}
197,838✔
1251

1252
void Bind2Backend::handle::reset()
1253
{
8,852✔
1254
  d_records.reset();
8,852✔
1255
  qname.clear();
8,852✔
1256
  mustlog = false;
8,852✔
1257
}
8,852✔
1258

1259
//#define DLOG(x) x
1260
bool Bind2Backend::handle::get_normal(DNSResourceRecord& r)
1261
{
8,938✔
1262
  DLOG(g_log << "Bind2Backend get() was called for " << qtype.toString() << " record for '" << qname << "' - " << d_records->size() << " available in total!" << endl);
8,938✔
1263

1264
  if (d_iter == d_end_iter) {
8,938✔
1265
    return false;
3,867✔
1266
  }
3,867✔
1267

1268
  while (d_iter != d_end_iter && !(qtype.getCode() == QType::ANY || (d_iter)->qtype == qtype.getCode())) {
7,804!
1269
    DLOG(g_log << Logger::Warning << "Skipped " << qname << "/" << QType(d_iter->qtype).toString() << ": '" << d_iter->content << "'" << endl);
2,733✔
1270
    d_iter++;
2,733✔
1271
  }
2,733✔
1272
  if (d_iter == d_end_iter) {
5,071!
1273
    return false;
×
1274
  }
×
1275
  DLOG(g_log << "Bind2Backend get() returning a rr with a " << QType(d_iter->qtype).getCode() << endl);
5,071✔
1276

1277
  const DNSName& domainName(domain);
5,071✔
1278
  r.qname = qname.empty() ? domainName : (qname + domainName);
5,071!
1279
  r.domain_id = id;
5,071✔
1280
  r.content = (d_iter)->content;
5,071✔
1281
  //  r.domain_id=(d_iter)->domain_id;
1282
  r.qtype = (d_iter)->qtype;
5,071✔
1283
  r.ttl = (d_iter)->ttl;
5,071✔
1284

1285
  //if(!d_iter->auth && r.qtype.getCode() != QType::A && r.qtype.getCode()!=QType::AAAA && r.qtype.getCode() != QType::NS)
1286
  //  cerr<<"Warning! Unauth response for qtype "<< r.qtype.toString() << " for '"<<r.qname<<"'"<<endl;
1287
  r.auth = d_iter->auth;
5,071✔
1288

1289
  d_iter++;
5,071✔
1290

1291
  return true;
5,071✔
1292
}
5,071✔
1293

1294
bool Bind2Backend::list(const ZoneName& /* target */, int domainId, bool /* include_disabled */)
1295
{
331✔
1296
  BB2DomainInfo bbd;
331✔
1297

1298
  if (!safeGetBBDomainInfo(domainId, &bbd)) {
331!
1299
    return false;
×
1300
  }
×
1301

1302
  d_handle.reset();
331✔
1303
  DLOG(g_log << "Bind2Backend constructing handle for list of " << domainId << endl);
331✔
1304

1305
  if (!bbd.d_loaded) {
331!
1306
    throw PDNSException("zone was not loaded, perhaps because of: " + bbd.d_status);
×
1307
  }
×
1308

1309
  d_handle.d_records = bbd.d_records.get(); // give it a copy, which will stay around
331✔
1310
  d_handle.d_qname_iter = d_handle.d_records->begin();
331✔
1311
  d_handle.d_qname_end = d_handle.d_records->end(); // iter now points to a vector of pointers to vector<BBResourceRecords>
331✔
1312

1313
  d_handle.id = domainId;
331✔
1314
  d_handle.domain = bbd.d_name;
331✔
1315
  d_handle.d_list = true;
331✔
1316
  return true;
331✔
1317
}
331✔
1318

1319
bool Bind2Backend::handle::get_list(DNSResourceRecord& r)
1320
{
188,900✔
1321
  if (d_qname_iter != d_qname_end) {
188,900✔
1322
    const DNSName& domainName(domain);
188,569✔
1323
    r.qname = d_qname_iter->qname.empty() ? domainName : (d_qname_iter->qname + domainName);
188,569!
1324
    r.domain_id = id;
188,569✔
1325
    r.content = (d_qname_iter)->content;
188,569✔
1326
    r.qtype = (d_qname_iter)->qtype;
188,569✔
1327
    r.ttl = (d_qname_iter)->ttl;
188,569✔
1328
    r.auth = d_qname_iter->auth;
188,569✔
1329
    d_qname_iter++;
188,569✔
1330
    return true;
188,569✔
1331
  }
188,569✔
1332
  return false;
331✔
1333
}
188,900✔
1334

1335
bool Bind2Backend::autoPrimariesList(std::vector<AutoPrimary>& primaries)
1336
{
×
1337
  if (getArg("autoprimary-config").empty())
×
1338
    return false;
×
1339

1340
  ifstream c_if(getArg("autoprimaries"), std::ios::in);
×
1341
  if (!c_if) {
×
1342
    g_log << Logger::Error << "Unable to open autoprimaries file for read: " << stringerror() << endl;
×
1343
    return false;
×
1344
  }
×
1345

1346
  string line, sip, saccount;
×
1347
  while (getline(c_if, line)) {
×
1348
    std::istringstream ii(line);
×
1349
    ii >> sip;
×
1350
    if (!sip.empty()) {
×
1351
      ii >> saccount;
×
1352
      primaries.emplace_back(sip, "", saccount);
×
1353
    }
×
1354
  }
×
1355

1356
  c_if.close();
×
1357
  return true;
×
1358
}
×
1359

1360
bool Bind2Backend::autoPrimaryBackend(const string& ipAddress, const ZoneName& /* domain */, const vector<DNSResourceRecord>& /* nsset */, string* /* nameserver */, string* account, DNSBackend** backend)
1361
{
×
1362
  // Check whether we have a configfile available.
1363
  if (getArg("autoprimary-config").empty())
×
1364
    return false;
×
1365

1366
  ifstream c_if(getArg("autoprimaries").c_str(), std::ios::in); // this was nocreate?
×
1367
  if (!c_if) {
×
1368
    g_log << Logger::Error << "Unable to open autoprimaries file for read: " << stringerror() << endl;
×
1369
    return false;
×
1370
  }
×
1371

1372
  // Format:
1373
  // <ip> <accountname>
1374
  string line, sip, saccount;
×
1375
  while (getline(c_if, line)) {
×
1376
    std::istringstream ii(line);
×
1377
    ii >> sip;
×
1378
    if (sip == ipAddress) {
×
1379
      ii >> saccount;
×
1380
      break;
×
1381
    }
×
1382
  }
×
1383
  c_if.close();
×
1384

1385
  if (sip != ipAddress) { // ip not found in authorization list - reject
×
1386
    return false;
×
1387
  }
×
1388

1389
  // ip authorized as autoprimary - accept
1390
  *backend = this;
×
1391
  if (saccount.length() > 0)
×
1392
    *account = saccount.c_str();
×
1393

1394
  return true;
×
1395
}
×
1396

1397
BB2DomainInfo Bind2Backend::createDomainEntry(const ZoneName& domain, const string& filename)
1398
{
6✔
1399
  int newid = 1;
6✔
1400
  { // Find a free zone id nr.
6✔
1401
    auto state = s_state.read_lock();
6✔
1402
    if (!state->empty()) {
6!
1403
      // older (1.53) versions of boost have an expression for s_state.rbegin()
1404
      // that is ambiguous in C++17. So construct it explicitly
1405
      newid = boost::make_reverse_iterator(state->end())->d_id + 1;
6✔
1406
    }
6✔
1407
  }
6✔
1408

1409
  BB2DomainInfo bbd;
6✔
1410
  bbd.d_kind = DomainInfo::Native;
6✔
1411
  bbd.d_id = newid;
6✔
1412
  bbd.d_records = std::make_shared<recordstorage_t>();
6✔
1413
  bbd.d_name = domain;
6✔
1414
  bbd.setCheckInterval(getArgAsNum("check-interval"));
6✔
1415
  bbd.d_filename = filename;
6✔
1416

1417
  return bbd;
6✔
1418
}
6✔
1419

1420
bool Bind2Backend::createSecondaryDomain(const string& ipAddress, const ZoneName& domain, const string& /* nameserver */, const string& account)
1421
{
×
1422
  string filename = getArg("autoprimary-destdir") + '/' + domain.toStringNoDot();
×
1423

1424
  g_log << Logger::Warning << d_logprefix
×
1425
        << " Writing bind config zone statement for superslave zone '" << domain
×
1426
        << "' from autoprimary " << ipAddress << endl;
×
1427

1428
  {
×
1429
    std::lock_guard<std::mutex> l2(s_autosecondary_config_lock);
×
1430

1431
    ofstream c_of(getArg("autoprimary-config").c_str(), std::ios::app);
×
1432
    if (!c_of) {
×
1433
      g_log << Logger::Error << "Unable to open autoprimary configfile for append: " << stringerror() << endl;
×
1434
      throw DBException("Unable to open autoprimary configfile for append: " + stringerror());
×
1435
    }
×
1436

1437
    c_of << endl;
×
1438
    c_of << "# AutoSecondary zone '" << domain.toString() << "' (added: " << nowTime() << ") (account: " << account << ')' << endl;
×
1439
    c_of << "zone \"" << domain.toStringNoDot() << "\" {" << endl;
×
1440
    c_of << "\ttype secondary;" << endl;
×
1441
    c_of << "\tfile \"" << filename << "\";" << endl;
×
1442
    c_of << "\tprimaries { " << ipAddress << "; };" << endl;
×
1443
    c_of << "};" << endl;
×
1444
    c_of.close();
×
1445
  }
×
1446

1447
  BB2DomainInfo bbd = createDomainEntry(domain, filename);
×
1448
  bbd.d_kind = DomainInfo::Secondary;
×
1449
  bbd.d_primaries.emplace_back(ComboAddress(ipAddress, 53));
×
1450
  bbd.setCtime();
×
1451
  safePutBBDomainInfo(bbd);
×
1452

1453
  return true;
×
1454
}
×
1455

1456
bool Bind2Backend::searchRecords(const string& pattern, size_t maxResults, vector<DNSResourceRecord>& result)
1457
{
18✔
1458
  SimpleMatch sm(pattern, true);
18✔
1459
  static bool mustlog = ::arg().mustDo("query-logging");
18✔
1460
  if (mustlog)
18!
1461
    g_log << Logger::Warning << "Search for pattern '" << pattern << "'" << endl;
×
1462

1463
  {
18✔
1464
    auto state = s_state.read_lock();
18✔
1465

1466
    for (const auto& i : *state) {
18!
1467
      BB2DomainInfo h;
×
1468
      if (!safeGetBBDomainInfo(i.d_id, &h)) {
×
1469
        continue;
×
1470
      }
×
1471

1472
      if (!h.d_loaded) {
×
1473
        continue;
×
1474
      }
×
1475

1476
      shared_ptr<const recordstorage_t> rhandle = h.d_records.get();
×
1477

1478
      for (recordstorage_t::const_iterator ri = rhandle->begin(); result.size() < maxResults && ri != rhandle->end(); ri++) {
×
1479
        const DNSName& domainName(i.d_name);
×
1480
        DNSName name = ri->qname.empty() ? domainName : (ri->qname + domainName);
×
1481
        if (sm.match(name) || sm.match(ri->content)) {
×
1482
          DNSResourceRecord r;
×
1483
          r.qname = std::move(name);
×
1484
          r.domain_id = i.d_id;
×
1485
          r.content = ri->content;
×
1486
          r.qtype = ri->qtype;
×
1487
          r.ttl = ri->ttl;
×
1488
          r.auth = ri->auth;
×
1489
          result.push_back(std::move(r));
×
1490
        }
×
1491
      }
×
1492
    }
×
1493
  }
18✔
1494

1495
  return true;
18✔
1496
}
18✔
1497

1498
class Bind2Factory : public BackendFactory
1499
{
1500
public:
1501
  Bind2Factory() :
1502
    BackendFactory("bind") {}
3,928✔
1503

1504
  void declareArguments(const string& suffix = "") override
1505
  {
563✔
1506
    declare(suffix, "ignore-broken-records", "Ignore records that are out-of-bound for the zone.", "no");
563✔
1507
    declare(suffix, "config", "Location of named.conf", "");
563✔
1508
    declare(suffix, "check-interval", "Interval for zonefile changes", "0");
563✔
1509
    declare(suffix, "autoprimary-config", "Location of (part of) named.conf where pdns can write zone-statements to", "");
563✔
1510
    declare(suffix, "autoprimaries", "List of IP-addresses of autoprimaries", "");
563✔
1511
    declare(suffix, "autoprimary-destdir", "Destination directory for newly added secondary zones", ::arg()["config-dir"]);
563✔
1512
    declare(suffix, "dnssec-db", "Filename to store & access our DNSSEC metadatabase, empty for none", "");
563✔
1513
    declare(suffix, "dnssec-db-journal-mode", "SQLite3 journal mode", "WAL");
563✔
1514
    declare(suffix, "hybrid", "Store DNSSEC metadata in other backend", "no");
563✔
1515
  }
563✔
1516

1517
  DNSBackend* make(const string& suffix = "") override
1518
  {
2,227✔
1519
    assertEmptySuffix(suffix);
2,227✔
1520
    return new Bind2Backend(suffix);
2,227✔
1521
  }
2,227✔
1522

1523
  DNSBackend* makeMetadataOnly(const string& suffix = "") override
1524
  {
900✔
1525
    assertEmptySuffix(suffix);
900✔
1526
    return new Bind2Backend(suffix, false);
900✔
1527
  }
900✔
1528

1529
private:
1530
  void assertEmptySuffix(const string& suffix)
1531
  {
3,126✔
1532
    if (!suffix.empty())
3,126!
1533
      throw PDNSException("launch= suffixes are not supported on the bindbackend");
×
1534
  }
3,126✔
1535
};
1536

1537
//! Magic class that is activated when the dynamic library is loaded
1538
class Bind2Loader
1539
{
1540
public:
1541
  Bind2Loader()
1542
  {
3,928✔
1543
    BackendMakers().report(std::make_unique<Bind2Factory>());
3,928✔
1544
    g_log << Logger::Info << "[bind2backend] This is the bind backend version " << VERSION
3,928✔
1545
#ifndef REPRODUCIBLE
3,928✔
1546
          << " (" __DATE__ " " __TIME__ ")"
3,928✔
1547
#endif
3,928✔
1548
#ifdef HAVE_SQLITE3
3,928✔
1549
          << " (with bind-dnssec-db support)"
3,928✔
1550
#endif
3,928✔
1551
          << " reporting" << endl;
3,928✔
1552
  }
3,928✔
1553
};
1554
static Bind2Loader bind2loader;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc