From: Roy Marples Date: Mon, 26 Mar 2012 17:32:18 +0000 (+0000) Subject: Add a suffix to our per interface config files for non IPv4 states. X-Git-Tag: v5.5.6~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9cf974fea3154a9b3fd90e77970f6d86f2669e51;p=thirdparty%2Fdhcpcd.git Add a suffix to our per interface config files for non IPv4 states. This stops RA from stamping on NTP and YP configs. --- diff --git a/dhcpcd-hooks/20-resolv.conf b/dhcpcd-hooks/20-resolv.conf index b4dd5f38..afe7ebb1 100644 --- a/dhcpcd-hooks/20-resolv.conf +++ b/dhcpcd-hooks/20-resolv.conf @@ -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 diff --git a/dhcpcd-hooks/50-ntp.conf b/dhcpcd-hooks/50-ntp.conf index 83e71bf0..adbe6202 100644 --- a/dhcpcd-hooks/50-ntp.conf +++ b/dhcpcd-hooks/50-ntp.conf @@ -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 } diff --git a/dhcpcd-hooks/50-yp.conf b/dhcpcd-hooks/50-yp.conf index 1a2bf4fa..2da68ebc 100644 --- a/dhcpcd-hooks/50-yp.conf +++ b/dhcpcd-hooks/50-yp.conf @@ -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 diff --git a/dhcpcd-hooks/50-ypbind b/dhcpcd-hooks/50-ypbind index f63660e5..25e009d7 100644 --- a/dhcpcd-hooks/50-ypbind +++ b/dhcpcd-hooks/50-ypbind @@ -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 diff --git a/dhcpcd-run-hooks.in b/dhcpcd-run-hooks.in index dc7dfeb9..2125f9a2 100644 --- a/dhcpcd-run-hooks.in +++ b/dhcpcd-run-hooks.in @@ -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() {