Skip to content

Commit

Permalink
replace master by primary in as many places as possible
Browse files Browse the repository at this point in the history
  • Loading branch information
mind04 committed Nov 13, 2023
1 parent 19b8727 commit d525b58
Show file tree
Hide file tree
Showing 68 changed files with 639 additions and 639 deletions.
74 changes: 37 additions & 37 deletions modules/bindbackend/bindbackend2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ SharedLockGuarded<Bind2Backend::state_t> Bind2Backend::s_state;
int Bind2Backend::s_first = 1;
bool Bind2Backend::s_ignore_broken_records = false;

std::mutex Bind2Backend::s_supermaster_config_lock; // protects writes to config file
std::mutex Bind2Backend::s_autoprimary_config_lock; // protects writes to config file
std::mutex Bind2Backend::s_startup_lock;
string Bind2Backend::s_binddirectory;

Expand Down Expand Up @@ -235,8 +235,8 @@ bool Bind2Backend::startTransaction(const DNSName& qname, int id)
fd = -1;

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

return true;
}
Expand Down Expand Up @@ -298,7 +298,7 @@ bool Bind2Backend::feedRecord(const DNSResourceRecord& rr, const DNSName& /* ord
throw DBException("out-of-zone data '" + rr.qname.toLogString() + "' during AXFR of zone '" + d_transaction_qname.toLogString() + "'");
}

shared_ptr<DNSRecordContent> drc(DNSRecordContent::mastermake(rr.qtype.getCode(), QClass::IN, rr.content));
shared_ptr<DNSRecordContent> drc(DNSRecordContent::make(rr.qtype.getCode(), QClass::IN, rr.content));
string content = drc->getZoneRepresentation();

// SOA needs stripping too! XXX FIXME - also, this should not be here I think
Expand All @@ -318,14 +318,14 @@ bool Bind2Backend::feedRecord(const DNSResourceRecord& rr, const DNSName& /* ord
return true;
}

void Bind2Backend::getUpdatedMasters(vector<DomainInfo>& changedDomains, std::unordered_set<DNSName>& /* catalogs */, CatalogHashMap& /* catalogHashes */)
void Bind2Backend::getUpdatedPrimaries(vector<DomainInfo>& changedDomains, std::unordered_set<DNSName>& /* catalogs */, CatalogHashMap& /* catalogHashes */)
{
vector<DomainInfo> consider;
{
auto state = s_state.read_lock();

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

DomainInfo di;
Expand All @@ -334,7 +334,7 @@ void Bind2Backend::getUpdatedMasters(vector<DomainInfo>& changedDomains, std::un
di.last_check = i.d_lastcheck;
di.notified_serial = i.d_lastnotified;
di.backend = this;
di.kind = DomainInfo::Master;
di.kind = DomainInfo::Primary;
consider.push_back(std::move(di));
}
}
Expand Down Expand Up @@ -377,7 +377,7 @@ void Bind2Backend::getAllDomains(vector<DomainInfo>* domains, bool getSerial, bo
di.zone = i.d_name;
di.last_check = i.d_lastcheck;
di.kind = i.d_kind;
di.masters = i.d_masters;
di.primaries = i.d_primaries;
di.backend = this;
domains->push_back(std::move(di));
};
Expand Down Expand Up @@ -411,7 +411,7 @@ void Bind2Backend::getUnfreshSlaveInfos(vector<DomainInfo>* unfreshDomains)
DomainInfo sd;
sd.id = i.d_id;
sd.zone = i.d_name;
sd.masters = i.d_masters;
sd.primaries = i.d_primaries;
sd.last_check = i.d_lastcheck;
sd.backend = this;
sd.kind = DomainInfo::Slave;
Expand Down Expand Up @@ -444,7 +444,7 @@ bool Bind2Backend::getDomainInfo(const DNSName& domain, DomainInfo& di, bool get

di.id = bbd.d_id;
di.zone = domain;
di.masters = bbd.d_masters;
di.primaries = bbd.d_primaries;
di.last_check = bbd.d_lastcheck;
di.backend = this;
di.kind = bbd.d_kind;
Expand Down Expand Up @@ -624,8 +624,8 @@ static void printDomainExtendedStatus(ostringstream& ret, const BB2DomainInfo& i
ret << "\t On-disk file: " << info.d_filename << " (" << info.d_ctime << ")" << std::endl;
ret << "\t Kind: ";
switch (info.d_kind) {
case DomainInfo::Master:
ret << "Master";
case DomainInfo::Primary:
ret << "Primary";
break;
case DomainInfo::Slave:
ret << "Slave";
Expand All @@ -634,9 +634,9 @@ static void printDomainExtendedStatus(ostringstream& ret, const BB2DomainInfo& i
ret << "Native";
}
ret << std::endl;
ret << "\t Masters: " << std::endl;
for (const auto& master : info.d_masters) {
ret << "\t\t - " << master.toStringWithPort() << std::endl;
ret << "\t Primaries: " << std::endl;
for (const auto& primary : info.d_primaries) {
ret << "\t\t - " << primary.toStringWithPort() << std::endl;
}
ret << "\t Also Notify: " << std::endl;
for (const auto& also : info.d_also_notify) {
Expand Down Expand Up @@ -955,14 +955,14 @@ void Bind2Backend::loadConfig(string* status) // NOLINT(readability-function-cog
// overwrite what we knew about the domain
bbd.d_name = domain.name;
bool filenameChanged = (bbd.d_filename != domain.filename);
bool addressesChanged = (bbd.d_masters != domain.masters || bbd.d_also_notify != domain.alsoNotify);
bool addressesChanged = (bbd.d_primaries != domain.primaries || bbd.d_also_notify != domain.alsoNotify);
bbd.d_filename = domain.filename;
bbd.d_masters = domain.masters;
bbd.d_primaries = domain.primaries;
bbd.d_also_notify = domain.alsoNotify;

DomainInfo::DomainKind kind = DomainInfo::Native;
if (domain.type == "primary" || domain.type == "master") {
kind = DomainInfo::Master;
kind = DomainInfo::Primary;
}
if (domain.type == "secondary" || domain.type == "slave") {
kind = DomainInfo::Slave;
Expand Down Expand Up @@ -1197,7 +1197,7 @@ void Bind2Backend::lookup(const QType& qtype, const DNSName& qname, int zoneId,

if (!bbd.d_loaded) {
d_handle.reset();
throw DBException("Zone for '" + d_handle.domain.toLogString() + "' in '" + bbd.d_filename + "' not loaded (file missing, corrupt or master dead)"); // fsck
throw DBException("Zone for '" + d_handle.domain.toLogString() + "' in '" + bbd.d_filename + "' not loaded (file missing, corrupt or primary dead)"); // fsck
}

d_handle.d_records = bbd.d_records.get();
Expand Down Expand Up @@ -1331,12 +1331,12 @@ bool Bind2Backend::handle::get_list(DNSResourceRecord& r)

bool Bind2Backend::autoPrimariesList(std::vector<AutoPrimary>& primaries)
{
if (getArg("supermaster-config").empty())
if (getArg("autoprimary-config").empty())
return false;

ifstream c_if(getArg("supermasters"), std::ios::in);
ifstream c_if(getArg("autoprimaries"), std::ios::in);
if (!c_if) {
g_log << Logger::Error << "Unable to open supermasters file for read: " << stringerror() << endl;
g_log << Logger::Error << "Unable to open autoprimaries file for read: " << stringerror() << endl;
return false;
}

Expand All @@ -1354,15 +1354,15 @@ bool Bind2Backend::autoPrimariesList(std::vector<AutoPrimary>& primaries)
return true;
}

bool Bind2Backend::superMasterBackend(const string& ip, const DNSName& /* domain */, const vector<DNSResourceRecord>& /* nsset */, string* /* nameserver */, string* account, DNSBackend** db)
bool Bind2Backend::autoPrimaryBackend(const string& ip, const DNSName& /* domain */, const vector<DNSResourceRecord>& /* nsset */, string* /* nameserver */, string* account, DNSBackend** db)
{
// Check whether we have a configfile available.
if (getArg("supermaster-config").empty())
if (getArg("autoprimary-config").empty())
return false;

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

Expand All @@ -1382,7 +1382,7 @@ bool Bind2Backend::superMasterBackend(const string& ip, const DNSName& /* domain
if (sip != ip) // ip not found in authorization list - reject
return false;

// ip authorized as supermaster - accept
// ip authorized as autoprimary - accept
*db = this;
if (saccount.length() > 0)
*account = saccount.c_str();
Expand Down Expand Up @@ -1415,19 +1415,19 @@ BB2DomainInfo Bind2Backend::createDomainEntry(const DNSName& domain, const strin

bool Bind2Backend::createSlaveDomain(const string& ip, const DNSName& domain, const string& /* nameserver */, const string& account)
{
string filename = getArg("supermaster-destdir") + '/' + domain.toStringNoDot();
string filename = getArg("autoprimary-destdir") + '/' + domain.toStringNoDot();

g_log << Logger::Warning << d_logprefix
<< " Writing bind config zone statement for superslave zone '" << domain
<< "' from supermaster " << ip << endl;
<< "' from autoprimary " << ip << endl;

{
std::lock_guard<std::mutex> l2(s_supermaster_config_lock);
std::lock_guard<std::mutex> l2(s_autoprimary_config_lock);

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

c_of << endl;
Expand All @@ -1442,7 +1442,7 @@ bool Bind2Backend::createSlaveDomain(const string& ip, const DNSName& domain, co

BB2DomainInfo bbd = createDomainEntry(domain, filename);
bbd.d_kind = DomainInfo::Slave;
bbd.d_masters.push_back(ComboAddress(ip, 53));
bbd.d_primaries.push_back(ComboAddress(ip, 53));
bbd.setCtime();
safePutBBDomainInfo(bbd);

Expand Down Expand Up @@ -1501,9 +1501,9 @@ class Bind2Factory : public BackendFactory
declare(suffix, "ignore-broken-records", "Ignore records that are out-of-bound for the zone.", "no");
declare(suffix, "config", "Location of named.conf", "");
declare(suffix, "check-interval", "Interval for zonefile changes", "0");
declare(suffix, "supermaster-config", "Location of (part of) named.conf where pdns can write zone-statements to", "");
declare(suffix, "supermasters", "List of IP-addresses of supermasters", "");
declare(suffix, "supermaster-destdir", "Destination directory for newly added slave zones", ::arg()["config-dir"]);
declare(suffix, "autoprimary-config", "Location of (part of) named.conf where pdns can write zone-statements to", "");
declare(suffix, "autoprimaries", "List of IP-addresses of autoprimaries", "");
declare(suffix, "autoprimary-destdir", "Destination directory for newly added slave zones", ::arg()["config-dir"]);
declare(suffix, "dnssec-db", "Filename to store & access our DNSSEC metadatabase, empty for none", "");
declare(suffix, "dnssec-db-journal-mode", "SQLite3 journal mode", "WAL");
declare(suffix, "hybrid", "Store DNSSEC metadata in other backend", "no");
Expand Down
8 changes: 4 additions & 4 deletions modules/bindbackend/bindbackend2.hh
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public:
DomainInfo::DomainKind d_kind{DomainInfo::Native}; //!< the kind of domain
string d_filename; //!< full absolute filename of the zone on disk
string d_status; //!< message describing status of a domain, for human consumption
vector<ComboAddress> d_masters; //!< IP address of the master of this domain
vector<ComboAddress> d_primaries; //!< IP address of the primary of this domain
set<string> d_also_notify; //!< IP list of hosts to also notify
LookButDontTouch<recordstorage_t> d_records; //!< the actual records belonging to this domain
time_t d_ctime{0}; //!< last known ctime of the file on disk
Expand Down Expand Up @@ -184,7 +184,7 @@ public:
Bind2Backend(const string& suffix = "", bool loadZones = true);
~Bind2Backend();
void getUnfreshSlaveInfos(vector<DomainInfo>* unfreshDomains) override;
void getUpdatedMasters(vector<DomainInfo>& changedDomains, std::unordered_set<DNSName>& catalogs, CatalogHashMap& catalogHashes) override;
void getUpdatedPrimaries(vector<DomainInfo>& changedDomains, std::unordered_set<DNSName>& catalogs, CatalogHashMap& catalogHashes) override;
bool getDomainInfo(const DNSName& domain, DomainInfo& di, bool getSerial = true) override;
time_t getCtime(const string& fname);
// DNSSEC
Expand Down Expand Up @@ -236,8 +236,8 @@ public:

// for autoprimary support
bool autoPrimariesList(std::vector<AutoPrimary>& primaries) override;
bool superMasterBackend(const string& ip, const DNSName& domain, const vector<DNSResourceRecord>& nsset, string* nameserver, string* account, DNSBackend** db) override;
static std::mutex s_supermaster_config_lock;
bool autoPrimaryBackend(const string& ip, const DNSName& domain, const vector<DNSResourceRecord>& nsset, string* nameserver, string* account, DNSBackend** db) override;
static std::mutex s_autoprimary_config_lock;
bool createSlaveDomain(const string& ip, const DNSName& domain, const string& nameserver, const string& account) override;

private:
Expand Down
2 changes: 1 addition & 1 deletion modules/bindbackend/binddnssec.cc
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ bool Bind2Backend::getNSEC3PARAMuncached(const DNSName& name, NSEC3PARAMRecordCo

static int maxNSEC3Iterations = ::arg().asNum("max-nsec3-iterations");
if (ns3p) {
auto tmp = std::dynamic_pointer_cast<NSEC3PARAMRecordContent>(DNSRecordContent::mastermake(QType::NSEC3PARAM, 1, value));
auto tmp = std::dynamic_pointer_cast<NSEC3PARAMRecordContent>(DNSRecordContent::make(QType::NSEC3PARAM, 1, value));
*ns3p = *tmp;

if (ns3p->d_iterations > maxNSEC3Iterations) {
Expand Down
10 changes: 5 additions & 5 deletions modules/gmysqlbackend/gmysqlbackend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ class gMySQLFactory : public BackendFactory
declare(suffix, "info-zone-query", "", "select id,name,master,last_check,notified_serial,type,options,catalog,account from domains where name=?");

declare(suffix, "info-all-slaves-query", "", "select domains.id, domains.name, domains.type, domains.master, domains.last_check, records.content from domains LEFT JOIN records ON records.domain_id=domains.id AND records.type='SOA' AND records.name=domains.name where domains.type in ('SLAVE', 'CONSUMER')");
declare(suffix, "supermaster-query", "", "select account from supermasters where ip=? and nameserver=?");
declare(suffix, "supermaster-name-to-ips", "", "select ip,account from supermasters where nameserver=? and account=?");
declare(suffix, "supermaster-add", "", "insert into supermasters (ip, nameserver, account) values (?,?,?)");
declare(suffix, "autoprimary-query", "", "select account from supermasters where ip=? and nameserver=?");
declare(suffix, "autoprimary-name-to-ips", "", "select ip,account from supermasters where nameserver=? and account=?");
declare(suffix, "autoprimary-add", "", "insert into supermasters (ip, nameserver, account) values (?,?,?)");
declare(suffix, "autoprimary-remove", "", "delete from supermasters where ip = ? and nameserver = ?");
declare(suffix, "list-autoprimaries", "", "select ip,nameserver,account from supermasters");

Expand All @@ -125,14 +125,14 @@ class gMySQLFactory : public BackendFactory
declare(suffix, "nullify-ordername-and-update-auth-query", "DNSSEC nullify ordername and update auth for a qname query", "update records set ordername=NULL,auth=? where domain_id=? and name=? and disabled=0");
declare(suffix, "nullify-ordername-and-update-auth-type-query", "DNSSEC nullify ordername and update auth for a rrset query", "update records set ordername=NULL,auth=? where domain_id=? and name=? and type=? and disabled=0");

declare(suffix, "update-master-query", "", "update domains set master=? where name=?");
declare(suffix, "update-primary-query", "", "update domains set master=? where name=?");
declare(suffix, "update-kind-query", "", "update domains set type=? where name=?");
declare(suffix, "update-options-query", "", "update domains set options=? where name=?");
declare(suffix, "update-catalog-query", "", "update domains set catalog=? where name=?");
declare(suffix, "update-account-query", "", "update domains set account=? where name=?");
declare(suffix, "update-serial-query", "", "update domains set notified_serial=? where id=?");
declare(suffix, "update-lastcheck-query", "", "update domains set last_check=? where id=?");
declare(suffix, "info-all-master-query", "", "select d.id, d.name, d.type, d.notified_serial,d.options, d.catalog,r.content from records r join domains d on r.domain_id=d.id and r.name=d.name where r.type='SOA' and r.disabled=0 and d.type in ('MASTER', 'PRODUCER')");
declare(suffix, "info-all-primary-query", "", "select d.id, d.name, d.type, d.notified_serial,d.options, d.catalog,r.content from records r join domains d on r.domain_id=d.id and r.name=d.name where r.type='SOA' and r.disabled=0 and d.type in ('MASTER', 'PRODUCER')");
declare(suffix, "info-producer-members-query", "", "select domains.id, domains.name, domains.options from records join domains on records.domain_id=domains.id and records.name=domains.name where domains.type='MASTER' and domains.catalog=? and records.type='SOA' and records.disabled=0");
declare(suffix, "info-consumer-members-query", "", "select id, name, options, master from domains where type='SLAVE' and catalog=?");
declare(suffix, "delete-domain-query", "", "delete from domains where name=?");
Expand Down
Loading

0 comments on commit d525b58

Please sign in to comment.