summaryrefslogtreecommitdiffstats
path: root/sbin/dhclient
diff options
context:
space:
mode:
authorume <ume@FreeBSD.org>2011-03-18 12:23:20 +0000
committerume <ume@FreeBSD.org>2011-03-18 12:23:20 +0000
commitb7b4bdf554b412ccfa5038047edf1c35bdd07d1a (patch)
tree7f3003e39c3b93e702b883cb80456b565d226a7d /sbin/dhclient
parent5c37492f6bc8a98141f4bf26f623f929ed510c06 (diff)
downloadFreeBSD-src-b7b4bdf554b412ccfa5038047edf1c35bdd07d1a.zip
FreeBSD-src-b7b4bdf554b412ccfa5038047edf1c35bdd07d1a.tar.gz
Use resolvconf(8) to update /etc/resolv.conf.
If you don't want to use resolvconf(8) to update /etc/resolv.conf, you can put resolvconf_enable="NO" into /etc/dhclient-enter-hooks.
Diffstat (limited to 'sbin/dhclient')
-rw-r--r--sbin/dhclient/dhclient-script71
1 files changed, 46 insertions, 25 deletions
diff --git a/sbin/dhclient/dhclient-script b/sbin/dhclient/dhclient-script
index c457bf4..826d83c 100644
--- a/sbin/dhclient/dhclient-script
+++ b/sbin/dhclient/dhclient-script
@@ -216,29 +216,40 @@ add_new_resolv_conf() {
cat /etc/resolv.conf.tail >>$tmpres
fi
- # When resolv.conf is not changed actually, we don't
- # need to update it.
- # If /usr is not mounted yet, we cannot use cmp, then
- # the following test fails. In such case, we simply
- # ignore an error and do update resolv.conf.
- if cmp -s $tmpres /etc/resolv.conf; then
- rm -f $tmpres
- return 0
- fi 2>/dev/null
-
- # In case (e.g. during OpenBSD installs) /etc/resolv.conf
- # is a symbolic link, take care to preserve the link and write
- # the new data in the correct location.
-
- if [ -f /etc/resolv.conf ]; then
- cat /etc/resolv.conf > /etc/resolv.conf.save
- fi
- cat $tmpres > /etc/resolv.conf
- rm -f $tmpres
+ case $resolvconf_enable in
+ # "no", "false", "off", or "0"
+ [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
+ # When resolv.conf is not changed actually, we don't
+ # need to update it.
+ # If /usr is not mounted yet, we cannot use cmp, then
+ # the following test fails. In such case, we simply
+ # ignore an error and do update resolv.conf.
+ if cmp -s $tmpres /etc/resolv.conf; then
+ rm -f $tmpres
+ return 0
+ fi 2>/dev/null
+
+ # In case (e.g. during OpenBSD installs)
+ # /etc/resolv.conf is a symbolic link, take
+ # care to preserve the link and write the new
+ # data in the correct location.
+
+ if [ -f /etc/resolv.conf ]; then
+ cat /etc/resolv.conf > /etc/resolv.conf.save
+ fi
+ cat $tmpres > /etc/resolv.conf
+
+ # Try to ensure correct ownership and permissions.
+ chown -RL root:wheel /etc/resolv.conf
+ chmod -RL 644 /etc/resolv.conf
+ ;;
- # Try to ensure correct ownership and permissions.
- chown -RL root:wheel /etc/resolv.conf
- chmod -RL 644 /etc/resolv.conf
+ *)
+ /sbin/resolvconf -a ${interface} < $tmpres
+ ;;
+ esac
+
+ rm -f $tmpres
return 0
fi
@@ -296,6 +307,8 @@ if [ -f /etc/dhclient-enter-hooks ]; then
fi
fi
+: ${resolvconf_enable="YES"}
+
case $reason in
MEDIUM)
eval "$IFCONFIG $interface $medium"
@@ -349,9 +362,17 @@ EXPIRE|FAIL)
# XXX Why add alias we just deleted above?
add_new_alias
if is_default_interface; then
- if [ -f /etc/resolv.conf.save ]; then
- cat /etc/resolv.conf.save > /etc/resolv.conf
- fi
+ case $resolvconf_enable in
+ # "no", "false", "off", or "0"
+ [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
+ if [ -f /etc/resolv.conf.save ]; then
+ cat /etc/resolv.conf.save > /etc/resolv.conf
+ fi
+ ;;
+ *)
+ /sbin/resolvconf -d ${interface}
+ ;;
+ esac
fi
;;
OpenPOWER on IntegriCloud