Make dhclient-script more agreeable with read-only /etc.

PR:		90518
Submitted by:	John E. Hein <jhein@timing.com>
MFC after:	3 days
This commit is contained in:
Wes Peters 2006-01-23 05:42:59 +00:00
parent ad4e4c676f
commit 90158aee27

View File

@ -135,21 +135,22 @@ add_new_resolv_conf() {
# thus broke the script. This code creates the resolv.conf if either
# are provided.
rm -f /etc/resolv.conf.std
local tmpres=${TMPDIR:-/tmp}/resolv.conf.std
rm -f $tmpres
if [ -n "$new_domain_name" ]; then
echo "search $new_domain_name" >>/etc/resolv.conf.std
echo "search $new_domain_name" >>$tmpres
fi
if [ -n "$new_domain_name_servers" ]; then
for nameserver in $new_domain_name_servers; do
echo "nameserver $nameserver" >>/etc/resolv.conf.std
echo "nameserver $nameserver" >>$tmpres
done
fi
if [ -f /etc/resolv.conf.std ]; then
if [ -f $tmpres ]; then
if [ -f /etc/resolv.conf.tail ]; then
cat /etc/resolv.conf.tail >>/etc/resolv.conf.std
cat /etc/resolv.conf.tail >>$tmpres
fi
# When resolv.conf is not changed actually, we don't
@ -157,8 +158,8 @@ add_new_resolv_conf() {
# 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 /etc/resolv.conf.std /etc/resolv.conf; then
rm -f /etc/resolv.conf.std
if cmp -s $tmpres /etc/resolv.conf; then
rm -f $tmpres
return 0
fi 2>/dev/null
@ -169,8 +170,8 @@ add_new_resolv_conf() {
if [ -f /etc/resolv.conf ]; then
cat /etc/resolv.conf > /etc/resolv.conf.save
fi
cat /etc/resolv.conf.std > /etc/resolv.conf
rm -f /etc/resolv.conf.std
cat $tmpres > /etc/resolv.conf
rm -f $tmpres
# Try to ensure correct ownership and permissions.
chown -RL root:wheel /etc/resolv.conf