- if (config.get<std::string>(user+".domain") != domain) {
- std::cerr << "Domain incorrect." << std::endl;
- return 1;
+
+ /* preapre the pipe */
+ 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();
+ if (child_pid < 0) {
+ std::cerr << "Error while forking." << std::endl;
+ exit(1);
+ }
+ if (child_pid == 0) {
+ /* We're in the child */
+ /* Close write end, use read end as stdin */
+ close(pipe_ends[1]);
+ if (dup2(pipe_ends[0], fileno(stdin)) < 0) {
+ std::cerr << "There was an error redirecting stdin." << std::endl;
+ exit(1);
+ }
+ /* exec nsupdate */
+ 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);