add option for dns update key
authorPatrick <patrick@lunatiki.de>
Fri, 9 Jan 2015 09:44:36 +0000 (10:44 +0100)
committerRalf Jung <post@ralfj.de>
Fri, 9 Jan 2015 09:44:36 +0000 (10:44 +0100)
dyn-nsupdate.conf.dist
nsupd-wrapper/dyn-nsupdate.cpp

index 96af7c780ca0b94a835e553c801b61e5dba3f6d6..d56bc78a1f63c7b4e0aa0f0bb282b1ca50603e96 100644 (file)
@@ -1,4 +1,5 @@
 nsupdate = /usr/bin/nsupdate
+key = keyname:passwd
 
 [test.dyn.example.com]
 password = some_secure_password
index b1bcfd281e23796ef86a0a7697ebca5120e9d044..27db031e118420adcb2f0ceccdfcd183db2fa5e1 100644 (file)
@@ -102,6 +102,7 @@ int main(int argc, const char ** argv)
         pt::ini_parser::read_ini(CONFIG_FILE, config);
         std::string nsupdate = config.get<std::string>("nsupdate");
         unsigned server_port = config.get<unsigned>("port", 53);
+        std::string key = config.get<std::string>("key","");
         
         /* Given the domain, check whether the password matches */
         optional<std::string> correct_password = config.get_optional<std::string>(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);