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.
This commit is contained in:
Hajimu UMEMOTO 2011-03-18 12:23:20 +00:00
parent b7f8411df2
commit 9201145d02
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=219739

View File

@ -216,30 +216,41 @@ add_new_resolv_conf() {
cat /etc/resolv.conf.tail >>$tmpres cat /etc/resolv.conf.tail >>$tmpres
fi fi
# When resolv.conf is not changed actually, we don't case $resolvconf_enable in
# need to update it. # "no", "false", "off", or "0"
# If /usr is not mounted yet, we cannot use cmp, then [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
# the following test fails. In such case, we simply # When resolv.conf is not changed actually, we don't
# ignore an error and do update resolv.conf. # need to update it.
if cmp -s $tmpres /etc/resolv.conf; then # If /usr is not mounted yet, we cannot use cmp, then
rm -f $tmpres # the following test fails. In such case, we simply
return 0 # ignore an error and do update resolv.conf.
fi 2>/dev/null 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 # In case (e.g. during OpenBSD installs)
# is a symbolic link, take care to preserve the link and write # /etc/resolv.conf is a symbolic link, take
# the new data in the correct location. # 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
;;
*)
/sbin/resolvconf -a ${interface} < $tmpres
;;
esac
if [ -f /etc/resolv.conf ]; then
cat /etc/resolv.conf > /etc/resolv.conf.save
fi
cat $tmpres > /etc/resolv.conf
rm -f $tmpres rm -f $tmpres
# Try to ensure correct ownership and permissions.
chown -RL root:wheel /etc/resolv.conf
chmod -RL 644 /etc/resolv.conf
return 0 return 0
fi fi
@ -296,6 +307,8 @@ if [ -f /etc/dhclient-enter-hooks ]; then
fi fi
fi fi
: ${resolvconf_enable="YES"}
case $reason in case $reason in
MEDIUM) MEDIUM)
eval "$IFCONFIG $interface $medium" eval "$IFCONFIG $interface $medium"
@ -349,9 +362,17 @@ EXPIRE|FAIL)
# XXX Why add alias we just deleted above? # XXX Why add alias we just deleted above?
add_new_alias add_new_alias
if is_default_interface; then if is_default_interface; then
if [ -f /etc/resolv.conf.save ]; then case $resolvconf_enable in
cat /etc/resolv.conf.save > /etc/resolv.conf # "no", "false", "off", or "0"
fi [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 fi
;; ;;