From d61aa3e46d25f8800d3a3db887e756f9b3a744dc Mon Sep 17 00:00:00 2001 From: Patrick Date: Fri, 9 Jan 2015 10:44:36 +0100 Subject: [PATCH 1/1] add option for dns update key --- dyn-nsupdate.conf.dist | 1 + nsupd-wrapper/dyn-nsupdate.cpp | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) 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); -- 2.30.2