From: Wieger Opmeer Date: Thu, 17 Mar 2016 13:23:42 +0000 (+0100) Subject: repair dnssec in luabackend (done by ahu); try not to crash on unexpected return... X-Git-Tag: dnsdist-1.0.0-beta1~87^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7b7f06d797f0c4873bf95990ee715dd1a653c75c;p=pdns repair dnssec in luabackend (done by ahu); try not to crash on unexpected return values; use integers where appropriate because that works better for lua 5.3 --- diff --git a/modules/luabackend/dnssec.cc b/modules/luabackend/dnssec.cc index 480e6414e..8f04b6a07 100644 --- a/modules/luabackend/dnssec.cc +++ b/modules/luabackend/dnssec.cc @@ -24,35 +24,16 @@ #include "pdns/logger.hh" #include "pdns/arguments.hh" -/* - virtual bool updateDNSSECOrderAndAuth(uint32_t domain_id, const std::string& zonename, const std::string& qname, bool auth) - virtual bool updateDNSSECOrderAndAuthAbsolute(uint32_t domain_id, const std::string& qname, const std::string& ordername, bool auth) - virtual bool getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& qname, std::string& unhashed, std::string& before, std::string& after) - virtual bool getDomainKeys(const string& name, unsigned int kind, std::vector& keys) - virtual bool removeDomainKey(const string& name, unsigned int id) - virtual int addDomainKey(const string& name, const KeyData& key) - virtual bool activateDomainKey(const string& name, unsigned int id) - virtual bool deactivateDomainKey(const string& name, unsigned int id) - - virtual bool getTSIGKey(const string& name, string* algorithm, string* content) { return false; } - - virtual bool setDomainMetadata(const string& name, const std::string& kind, std::vector& meta) - virtual bool getDomainMetadata(const string& name, const std::string& kind, std::vector& meta) - virtual void alsoNotifies(const string &domain, set *ips) - -*/ - -bool LUABackend::updateDNSSECOrderAndAuth(uint32_t domain_id, const std::string& zonename, const std::string& qname, bool auth) { +bool LUABackend::updateDNSSECOrderAndAuth(uint32_t domain_id, const DNSName& zonename, const DNSName& qname, bool auth) { if(f_lua_updatednssecorderandauth == 0) { if(logging) L << Logger::Info << backend_name << "(updateDNSSECOrderAndAuth) domain_id: '" << domain_id << "' zonename: '" << zonename << "' qname: '" << qname << "' auth: '" << auth << "'" << endl; - string ins=toLower(labelReverse(makeRelative(qname, zonename))); + string ins=toLower(labelReverse(qname.makeRelative(zonename).toString())); return this->updateDNSSECOrderAndAuthAbsolute(domain_id, qname, ins, auth); - } if(logging) @@ -60,9 +41,9 @@ bool LUABackend::updateDNSSECOrderAndAuth(uint32_t domain_id, const std::string& lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_updatednssecorderandauth); - lua_pushnumber(lua, domain_id); - lua_pushstring(lua, zonename.c_str()); - lua_pushstring(lua, qname.c_str()); + lua_pushinteger(lua, domain_id); + lua_pushstring(lua, zonename.toString().c_str()); + lua_pushstring(lua, qname.toString().c_str()); lua_pushboolean(lua, auth); if(lua_pcall(lua, 4, 1, f_lua_exec_error) != 0) { @@ -87,7 +68,12 @@ bool LUABackend::updateDNSSECOrderAndAuth(uint32_t domain_id, const std::string& return ok; } -bool LUABackend::updateDNSSECOrderAndAuthAbsolute(uint32_t domain_id, const std::string& qname, const std::string& ordername, bool auth) { +bool LUABackend::updateDNSSECOrderNameAndAuth(unsigned int, DNSName const&, DNSName const&, DNSName const&, bool, unsigned short) +{ + return false; +} + +bool LUABackend::updateDNSSECOrderAndAuthAbsolute(uint32_t domain_id, const DNSName& qname, const std::string& ordername, bool auth) { if(f_lua_updatednssecorderandauthabsolute == 0) return false; @@ -97,8 +83,8 @@ bool LUABackend::updateDNSSECOrderAndAuthAbsolute(uint32_t domain_id, const std: lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_updatednssecorderandauthabsolute); - lua_pushnumber(lua, domain_id); - lua_pushstring(lua, qname.c_str()); + lua_pushinteger(lua, domain_id); + lua_pushstring(lua, qname.toString().c_str()); lua_pushstring(lua, ordername.c_str()); lua_pushboolean(lua, auth); @@ -124,7 +110,7 @@ bool LUABackend::updateDNSSECOrderAndAuthAbsolute(uint32_t domain_id, const std: return ok; } -bool LUABackend::getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& qname, std::string& unhashed, std::string& before, std::string& after) { +bool LUABackend::getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& qname, DNSName& unhashed, std::string& before, std::string& after) { if(f_lua_getbeforeandafternamesabsolute == 0) return false; @@ -138,7 +124,7 @@ bool LUABackend::getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_updatednssecorderandauthabsolute); - lua_pushnumber(lua, id); + lua_pushinteger(lua, id); lua_pushstring(lua, qname.c_str()); if(lua_pcall(lua, 2, 3, f_lua_exec_error) != 0) { @@ -160,7 +146,7 @@ bool LUABackend::getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& } //will this be correct since we are poping one at the time? - unhashed = lua_tostring(lua, -1); + unhashed = DNSName(lua_tostring(lua, -1)); lua_pop(lua, 1); returnedwhat = lua_type(lua, -1); @@ -181,7 +167,7 @@ bool LUABackend::getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& return ok; } -bool LUABackend::updateDomainKey(const string& name, unsigned int &id, bool toowhat ) { +bool LUABackend::updateDomainKey(const DNSName& name, unsigned int &id, bool toowhat ) { if(f_lua_updatedomainkey == 0) return false; @@ -191,8 +177,8 @@ bool LUABackend::updateDomainKey(const string& name, unsigned int &id, bool toow lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_updatedomainkey); - lua_pushstring(lua, name.c_str()); - lua_pushnumber(lua, id); + lua_pushstring(lua, name.toString().c_str()); + lua_pushinteger(lua, id); lua_pushboolean(lua, toowhat); if(lua_pcall(lua, 3, 1, f_lua_exec_error) != 0) { @@ -217,7 +203,7 @@ bool LUABackend::updateDomainKey(const string& name, unsigned int &id, bool toow return ok; } -bool LUABackend::activateDomainKey(const string& name, unsigned int id) { +bool LUABackend::activateDomainKey(const DNSName& name, unsigned int id) { if(f_lua_activatedomainkey == 0) return updateDomainKey(name, id, true); @@ -227,8 +213,8 @@ bool LUABackend::activateDomainKey(const string& name, unsigned int id) { lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_activatedomainkey); - lua_pushstring(lua, name.c_str()); - lua_pushnumber(lua, id); + lua_pushstring(lua, name.toString().c_str()); + lua_pushinteger(lua, id); if(lua_pcall(lua, 2, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); @@ -252,7 +238,7 @@ bool LUABackend::activateDomainKey(const string& name, unsigned int id) { return ok; } -bool LUABackend::deactivateDomainKey(const string& name, unsigned int id) { +bool LUABackend::deactivateDomainKey(const DNSName& name, unsigned int id) { if(f_lua_deactivatedomainkey == 0) return updateDomainKey(name, id, false); @@ -262,8 +248,8 @@ bool LUABackend::deactivateDomainKey(const string& name, unsigned int id) { lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_deactivatedomainkey); - lua_pushstring(lua, name.c_str()); - lua_pushnumber(lua, id); + lua_pushstring(lua, name.toString().c_str()); + lua_pushinteger(lua, id); if(lua_pcall(lua, 2, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); @@ -287,7 +273,7 @@ bool LUABackend::deactivateDomainKey(const string& name, unsigned int id) { return ok; } -bool LUABackend::removeDomainKey(const string& name, unsigned int id) { +bool LUABackend::removeDomainKey(const DNSName& name, unsigned int id) { if(f_lua_removedomainkey == 0) return false; @@ -297,8 +283,8 @@ bool LUABackend::removeDomainKey(const string& name, unsigned int id) { lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_removedomainkey); - lua_pushstring(lua, name.c_str()); - lua_pushnumber(lua, id); + lua_pushstring(lua, name.toString().c_str()); + lua_pushinteger(lua, id); if(lua_pcall(lua, 2, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); @@ -322,7 +308,7 @@ bool LUABackend::removeDomainKey(const string& name, unsigned int id) { return ok; } -int LUABackend::addDomainKey(const string& name, const KeyData& key) { +int LUABackend::addDomainKey(const DNSName& name, const KeyData& key) { // there is no logging function in pdnsutil when running this routine? //key = id, flags, active, content @@ -336,12 +322,12 @@ int LUABackend::addDomainKey(const string& name, const KeyData& key) { lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_adddomainkey); - lua_pushstring(lua, name.c_str()); + lua_pushstring(lua, name.toString().c_str()); lua_newtable(lua); lua_pushliteral(lua, "flags"); - lua_pushnumber(lua, key.flags); + lua_pushinteger(lua, key.flags); lua_settable(lua, -3); lua_pushliteral(lua, "active"); @@ -374,7 +360,7 @@ int LUABackend::addDomainKey(const string& name, const KeyData& key) { return ok; } -bool LUABackend::getDomainKeys(const string& name, unsigned int kind, std::vector& keys) { +bool LUABackend::getDomainKeys(const DNSName& name, unsigned int kind, std::vector& keys) { //what is kind used for? if(f_lua_getdomainkeys == 0) @@ -385,8 +371,8 @@ bool LUABackend::getDomainKeys(const string& name, unsigned int kind, std::vecto lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_getdomainkeys); - lua_pushstring(lua, name.c_str()); - lua_pushnumber(lua, kind); + lua_pushstring(lua, name.toString().c_str()); + lua_pushinteger(lua, kind); if(lua_pcall(lua, 2, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); @@ -436,7 +422,7 @@ bool LUABackend::getDomainKeys(const string& name, unsigned int kind, std::vecto return j > 0; } -bool LUABackend::getTSIGKey(const string& name, string* algorithm, string* content) { +bool LUABackend::getTSIGKey(const DNSName& name, DNSName* algorithm, string* content) { if(f_lua_gettsigkey == 0) return false; @@ -446,7 +432,7 @@ bool LUABackend::getTSIGKey(const string& name, string* algorithm, string* conte lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_gettsigkey); - lua_pushstring(lua, name.c_str()); + lua_pushstring(lua, name.toString().c_str()); if(lua_pcall(lua, 1, 2, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); @@ -471,7 +457,7 @@ bool LUABackend::getTSIGKey(const string& name, string* algorithm, string* conte c = lua_tostring(lua, -1); lua_pop(lua, 1); - *algorithm = a; + *algorithm = DNSName(a); *content = c; if(logging) @@ -480,7 +466,7 @@ bool LUABackend::getTSIGKey(const string& name, string* algorithm, string* conte return true; } -bool LUABackend::setDomainMetadata(const string& name, const std::string& kind, const std::vector& meta) { +bool LUABackend::setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector& meta) { if(f_lua_setdomainmetadata == 0) return false; @@ -490,7 +476,7 @@ bool LUABackend::setDomainMetadata(const string& name, const std::string& kind, lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_setdomainmetadata); - lua_pushstring(lua, name.c_str()); + lua_pushstring(lua, name.toString().c_str()); lua_pushstring(lua, kind.c_str()); lua_newtable(lua); @@ -501,7 +487,7 @@ bool LUABackend::setDomainMetadata(const string& name, const std::string& kind, for(i = meta.begin(); ic_str()); lua_settable(lua, -3); } @@ -529,7 +515,7 @@ bool LUABackend::setDomainMetadata(const string& name, const std::string& kind, } -bool LUABackend::getDomainMetadata(const string& name, const std::string& kind, std::vector& meta) { +bool LUABackend::getDomainMetadata(const DNSName& name, const std::string& kind, std::vector& meta) { if(f_lua_getdomainmetadata == 0) return false; @@ -538,7 +524,7 @@ bool LUABackend::getDomainMetadata(const string& name, const std::string& kind, lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_getdomainmetadata); - lua_pushstring(lua, name.c_str()); + lua_pushstring(lua, name.toString().c_str()); lua_pushstring(lua, kind.c_str()); if(lua_pcall(lua, 2, 1, f_lua_exec_error) != 0) { @@ -549,6 +535,9 @@ bool LUABackend::getDomainMetadata(const string& name, const std::string& kind, return false; } + if (lua_type(lua, -1) != LUA_TTABLE) + return false; + lua_pushnil(lua); int j = 0; @@ -571,7 +560,7 @@ bool LUABackend::getDomainMetadata(const string& name, const std::string& kind, } -void LUABackend::alsoNotifies(const string &domain, set *ips) { +void LUABackend::alsoNotifies(const DNSName& domain, set *ips) { if(f_lua_alsonotifies == 0) return; @@ -581,7 +570,7 @@ void LUABackend::alsoNotifies(const string &domain, set *ips) { lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_alsonotifies); - lua_pushstring(lua, domain.c_str()); + lua_pushstring(lua, domain.toString().c_str()); if(lua_pcall(lua, 1, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); @@ -591,6 +580,9 @@ void LUABackend::alsoNotifies(const string &domain, set *ips) { return; } + if (lua_type(lua, -1) != LUA_TTABLE) + return; + lua_pushnil(lua); size_t returnedwhat; diff --git a/modules/luabackend/lua_functions.cc b/modules/luabackend/lua_functions.cc index 2df88746c..ec99c7f7f 100644 --- a/modules/luabackend/lua_functions.cc +++ b/modules/luabackend/lua_functions.cc @@ -297,7 +297,7 @@ bool LUABackend::getValueFromTable(lua_State *lua, const std::string& key, uint3 bool ret = false; if(!lua_isnil(lua, -1)) { - value = (uint32_t)lua_tonumber(lua, -1); + value = (uint32_t)lua_tointeger(lua, -1); ret = true; } @@ -313,7 +313,7 @@ bool LUABackend::getValueFromTable(lua_State *lua, const std::string& key, uint1 bool ret = false; if(!lua_isnil(lua, -1)) { - value = (uint16_t)lua_tonumber(lua, -1); + value = (uint16_t)lua_tointeger(lua, -1); ret = true; } @@ -329,7 +329,7 @@ bool LUABackend::getValueFromTable(lua_State *lua, const std::string& key, uint8 bool ret = false; if(!lua_isnil(lua, -1)) { - value = (uint8_t)lua_tonumber(lua, -1); + value = (uint8_t)lua_tointeger(lua, -1); ret = true; } @@ -345,7 +345,7 @@ bool LUABackend::getValueFromTable(lua_State *lua, const std::string& key, int& bool ret = false; if(!lua_isnil(lua, -1)) { - value = (int)lua_tonumber(lua, -1); + value = (int)lua_tointeger(lua, -1); ret = true; } diff --git a/modules/luabackend/luabackend.hh b/modules/luabackend/luabackend.hh index 1b2a38045..a251ba016 100644 --- a/modules/luabackend/luabackend.hh +++ b/modules/luabackend/luabackend.hh @@ -47,45 +47,43 @@ public: // SLAVE BACKEND - bool getDomainInfo(const string &domain, DomainInfo &di); - bool isMaster(const string &name, const string &ip); - void getUnfreshSlaveInfos(vector* domains); - void setFresh(uint32_t id); + bool getDomainInfo(const DNSName& domain, DomainInfo &di) override; + bool isMaster(const DNSName& name, const string &ip) override; + void getUnfreshSlaveInfos(vector* domains) override; + void setFresh(uint32_t id) override; - bool startTransaction(const string &qname, int id); - bool commitTransaction(); - bool abortTransaction(); - bool feedRecord(const DNSResourceRecord &rr, string *ordername=0); + bool startTransaction(const DNSName &qname, int id) override; + bool commitTransaction() override; + bool abortTransaction() override; + bool feedRecord(const DNSResourceRecord &rr, string *ordername=0) override; // SUPERMASTER BACKEND - bool superMasterBackend(const string &ip, const string &domain, const vector&nsset, string *nameserver, string *account, DNSBackend **db); - bool createSlaveDomain(const string &ip, const string &domain, const string &nameserver, const string &account); + bool superMasterBackend(const string &ip, const DNSName &domain, const vector&nsset, string *nameserver, string *account, DNSBackend **db) override; + bool createSlaveDomain(const string &ip, const DNSName &domain, const string &nameserver, const string &account) override; // DNSSEC BACKEND //! get a list of IP addresses that should also be notified for a domain - void alsoNotifies(const string &domain, set *ips); - bool getDomainMetadata(const string& name, const std::string& kind, std::vector& meta); - bool setDomainMetadata(const string& name, const std::string& kind, const std::vector& meta); - - bool getDomainKeys(const string& name, unsigned int kind, std::vector& keys); - bool removeDomainKey(const string& name, unsigned int id); - bool activateDomainKey(const string& name, unsigned int id); - bool deactivateDomainKey(const string& name, unsigned int id); - bool getTSIGKey(const string& name, string* algorithm, string* content); - int addDomainKey(const string& name, const KeyData& key); - - bool getBeforeAndAfterNamesAbsolute(uint32_t id, const std::string& qname, std::string& unhashed, std::string& before, std::string& after); - bool updateDNSSECOrderAndAuthAbsolute(uint32_t domain_id, const std::string& qname, const std::string& ordername, bool auth); - bool updateDNSSECOrderAndAuth(uint32_t domain_id, const std::string& zonename, const std::string& qname, bool auth); - - + void alsoNotifies(const DNSName &domain, set *ips) override; + bool getDomainMetadata(const DNSName& name, const std::string& kind, std::vector& meta) override; + bool setDomainMetadata(const DNSName& name, const std::string& kind, const std::vector& meta) override; + + bool getDomainKeys(const DNSName& name, unsigned int kind, std::vector& keys) override ; + bool removeDomainKey(const DNSName& name, unsigned int id) override ; + bool activateDomainKey(const DNSName& name, unsigned int id) override ; + bool deactivateDomainKey(const DNSName& name, unsigned int id) override ; + bool getTSIGKey(const DNSName& name, DNSName* algorithm, string* content) override ; + int addDomainKey(const DNSName& name, const KeyData& key) override ; + bool updateDNSSECOrderAndAuthAbsolute(uint32_t domain_id, const DNSName& qname, const std::string& ordername, bool auth); + bool getBeforeAndAfterNamesAbsolute(uint32_t id, const string& qname, DNSName& unhashed, string& before, string& after) override; + bool updateDNSSECOrderNameAndAuth(uint32_t domain_id, const DNSName& zonename, const DNSName& qname, const DNSName& ordername, bool auth, const uint16_t qtype=QType::ANY) override; + bool updateDNSSECOrderAndAuth(uint32_t domain_id, const DNSName& zonename, const DNSName& qname, bool auth); // OTHER - void reload(); - void rediscover(string* status=0); + void reload() override ; + void rediscover(string* status=0) override ; string backend_name; @@ -177,7 +175,7 @@ private: bool logging; //dnssec.cc - bool updateDomainKey(const string& name, unsigned int &id, bool toowhat); + bool updateDomainKey(const DNSName& name, unsigned int &id, bool toowhat); /* diff --git a/modules/luabackend/master.cc b/modules/luabackend/master.cc index fd9a9a817..51b857f7c 100644 --- a/modules/luabackend/master.cc +++ b/modules/luabackend/master.cc @@ -69,8 +69,8 @@ void LUABackend::setNotifed(int id, uint32_t serial) { lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_setnotifed); - lua_pushnumber(lua, id); - lua_pushnumber(lua, serial); + lua_pushinteger(lua, id); + lua_pushinteger(lua, serial); if(lua_pcall(lua, 2, 0, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); diff --git a/modules/luabackend/private.cc b/modules/luabackend/private.cc index 9ee1cf169..732f590c0 100644 --- a/modules/luabackend/private.cc +++ b/modules/luabackend/private.cc @@ -106,11 +106,11 @@ void LUABackend::dnsrr_to_table(lua_State *lua, const DNSResourceRecord *rr) { lua_settable(lua, -3); lua_pushliteral(lua, "qclass"); - lua_pushnumber(lua, rr->qclass); + lua_pushinteger(lua, rr->qclass); lua_settable(lua, -3); lua_pushliteral(lua, "ttl"); - lua_pushnumber(lua, rr->ttl); + lua_pushinteger(lua, rr->ttl); lua_settable(lua, -3); lua_pushliteral(lua, "auth"); diff --git a/modules/luabackend/slave.cc b/modules/luabackend/slave.cc index 8f60b14b8..c0be49121 100644 --- a/modules/luabackend/slave.cc +++ b/modules/luabackend/slave.cc @@ -37,7 +37,7 @@ virtual void setFresh(uint32_t id); */ -bool LUABackend::startTransaction(const string &qname, int id) { +bool LUABackend::startTransaction(const DNSName& qname, int id) { if (f_lua_starttransaction == 0) return false; @@ -47,8 +47,8 @@ bool LUABackend::startTransaction(const string &qname, int id) { lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_starttransaction); - lua_pushstring(lua, qname.c_str()); - lua_pushnumber(lua, id); + lua_pushstring(lua, qname.toString().c_str()); + lua_pushinteger(lua, id); if(lua_pcall(lua, 2, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); @@ -174,7 +174,7 @@ void LUABackend::setFresh(uint32_t id) { lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_setfresh); - lua_pushnumber(lua, id); + lua_pushinteger(lua, id); if(lua_pcall(lua, 1, 0, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); @@ -220,7 +220,7 @@ void LUABackend::getUnfreshSlaveInfos(vector* domains) { } -bool LUABackend::isMaster(const string &domain, const string &ip) { +bool LUABackend::isMaster(const DNSName& domain, const string &ip) { if (f_lua_ismaster == 0) return false; @@ -230,7 +230,7 @@ bool LUABackend::isMaster(const string &domain, const string &ip) { lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_ismaster); - lua_pushstring(lua, domain.c_str()); + lua_pushstring(lua, domain.toString().c_str()); lua_pushstring(lua, ip.c_str()); if(lua_pcall(lua, 2, 1, f_lua_exec_error) != 0) { @@ -254,7 +254,7 @@ bool LUABackend::isMaster(const string &domain, const string &ip) { return ok; } -bool LUABackend::getDomainInfo(const string &domain, DomainInfo &di) { +bool LUABackend::getDomainInfo(const DNSName&domain, DomainInfo &di) { if (f_lua_getdomaininfo == 0) return false; @@ -263,7 +263,7 @@ bool LUABackend::getDomainInfo(const string &domain, DomainInfo &di) { lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_getdomaininfo); - lua_pushstring(lua, domain.c_str()); + lua_pushstring(lua, domain.toString().c_str()); if(lua_pcall(lua, 1, 1, f_lua_exec_error) != 0) { string e = backend_name + lua_tostring(lua, -1); diff --git a/modules/luabackend/supermaster.cc b/modules/luabackend/supermaster.cc index 9360356d4..2d0160a8e 100644 --- a/modules/luabackend/supermaster.cc +++ b/modules/luabackend/supermaster.cc @@ -33,7 +33,7 @@ */ -bool LUABackend::superMasterBackend(const string &ip, const string &domain, const vector&nsset, string *nameserver, string *account, DNSBackend **db) { +bool LUABackend::superMasterBackend(const string &ip, const DNSName &domain, const vector&nsset, string *nameserver, string *account, DNSBackend **db) { if (f_lua_supermasterbackend == 0) return false; @@ -44,14 +44,14 @@ bool LUABackend::superMasterBackend(const string &ip, const string &domain, cons lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_supermasterbackend); lua_pushstring(lua, ip.c_str()); - lua_pushstring(lua, domain.c_str()); + lua_pushstring(lua, domain.toString().c_str()); lua_newtable(lua); int c = 0; for(vector::const_iterator i=nsset.begin();i!=nsset.end();++i) { c++; - lua_pushnumber(lua, c); + lua_pushinteger(lua, c); DNSResourceRecord rr; @@ -98,7 +98,7 @@ bool LUABackend::superMasterBackend(const string &ip, const string &domain, cons return ok; } -bool LUABackend::createSlaveDomain(const string &ip, const string &domain, const string &nameserver, const string &account) { +bool LUABackend::createSlaveDomain(const string &ip, const DNSName& domain, const string &nameserver, const string &account) { if (f_lua_createslavedomain == 0) return false; @@ -109,7 +109,7 @@ bool LUABackend::createSlaveDomain(const string &ip, const string &domain, const lua_rawgeti(lua, LUA_REGISTRYINDEX, f_lua_createslavedomain); lua_pushstring(lua, ip.c_str()); - lua_pushstring(lua, domain.c_str()); + lua_pushstring(lua, domain.toString().c_str()); lua_pushstring(lua, account.c_str()); if(lua_pcall(lua, 3, 1, f_lua_exec_error) != 0) {