Development discussion of WireGuard
 help / color / mirror / Atom feed
From: Ronan Pigott <rpigott314@gmail.com>
To: wireguard@lists.zx2c4.com
Cc: Ronan Pigott <rpigott@berkeley.edu>
Subject: [PATCH] wg-quick: linux: Don't fail systemd service when using systemd-resolved
Date: Sat, 24 Aug 2019 00:14:51 -0700	[thread overview]
Message-ID: <20190824071451.5297-1-rpigott@berkeley.edu> (raw)

From: Ronan Pigott <rpigott@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@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

_______________________________________________
WireGuard mailing list
WireGuard@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/wireguard

             reply	other threads:[~2019-08-25 15:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-24  7:14 Ronan Pigott [this message]
2019-08-27 22:51 ` Jason A. Donenfeld
2019-08-28  1:21   ` Ronan Pigott
2019-08-28  2:20     ` Jason A. Donenfeld

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190824071451.5297-1-rpigott@berkeley.edu \
    --to=rpigott314@gmail.com \
    --cc=rpigott@berkeley.edu \
    --cc=wireguard@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).