diff hooks/20-resolv.conf @ 5572:aae13416e9b7 draft

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.
author Roy Marples <roy@marples.name>
date Sun, 27 Dec 2020 22:31:02 +0000
parents 4fe5c2a71254
children
line wrap: on
line diff
--- a/hooks/20-resolv.conf	Sun Dec 27 22:04:45 2020 +0000
+++ b/hooks/20-resolv.conf	Sun Dec 27 22:31:02 2020 +0000
@@ -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 @@
 
 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