summaryrefslogtreecommitdiffstats
path: root/sbin/dhclient/dhclient-script
diff options
context:
space:
mode:
authorwes <wes@FreeBSD.org>2006-01-23 05:42:59 +0000
committerwes <wes@FreeBSD.org>2006-01-23 05:42:59 +0000
commite00a5cdab0c1069989207fa566573c230be64836 (patch)
tree720b90b7a2daf92789388ef9cd17e74ec63c921f /sbin/dhclient/dhclient-script
parentf26da230031e1fb4e19aac17933940c277f3f1d1 (diff)
downloadFreeBSD-src-e00a5cdab0c1069989207fa566573c230be64836.zip
FreeBSD-src-e00a5cdab0c1069989207fa566573c230be64836.tar.gz
Make dhclient-script more agreeable with read-only /etc.
PR: 90518 Submitted by: John E. Hein <jhein@timing.com> MFC after: 3 days
Diffstat (limited to 'sbin/dhclient/dhclient-script')
-rw-r--r--sbin/dhclient/dhclient-script19
1 files changed, 10 insertions, 9 deletions
diff --git a/sbin/dhclient/dhclient-script b/sbin/dhclient/dhclient-script
index fd1fd61..9ba598c 100644
--- a/sbin/dhclient/dhclient-script
+++ b/sbin/dhclient/dhclient-script
@@ -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
OpenPOWER on IntegriCloud