property_tree::ptree config;
property_tree::ini_parser::read_ini(CONFIG_FILE, config);
std::string nsupdate = config.get<std::string>("nsupdate");
- std::string keyfile = config.get<std::string>("key");
/* Check username, password, domain */
optional<std::string> correct_password = config.get_optional<std::string>(user+".password");
}
/* 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();
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());
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)