From df26024e7ac0d352f609ce1e9154c97c9b082c79 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Mon, 28 Sep 2015 09:36:12 +0200 Subject: [PATCH] opendbx and ldabbackend fixes for DNSName --- modules/ldapbackend/ldapbackend.cc | 16 ++++++---------- modules/opendbxbackend/odbxbackend.cc | 8 ++++---- modules/opendbxbackend/odbxprivate.cc | 2 +- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/modules/ldapbackend/ldapbackend.cc b/modules/ldapbackend/ldapbackend.cc index 9945df683..f9a4e406c 100644 --- a/modules/ldapbackend/ldapbackend.cc +++ b/modules/ldapbackend/ldapbackend.cc @@ -3,12 +3,8 @@ #endif #include "ldapbackend.hh" - - unsigned int ldap_host_index = 0; - - LdapBackend::LdapBackend( const string &suffix ) { string hoststr; @@ -19,7 +15,7 @@ LdapBackend::LdapBackend( const string &suffix ) try { m_msgid = 0; - m_qname = ""; + m_qname.clear(); m_pldap = NULL; m_qlog = arg().mustDo( "query-logging" ); m_default_ttl = arg().asNum( "default-ttl" ); @@ -101,12 +97,12 @@ bool LdapBackend::list( const DNSName& target, int domain_id, bool include_disab } catch( LDAPTimeout < ) { - L << Logger::Warning << m_myname << " Unable to get zone " + target + " from LDAP directory: " << lt.what() << endl; + L << Logger::Warning << m_myname << " Unable to get zone " << target << " from LDAP directory: " << lt.what() << endl; throw( DBException( "LDAP server timeout" ) ); } catch( LDAPException &le ) { - L << Logger::Error << m_myname << " Unable to get zone " + target + " from LDAP directory: " << le.what() << endl; + L << Logger::Error << m_myname << " Unable to get zone " << target << " from LDAP directory: " << le.what() << endl; throw( PDNSException( "LDAP server unreachable" ) ); // try to reconnect to another server } catch( std::exception &e ) @@ -356,7 +352,7 @@ inline bool LdapBackend::prepare_simple() vector::iterator i; for( i = m_result["associatedDomain"].begin(); i != m_result["associatedDomain"].end(); i++ ) { if( i->size() >= m_axfrqlen && i->substr( i->size() - m_axfrqlen, m_axfrqlen ) == m_qname.toString() /* ugh */ ) { - m_adomains.push_back( *i ); + m_adomains.push_back( DNSName(*i) ); } } m_result.erase( "associatedDomain" ); @@ -386,7 +382,7 @@ inline bool LdapBackend::prepare_strict() vector::iterator i; for( i = m_result["associatedDomain"].begin(); i != m_result["associatedDomain"].end(); i++ ) { if( i->size() >= m_axfrqlen && i->substr( i->size() - m_axfrqlen, m_axfrqlen ) == m_qname.toString() /* ugh */ ) { - m_adomains.push_back( *i ); + m_adomains.push_back( DNSName(*i) ); } } m_result.erase( "associatedDomain" ); @@ -482,7 +478,7 @@ bool LdapBackend::get( DNSResourceRecord &rr ) di.id = 0; di.serial = sd.serial; - di.zone = domain; + di.zone = DNSName(domain); di.last_check = 0; di.backend = this; di.kind = DomainInfo::Master; diff --git a/modules/opendbxbackend/odbxbackend.cc b/modules/opendbxbackend/odbxbackend.cc index 63d3d4dc6..a3ffaa7b7 100644 --- a/modules/opendbxbackend/odbxbackend.cc +++ b/modules/opendbxbackend/odbxbackend.cc @@ -101,7 +101,7 @@ bool OdbxBackend::getDomainInfo( const string& domain, DomainInfo& di ) do { di.id = 0; - di.zone = ""; + di.zone.clear(); di.masters.clear(); di.last_check = 0; di.notified_serial = 0; @@ -212,12 +212,12 @@ bool OdbxBackend::getSOA( const DNSName& domain, SOAData& sd, DNSPacket* p ) if( sd.nameserver.empty() ) { - sd.nameserver = arg()["default-soa-name"]; + sd.nameserver = DNSName(arg()["default-soa-name"]); } if( sd.hostmaster.empty() ) { - sd.hostmaster = "hostmaster." + domain; + sd.hostmaster = DNSName("hostmaster") + DNSName(domain); } sd.db = this; @@ -365,7 +365,7 @@ bool OdbxBackend::get( DNSResourceRecord& rr ) if( m_qname.empty() && ( tmp = odbx_field_value( m_result, 1 ) ) != NULL ) { - rr.qname = string( tmp, odbx_field_length( m_result, 1 ) ); + rr.qname = DNSName( tmp, odbx_field_length( m_result, 1 ) ); } if( ( tmp = odbx_field_value( m_result, 2 ) ) != NULL ) diff --git a/modules/opendbxbackend/odbxprivate.cc b/modules/opendbxbackend/odbxprivate.cc index 399f5f076..52143fadc 100644 --- a/modules/opendbxbackend/odbxprivate.cc +++ b/modules/opendbxbackend/odbxprivate.cc @@ -215,7 +215,7 @@ bool OdbxBackend::getDomainList( const string& stmt, vector* list, b if( ( tmp = odbx_field_value( m_result, 1 ) ) != NULL ) { - di.zone = string( tmp, odbx_field_length( m_result, 1 ) ); + di.zone = DNSName( tmp, odbx_field_length( m_result, 1 ) ); } if( ( tmp = odbx_field_value( m_result, 0 ) ) != NULL ) -- 2.40.0