From: Patrick Date: Fri, 9 Jan 2015 09:44:36 +0000 (+0100) Subject: add option for dns update key X-Git-Url: https://git.ralfj.de/dyn-nsupdate.git/commitdiff_plain/d61aa3e46d25f8800d3a3db887e756f9b3a744dc?ds=sidebyside;hp=ce5910c07224d66252ff1921f7c181f65b574449 add option for dns update key --- diff --git a/dyn-nsupdate.conf.dist b/dyn-nsupdate.conf.dist index 96af7c7..d56bc78 100644 --- a/dyn-nsupdate.conf.dist +++ b/dyn-nsupdate.conf.dist @@ -1,4 +1,5 @@ nsupdate = /usr/bin/nsupdate +key = keyname:passwd [test.dyn.example.com] password = some_secure_password diff --git a/nsupd-wrapper/dyn-nsupdate.cpp b/nsupd-wrapper/dyn-nsupdate.cpp index b1bcfd2..27db031 100644 --- a/nsupd-wrapper/dyn-nsupdate.cpp +++ b/nsupd-wrapper/dyn-nsupdate.cpp @@ -102,6 +102,7 @@ int main(int argc, const char ** argv) pt::ini_parser::read_ini(CONFIG_FILE, config); std::string nsupdate = config.get("nsupdate"); unsigned server_port = config.get("port", 53); + std::string key = config.get("key",""); /* Given the domain, check whether the password matches */ optional correct_password = config.get_optional(pt::ptree::path_type(domain+"/password", '/')); @@ -132,7 +133,11 @@ int main(int argc, const char ** argv) exit(1); } /* exec nsupdate */ - execl(nsupdate.c_str(), nsupdate.c_str(), "-p", std::to_string(server_port).c_str(), "-l", (char *)NULL); + if (key.size() > 0) { + execl(nsupdate.c_str(), nsupdate.c_str(), "-y", key.c_str(), "-p", std::to_string(server_port).c_str(), "-l", (char *)NULL); + } else { + execl(nsupdate.c_str(), nsupdate.c_str(), "-p", std::to_string(server_port).c_str(), "-l", (char *)NULL); + } /* There was an error */ std::cerr << "There was an error executing nsupdate." << std::endl; exit(1);