]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
20-resolv.conf: Don't call resolvconf -c if we didn't call -C
authorRoy Marples <roy@marples.name>
Sun, 27 Dec 2020 22:31:02 +0000 (22:31 +0000)
committerRoy Marples <roy@marples.name>
Sun, 27 Dec 2020 22:33:11 +0000 (22:33 +0000)
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

index 86f4873d01fa7cdee3763a3b2675b22a20a9bf1b..504a6c5373a400042a5b780d32dfdbb834444a7f 100644 (file)
@@ -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