From 53ab3c27cdc03f03906dd0170c12c9039ef66fc3 Mon Sep 17 00:00:00 2001 From: Tobias Brunner Date: Fri, 28 Sep 2012 17:33:24 +0200 Subject: Ensure that pipe is closed when calling resolvconf(8) --- src/libhydra/plugins/resolve/resolve_handler.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/libhydra/plugins/resolve/resolve_handler.c') diff --git a/src/libhydra/plugins/resolve/resolve_handler.c b/src/libhydra/plugins/resolve/resolve_handler.c index 2bee45d0d..0a3094fd7 100644 --- a/src/libhydra/plugins/resolve/resolve_handler.c +++ b/src/libhydra/plugins/resolve/resolve_handler.c @@ -150,6 +150,7 @@ static bool invoke_resolvconf(private_resolve_handler_t *this, bool install) { char cmd[128]; + bool success = TRUE; /* we use the nameserver's IP address as part of the interface name to * make them unique */ @@ -171,7 +172,8 @@ static bool invoke_resolvconf(private_resolve_handler_t *this, DBG1(DBG_IKE, "installing DNS server %H via resolvconf", addr); fprintf(out, "nameserver %H # by strongSwan, from %Y\n", addr, server); - if (ferror(out) || pclose(out)) + success = !ferror(out); + if (pclose(out)) { return FALSE; } @@ -180,7 +182,7 @@ static bool invoke_resolvconf(private_resolve_handler_t *this, { ignore_result(system(cmd)); } - return TRUE; + return success; } METHOD(attribute_handler_t, handle, bool, -- cgit v1.2.3