]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Add a suffix to our per interface config files for non IPv4 states.
authorRoy Marples <roy@marples.name>
Mon, 26 Mar 2012 17:32:18 +0000 (17:32 +0000)
committerRoy Marples <roy@marples.name>
Mon, 26 Mar 2012 17:32:18 +0000 (17:32 +0000)
This stops RA from stamping on NTP and YP configs.

dhcpcd-hooks/20-resolv.conf
dhcpcd-hooks/50-ntp.conf
dhcpcd-hooks/50-yp.conf
dhcpcd-hooks/50-ypbind
dhcpcd-run-hooks.in

index b4dd5f385edfc9b71fdd0d50cc7fb5c6443c24e6..afe7ebb1231733c3a455a3580101c48d8f6969a2 100644 (file)
@@ -12,7 +12,7 @@ NL="
 
 build_resolv_conf()
 {
-       local cf="$state_dir/resolv.conf.$interface$if_suffix"
+       local cf="$state_dir/resolv.conf.$ifname"
        local interfaces= header= search= srvs= servers= x=
 
        # Build a list of interfaces
@@ -114,25 +114,25 @@ add_resolv_conf()
        done
        if type resolvconf >/dev/null 2>&1; then
                [ -n "$ifmetric" ] && export IF_METRIC="$ifmetric"
-               printf %s "$conf" | resolvconf -a "$interface$if_suffix"
+               printf %s "$conf" | resolvconf -a "$interface$ifname"
                return $?
        fi
 
-       if [ -e "$resolv_conf_dir/$interface$if_suffix" ]; then
-               rm -f "$resolv_conf_dir/$interface$if_suffix"
+       if [ -e "$resolv_conf_dir/$ifname" ]; then
+               rm -f "$resolv_conf_dir/$ifname"
        fi
        [ -d "$resolv_conf_dir" ] || mkdir -p "$resolv_conf_dir"
-       printf %s "$conf" > "$resolv_conf_dir/$interface$if_suffix"
+       printf %s "$conf" > "$resolv_conf_dir/$ifname"
        build_resolv_conf
 }
 
 remove_resolv_conf()
 {
        if type resolvconf >/dev/null 2>&1; then
-               resolvconf -d "$interface$if_suffix" -f
+               resolvconf -d "$ifname" -f
        else
-               if [ -e "$resolv_conf_dir/$interface$if_suffix" ]; then
-                       rm -f "$resolv_conf_dir/$interface$if_suffix"
+               if [ -e "$resolv_conf_dir/$ifname" ]; then
+                       rm -f "$resolv_conf_dir/$ifname"
                fi
                build_resolv_conf
        fi
index 83e71bf03583ea62a31da0d547cdaae6b5e7d356..adbe62024b74eb7029eb115fba46e2683b3f0f03 100644 (file)
@@ -25,7 +25,7 @@ NL="
 
 build_ntp_conf()
 {
-       local cf="$state_dir/ntp.conf.$interface"
+       local cf="$state_dir/ntp.conf.$ifname"
        local interfaces= header= srvs= servers= x=
 
        # Build a list of interfaces
@@ -75,7 +75,7 @@ build_ntp_conf()
 
 add_ntp_conf()
 {
-       local cf="$ntp_conf_dir/$interface" x=
+       local cf="$ntp_conf_dir/$ifname" x=
 
        [ -e "$cf" ] && rm "$cf"
        [ -d "$ntp_conf_dir" ] || mkdir -p "$ntp_conf_dir"
@@ -89,8 +89,8 @@ add_ntp_conf()
 
 remove_ntp_conf()
 {
-       if [ -e "$ntp_conf_dir/$interface" ]; then
-               rm "$ntp_conf_dir/$interface"
+       if [ -e "$ntp_conf_dir/$ifname" ]; then
+               rm "$ntp_conf_dir/$ifname"
        fi
        build_ntp_conf
 }
index 1a2bf4fa11dfc34f31c8af3033db51a7630b816e..2da68ebc9bcde16bcc70f28c9f904056491e4ff5 100644 (file)
@@ -9,7 +9,7 @@ ypbind_pid()
 make_yp_conf()
 {
        [ -z "$new_nis_domain" -a -z "$new_nis_servers" ] && return 0
-       local cf=/etc/yp.conf."$interface" prefix= x= pid=
+       local cf=/etc/yp.conf."$ifname" prefix= x= pid=
        rm -f "$cf"
        echo "$signature" > "$cf"
        if [ -n "$new_nis_domain" ]; then
index f63660e5081cb8ce82afe4f324e0440c1a1d336f..25e009d7fc2bc88143ea57cdc66db8875e4c2aa8 100644 (file)
@@ -20,12 +20,12 @@ best_domain()
 make_yp_binding()
 {
        [ -d "$ypbind_dir" ] || mkdir -p "$ypbind_dir"
-       echo "$new_nis_domain" >"$ypbind_dir/$interface"
+       echo "$new_nis_domain" >"$ypbind_dir/$ifname"
        local nd="$(best_domain)"
 
        local cf=/var/yp/binding/"$new_nis_domain".ypservers
        if [ -n "$new_nis_servers" ]; then
-               local ncf="$cf.$interface" x=
+               local ncf="$cf.$ifname" x=
                rm -f "$ncf"
                for x in $new_nis_servers; do
                        echo "$x" >>"$ncf"
@@ -46,7 +46,7 @@ make_yp_binding()
 
 restore_yp_binding()
 {
-       rm -f "$ypbind_dir/$interface"
+       rm -f "$ypbind_dir/$ifname"
        local nd="$(best_domain)"
        # We need to stop ypbind if there is no best domain
        # otherwise it will just stall as we cannot set domainname
@@ -64,7 +64,7 @@ restore_yp_binding()
 }
 
 if [ "$reason" = PREINIT ]; then
-       rm -f "$ypbind_dir/$interface"
+       rm -f "$ypbind_dir/$ifname"
 elif $if_up || $if_down; then
        if [ -n "$new_nis_domain" ]; then
                if valid_domainname "$new_nis_domain"; then
index dc7dfeb9e13b6e6b034fe094d09d957b333adf97..2125f9a2857e4a27e5e04e91c27aff59fcdfd280 100644 (file)
@@ -2,19 +2,20 @@
 # dhcpcd client configuration script 
 
 # Handy variables and functions for our hooks to use
+if [ "$reason" = ROUTERADVERT ]; then
+       ifsuffix=":ra"
+else
+       ifsuffix=
+fi
+ifname="$interface$ifsuffix"
+
 from=from
 signature_base="# Generated by dhcpcd"
-signature="$signature_base $from $interface"
+signature="$signature_base $from $ifname"
 signature_base_end="# End of dhcpcd"
-signature_end="$signature_base_end $from $interface"
+signature_end="$signature_base_end $from $ifname"
 state_dir=/var/run/dhcpcd
 
-if [ "$reason" = ROUTERADVERT ]; then
-       if_suffix=":ra"
-else
-       if_suffix=
-fi
-
 # Ensure that all arguments are unique
 uniqify()
 {