From: Peter van Dijk Date: Tue, 16 Jun 2015 14:03:24 +0000 (+0200) Subject: ldapbackend compiles X-Git-Tag: dnsdist-1.0.0-alpha1~248^2~58^2~21^2~5^2~32 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b30fe14b94bd109ff2fea095a867e7d585621221;p=thirdparty%2Fpdns.git ldapbackend compiles --- diff --git a/modules/ldapbackend/ldapbackend.cc b/modules/ldapbackend/ldapbackend.cc index 44d366bdb9..9945df6836 100644 --- a/modules/ldapbackend/ldapbackend.cc +++ b/modules/ldapbackend/ldapbackend.cc @@ -89,7 +89,7 @@ LdapBackend::~LdapBackend() -bool LdapBackend::list( const string& target, int domain_id, bool include_disabled ) +bool LdapBackend::list( const DNSName& target, int domain_id, bool include_disabled ) { try { @@ -120,7 +120,7 @@ bool LdapBackend::list( const string& target, int domain_id, bool include_disabl -inline bool LdapBackend::list_simple( const string& target, int domain_id ) +inline bool LdapBackend::list_simple( const DNSName& target, int domain_id ) { string dn; string filter; @@ -128,7 +128,7 @@ inline bool LdapBackend::list_simple( const string& target, int domain_id ) dn = getArg( "basedn" ); - qesc = toLower( m_pldap->escape( target ) ); + qesc = toLower( m_pldap->escape( target.toString() ) ); // search for SOARecord of target filter = strbind( ":target:", "&(associatedDomain=" + qesc + ")(sOARecord=*)", getArg( "filter-axfr" ) ); @@ -154,10 +154,9 @@ inline bool LdapBackend::list_simple( const string& target, int domain_id ) -inline bool LdapBackend::list_strict( const string& target, int domain_id ) +inline bool LdapBackend::list_strict( const DNSName& target, int domain_id ) { - if( (target.size() > 13 && target.substr( target.size() - 13, 13 ) == ".in-addr.arpa") || - (target.size() > 9 && target.substr( target.size() - 9, 9 ) == ".ip6.arpa") ) + if( target.isPartOf(DNSName("in-addr.arpa")) || target.isPartOf(DNSName(".ip6.arpa")) ) { L << Logger::Warning << m_myname << " Request for reverse zone AXFR, but this is not supported in strict mode" << endl; return false; // AXFR isn't supported in strict mode. Use simple mode and additional PTR records @@ -168,7 +167,7 @@ inline bool LdapBackend::list_strict( const string& target, int domain_id ) -void LdapBackend::lookup( const QType &qtype, const string &qname, DNSPacket *dnspkt, int zoneid ) +void LdapBackend::lookup( const QType &qtype, const DNSName &qname, DNSPacket *dnspkt, int zoneid ) { try { @@ -176,7 +175,7 @@ void LdapBackend::lookup( const QType &qtype, const string &qname, DNSPacket *dn m_qname = qname; m_adomain = m_adomains.end(); // skip loops in get() first time - if( m_qlog ) { L.log( "Query: '" + qname + "|" + qtype.getName() + "'", Logger::Error ); } + if( m_qlog ) { L.log( "Query: '" + qname.toString() + "|" + qtype.getName() + "'", Logger::Error ); } (this->*m_lookup_fcnt)( qtype, qname, dnspkt, zoneid ); } catch( LDAPTimeout < ) @@ -198,14 +197,14 @@ void LdapBackend::lookup( const QType &qtype, const string &qname, DNSPacket *dn -void LdapBackend::lookup_simple( const QType &qtype, const string &qname, DNSPacket *dnspkt, int zoneid ) +void LdapBackend::lookup_simple( const QType &qtype, const DNSName &qname, DNSPacket *dnspkt, int zoneid ) { string filter, attr, qesc; const char** attributes = ldap_attrany + 1; // skip associatedDomain const char* attronly[] = { NULL, "dNSTTL", "modifyTimestamp", NULL }; - qesc = toLower( m_pldap->escape( qname ) ); + qesc = toLower( m_pldap->escape( qname.toString() ) ); filter = "associatedDomain=" + qesc; if( qtype.getCode() != QType::ANY ) @@ -224,7 +223,7 @@ void LdapBackend::lookup_simple( const QType &qtype, const string &qname, DNSPac -void LdapBackend::lookup_strict( const QType &qtype, const string &qname, DNSPacket *dnspkt, int zoneid ) +void LdapBackend::lookup_strict( const QType &qtype, const DNSName &qname, DNSPacket *dnspkt, int zoneid ) { int len; vector parts; @@ -233,7 +232,7 @@ void LdapBackend::lookup_strict( const QType &qtype, const string &qname, DNSPac const char* attronly[] = { NULL, "dNSTTL", "modifyTimestamp", NULL }; - qesc = toLower( m_pldap->escape( qname ) ); + qesc = toLower( m_pldap->escape( qname.toString() ) ); stringtok( parts, qesc, "." ); len = qesc.length(); @@ -269,7 +268,7 @@ void LdapBackend::lookup_strict( const QType &qtype, const string &qname, DNSPac -void LdapBackend::lookup_tree( const QType &qtype, const string &qname, DNSPacket *dnspkt, int zoneid ) +void LdapBackend::lookup_tree( const QType &qtype, const DNSName &qname, DNSPacket *dnspkt, int zoneid ) { string filter, attr, qesc, dn; const char** attributes = ldap_attrany + 1; // skip associatedDomain @@ -278,7 +277,7 @@ void LdapBackend::lookup_tree( const QType &qtype, const string &qname, DNSPacke vector parts; - qesc = toLower( m_pldap->escape( qname ) ); + qesc = toLower( m_pldap->escape( qname.toString() ) ); filter = "associatedDomain=" + qesc; if( qtype.getCode() != QType::ANY ) @@ -291,7 +290,7 @@ void LdapBackend::lookup_tree( const QType &qtype, const string &qname, DNSPacke filter = strbind( ":target:", filter, getArg( "filter-lookup" ) ); - stringtok( parts, toLower( qname ), "." ); + stringtok( parts, toLower( qname.toString() ), "." ); for( i = parts.rbegin(); i != parts.rend(); i++ ) { dn = "dc=" + *i + "," + dn; @@ -356,7 +355,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 ) { + if( i->size() >= m_axfrqlen && i->substr( i->size() - m_axfrqlen, m_axfrqlen ) == m_qname.toString() /* ugh */ ) { m_adomains.push_back( *i ); } } @@ -386,7 +385,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 ) { + if( i->size() >= m_axfrqlen && i->substr( i->size() - m_axfrqlen, m_axfrqlen ) == m_qname.toString() /* ugh */ ) { m_adomains.push_back( *i ); } } diff --git a/modules/ldapbackend/ldapbackend.hh b/modules/ldapbackend/ldapbackend.hh index ca9db96ff3..136c7570af 100644 --- a/modules/ldapbackend/ldapbackend.hh +++ b/modules/ldapbackend/ldapbackend.hh @@ -100,23 +100,24 @@ class LdapBackend : public DNSBackend unsigned int m_axfrqlen; time_t m_last_modified; string m_myname; - string m_qname; + DNSName m_qname; PowerLDAP* m_pldap; PowerLDAP::sentry_t m_result; PowerLDAP::sentry_t::iterator m_attribute; - vector::iterator m_value, m_adomain; - vector m_adomains; + vector::iterator m_value; + vector::iterator m_adomain; + vector m_adomains; - bool (LdapBackend::*m_list_fcnt)( const string&, int ); - void (LdapBackend::*m_lookup_fcnt)( const QType&, const string&, DNSPacket*, int ); + bool (LdapBackend::*m_list_fcnt)( const DNSName&, int ); + void (LdapBackend::*m_lookup_fcnt)( const QType&, const DNSName&, DNSPacket*, int ); bool (LdapBackend::*m_prepare_fcnt)(); - bool list_simple( const string& target, int domain_id ); - bool list_strict( const string& target, int domain_id ); + bool list_simple( const DNSName& target, int domain_id ); + bool list_strict( const DNSName& target, int domain_id ); - void lookup_simple( const QType& qtype, const string& qdomain, DNSPacket* p, int zoneid ); - void lookup_strict( const QType& qtype, const string& qdomain, DNSPacket* p, int zoneid ); - void lookup_tree( const QType& qtype, const string& qdomain, DNSPacket* p, int zoneid ); + void lookup_simple( const QType& qtype, const DNSName& qdomain, DNSPacket* p, int zoneid ); + void lookup_strict( const QType& qtype, const DNSName& qdomain, DNSPacket* p, int zoneid ); + void lookup_tree( const QType& qtype, const DNSName& qdomain, DNSPacket* p, int zoneid ); bool prepare(); bool prepare_simple(); @@ -129,8 +130,8 @@ public: LdapBackend( const string &suffix="" ); ~LdapBackend(); - bool list( const string& target, int domain_id, bool include_disabled=false ); - void lookup( const QType& qtype, const string& qdomain, DNSPacket* p = 0, int zoneid = -1 ); + bool list( const DNSName& target, int domain_id, bool include_disabled=false ); + void lookup( const QType& qtype, const DNSName& qdomain, DNSPacket* p = 0, int zoneid = -1 ); bool get( DNSResourceRecord& rr ); };