summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2012-03-26 17:32:18 +0000
committerRoy Marples <roy@marples.name>2012-03-26 17:32:18 +0000
commit9cf974fea3154a9b3fd90e77970f6d86f2669e51 (patch)
treeff9a7845c8d79d45c1db74f6d8ce41d31018f8c5
parentbb02dff14da7b4a77ed25567574088bcd0b4f81d (diff)
downloaddhcpcd-9cf974fea3154a9b3fd90e77970f6d86f2669e51.tar.xz
Add a suffix to our per interface config files for non IPv4 states.
This stops RA from stamping on NTP and YP configs.
-rw-r--r--dhcpcd-hooks/20-resolv.conf16
-rw-r--r--dhcpcd-hooks/50-ntp.conf8
-rw-r--r--dhcpcd-hooks/50-yp.conf2
-rw-r--r--dhcpcd-hooks/50-ypbind8
-rw-r--r--dhcpcd-run-hooks.in17
5 files changed, 26 insertions, 25 deletions
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()
{