[PATCH] wg-quick: linux: Don't fail systemd service when using systemd-resolved

Ronan Pigott rpigott314 at gmail.com
Sat Aug 24 09:14:51 CEST 2019


From: Ronan Pigott <rpigott at berkeley.edu>

systemd-resolved has a compatibility interface for use with resolvconf
scripts when resolvectl is called from a symlink from resolvconf.
However, when tearing down the interface, cmd_down calls del_if and
then unset_dns. In the case of systemd-resolved, deleting the interface
also removes the systemd-resolved entry and causes resolvconf -d to fail
when resolvconf really is a symlink to resolvectl.

The failure is harmless, as the dns entries have already been
effectively removed, but the nonzero exit code causes the systemd
service in 'systemctl stop wg-quick at ifname' to exit with failure.

Adding real sysemd-resolved support might involve checking if resolved
is running through dbus and such, but I think thats generally beyond the
scope of the wg-quick tool. Instead, the intent of this patch is basically:

"Let users off the hook for failure in resolvconf this one time if it's
really just a symlink to resolvectl"

---
 src/tools/wg-quick/linux.bash | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/tools/wg-quick/linux.bash b/src/tools/wg-quick/linux.bash
index 2f36dee..63ef781 100755
--- a/src/tools/wg-quick/linux.bash
+++ b/src/tools/wg-quick/linux.bash
@@ -300,7 +300,7 @@ cmd_down() {
 	execute_hooks "${PRE_DOWN[@]}"
 	[[ $SAVE_CONFIG -eq 0 ]] || save_config
 	del_if
-	unset_dns
+	unset_dns || [[ "$(type -P resolvconf)" -ef "$(type -P resolvectl)" ]]
 	execute_hooks "${POST_DOWN[@]}"
 }
 
-- 
2.23.0



More information about the WireGuard mailing list