From: Ralf Jung Date: Sat, 10 Aug 2013 09:31:11 +0000 (+0200) Subject: Use local mode of nsupdate, then we don't even need a keyfile X-Git-Url: https://git.ralfj.de/dyn-nsupdate.git/commitdiff_plain/e9f6935aad370f9ac285f33a55c1c0ae51895939?ds=inline;hp=56695cea69537204d4cc2126343beba25f0a0f90 Use local mode of nsupdate, then we don't even need a keyfile --- diff --git a/dyn-nsupdate.cpp b/dyn-nsupdate.cpp index 7c39136..25381cf 100644 --- a/dyn-nsupdate.cpp +++ b/dyn-nsupdate.cpp @@ -50,7 +50,6 @@ int main(int argc, const char ** argv) property_tree::ptree config; property_tree::ini_parser::read_ini(CONFIG_FILE, config); std::string nsupdate = config.get("nsupdate"); - std::string keyfile = config.get("key"); /* Check username, password, domain */ optional correct_password = config.get_optional(user+".password"); @@ -64,8 +63,11 @@ int main(int argc, const char ** argv) } /* preapre the pipe */ - int pipe_ends[] = {0,0}; - pipe(pipe_ends); + int pipe_ends[2]; + if (pipe(pipe_ends) < 0) { + std::cerr << "Error opening pipe." << std::endl; + exit(1); + } /* Launch nsupdate */ pid_t child_pid = fork(); @@ -82,18 +84,16 @@ int main(int argc, const char ** argv) exit(1); } /* exec nsupdate */ - execl(nsupdate.c_str(), nsupdate.c_str(), "-k", keyfile.c_str(), (char *)NULL); + execl(nsupdate.c_str(), nsupdate.c_str(), "-l", (char *)NULL); /* There was an error */ std::cerr << "There was an error executing nsupdate." << std::endl; exit(1); } /* Send it the command */ - write(pipe_ends[1], "server localhost\n"); - write(pipe_ends[1], "update delete "); write(pipe_ends[1], domain.c_str()); - write(pipe_ends[1], ".\n"); + write(pipe_ends[1], ". A\n"); write(pipe_ends[1], "update add "); write(pipe_ends[1], domain.c_str()); diff --git a/update.py b/update.py index 8c87e3a..0642c40 100644 --- a/update.py +++ b/update.py @@ -14,10 +14,10 @@ if "user" not in form or "password" not in form or "domain" not in form or "ip" print "Mandatory argument missing: You must supply all of 'user', 'password', 'domain', 'ip'" sys.exit() -ip = form["ip"].value -domain = form["domain"].value user = form["user"].value password = form["password"].value +domain = form["domain"].value +ip = form["ip"].value # run update program p = subprocess.Popen(["/var/lib/named/dyn-nsupdate", user, password, domain, ip], stdout=subprocess.PIPE, stderr=subprocess.PIPE)