From 6468e7f2c01ace7a24039cc7bd9b12142ce063a0 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Sun, 27 Dec 2020 22:31:02 +0000 Subject: [PATCH] 20-resolv.conf: Don't call resolvconf -c if we didn't call -C This solves the warnings on all OS other than Linux who don't have a supporting resolvconf for deprecating DNS because they never emit the NOCARRIER_ROAMING reason. --- hooks/20-resolv.conf | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hooks/20-resolv.conf b/hooks/20-resolv.conf index 86f4873d..504a6c53 100644 --- a/hooks/20-resolv.conf +++ b/hooks/20-resolv.conf @@ -7,6 +7,7 @@ # or dnsmasq. This is important as the libc resolver isn't that powerful. resolv_conf_dir="$state_dir/resolv.conf" +nocarrier_roaming_dir="$state_dir/roaming" NL=" " : ${resolvconf:=resolvconf} @@ -205,9 +206,16 @@ esac if $if_configured; then if $have_resolvconf && [ "$reason" = NOCARRIER_ROAMING ]; then + # avoid calling resolvconf -c on CARRIER unless we roam + mkdir -p "$nocarrier_roaming_dir" + echo " " >"$nocarrier_roaming_dir/$interface" "$resolvconf" -C "$interface.*" elif $have_resolvconf && [ "$reason" = CARRIER ]; then - "$resolvconf" -c "$interface.*" + # Not all resolvconf implementations support -c + if [ -e "$nocarrier_roaming_dir/$interface" ]; then + rm -f "$nocarrier_roaming_dir/$interface" + "$resolvconf" -c "$interface.*" + fi elif $if_up || [ "$reason" = ROUTERADVERT ]; then add_resolv_conf elif $if_down; then -- 2.47.2