X-Git-Url: https://git.ralfj.de/dyn-nsupdate.git/blobdiff_plain/2edc45010802bffc986662091ca0e2d4d8f054ef..0f7c85cebd0ecebf94390fb7ab380327e1068b20:/dyn-nsupdate.cpp 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());