Ensure that pipe is closed when calling resolvconf(8)
authorTobias Brunner <tobias@strongswan.org>
Fri, 28 Sep 2012 15:33:24 +0000 (17:33 +0200)
committerTobias Brunner <tobias@strongswan.org>
Fri, 28 Sep 2012 15:33:24 +0000 (17:33 +0200)
src/libhydra/plugins/resolve/resolve_handler.c

index 2bee45d..0a3094f 100644 (file)
@@ -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,