From e45b81abe0aafa8a04bd64ac31a2fac63ce675b7 Mon Sep 17 00:00:00 2001 From: Jakub Hrozek Date: Tue, 16 Apr 2013 14:19:15 +0200 Subject: dyndns: new option dyndns_force_tcp https://fedorahosted.org/sssd/ticket/1831 Adds a new option that can be used to force nsupdate to only use TCP to communicate with the DNS server. --- src/providers/dp_dyndns.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/providers/dp_dyndns.c') diff --git a/src/providers/dp_dyndns.c b/src/providers/dp_dyndns.c index 79701c62..36cce458 100644 --- a/src/providers/dp_dyndns.c +++ b/src/providers/dp_dyndns.c @@ -935,7 +935,8 @@ static void be_nsupdate_done(struct tevent_req *subreq); struct tevent_req *be_nsupdate_send(TALLOC_CTX *mem_ctx, struct tevent_context *ev, - char *nsupdate_msg) + char *nsupdate_msg, + bool force_tcp) { int pipefd_to_child[2]; pid_t child_pid; @@ -943,7 +944,7 @@ struct tevent_req *be_nsupdate_send(TALLOC_CTX *mem_ctx, struct tevent_req *req = NULL; struct tevent_req *subreq = NULL; struct be_nsupdate_state *state; - char *args[3]; + char *args[4]; req = tevent_req_create(mem_ctx, &state, struct be_nsupdate_state); if (req == NULL) { @@ -962,14 +963,24 @@ struct tevent_req *be_nsupdate_send(TALLOC_CTX *mem_ctx, child_pid = fork(); if (child_pid == 0) { /* child */ + memset(args, 0, 4 * sizeof(char *)); + args[0] = talloc_strdup(state, NSUPDATE_PATH); args[1] = talloc_strdup(state, "-g"); - args[2] = NULL; if (args[0] == NULL || args[1] == NULL) { ret = ENOMEM; goto done; } + if (force_tcp) { + DEBUG(SSSDBG_FUNC_DATA, ("TCP is set to on\n")); + args[2] = talloc_strdup(state, "-v"); + if (args[2] == NULL) { + ret = ENOMEM; + goto done; + } + } + close(pipefd_to_child[1]); ret = dup2(pipefd_to_child[0], STDIN_FILENO); if (ret == -1) { @@ -1117,6 +1128,7 @@ static struct dp_option default_dyndns_opts[] = { { "dyndns_iface", DP_OPT_STRING, NULL_STRING, NULL_STRING }, { "dyndns_ttl", DP_OPT_NUMBER, { .number = 1200 }, NULL_NUMBER }, { "dyndns_update_ptr", DP_OPT_BOOL, BOOL_TRUE, BOOL_FALSE }, + { "dyndns_force_tcp", DP_OPT_BOOL, BOOL_FALSE, BOOL_FALSE }, DP_OPTION_TERMINATOR }; -- cgit