From 38c941b2f282f2a4351e23ffb2dbc77bfdcc997e Mon Sep 17 00:00:00 2001 From: bert hubert Date: Wed, 12 Jun 2013 20:25:08 +0200 Subject: [PATCH] enable us to do SRV records that end on . for zone2sql --- pdns/backends/bind/zone2sql.cc | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/pdns/backends/bind/zone2sql.cc b/pdns/backends/bind/zone2sql.cc index a59b8de91..0519697bc 100644 --- a/pdns/backends/bind/zone2sql.cc +++ b/pdns/backends/bind/zone2sql.cc @@ -49,6 +49,20 @@ static dbmode_t g_mode; static bool g_intransaction; static int g_numRecords; + +/* this is an official wart. We don't terminate domains on a . in PowerDNS, + which is fine as it goes, except for encoding the root, it would end up as '', + which leads to ambiguities in the content field. Therefore, if we encounter + the root as a . in a BIND zone, we leave it as a ., and don't replace it by + an empty string. Back in 1999 we made the wrong choice. */ + +static string stripDotContent(const string& content) +{ + if(boost::ends_with(content, " .") || content==".") + return content; + return stripDot(content); +} + static string sqlstr(const string &name) { if(g_mode == SQLITE) @@ -149,7 +163,7 @@ static void emitRecord(const string& zoneName, const string &qname, const string cout<<"insert into records (domain_id, name,type,content,ttl,prio) select id ,"<< sqlstr(toLower(stripDot(qname)))<<", "<< sqlstr(qtype)<<", "<< - sqlstr(stripDot(content))<<", "<