aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2016-06-07 15:58:05 +0200
committerTobias Brunner <tobias@strongswan.org>2016-06-10 18:39:21 +0200
commitf4a20b74fdf4affdae6042c4cbbfbc35cf6ce1bc (patch)
tree567dc3667d589091184d17132f05220e7464e061 /src
parent96b1fab53ce7f7b4b6c5e2a0bb85c3f3f14be62c (diff)
downloadstrongswan-f4a20b74fdf4affdae6042c4cbbfbc35cf6ce1bc.tar.bz2
strongswan-f4a20b74fdf4affdae6042c4cbbfbc35cf6ce1bc.tar.xz
resolve: Make sure to clean up if calling resolvconf failed
If running resolvconf fails handle() fails release() is not called, which might leave an interface file on the system (or depending on which script called by resolvconf actually failed even the installed DNS server).
Diffstat (limited to 'src')
-rw-r--r--src/libcharon/plugins/resolve/resolve_handler.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/libcharon/plugins/resolve/resolve_handler.c b/src/libcharon/plugins/resolve/resolve_handler.c
index ec3decc4d..aa0bea34d 100644
--- a/src/libcharon/plugins/resolve/resolve_handler.c
+++ b/src/libcharon/plugins/resolve/resolve_handler.c
@@ -149,7 +149,6 @@ 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 */
@@ -162,6 +161,7 @@ static bool invoke_resolvconf(private_resolve_handler_t *this,
if (install)
{
FILE *out;
+ bool success;
out = popen(cmd, "w");
if (!out)
@@ -171,8 +171,9 @@ static bool invoke_resolvconf(private_resolve_handler_t *this,
DBG1(DBG_IKE, "installing DNS server %H via resolvconf", addr);
fprintf(out, "nameserver %H\n", addr);
success = !ferror(out);
- if (pclose(out))
+ if (pclose(out) || !success)
{
+ invoke_resolvconf(this, server, addr, FALSE);
return FALSE;
}
}
@@ -180,7 +181,7 @@ static bool invoke_resolvconf(private_resolve_handler_t *this,
{
ignore_result(system(cmd));
}
- return success;
+ return TRUE;
}
METHOD(attribute_handler_t, handle, bool,