From fa2a6d6883931ef2ea2e6785b5547f0655c72ec7 Mon Sep 17 00:00:00 2001 From: nbd Date: Thu, 12 Jul 2007 21:59:38 +0000 Subject: avoid a race condition that might lead to dnsmasq reading an empty resolv.conf (#2007) git-svn-id: svn://svn.openwrt.org/openwrt/trunk@7952 3c298f89-4303-0410-b956-a3cf2f4a3e73 --- package/base-files/files/usr/share/udhcpc/default.script | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'package/base-files/files/usr/share') diff --git a/package/base-files/files/usr/share/udhcpc/default.script b/package/base-files/files/usr/share/udhcpc/default.script index a3a696be70..7ce3d2aa89 100755 --- a/package/base-files/files/usr/share/udhcpc/default.script +++ b/package/base-files/files/usr/share/udhcpc/default.script @@ -47,12 +47,13 @@ case "$1" in } [ -n "$dns" ] && { - echo -n > $RESOLV_CONF - ${domain:+echo search $domain} >> $RESOLV_CONF + echo -n > "${RESOLV_CONF}.tmp" + ${domain:+echo search $domain} >> "${RESOLV_CONF}.tmp" for i in $dns ; do echo "adding dns $i" - echo "nameserver $i" >> $RESOLV_CONF + echo "nameserver $i" >> "${RESOLV_CONF}.tmp" done + mv "${RESOLV_CONF}.tmp" "$RESOLV_CONF" } hotplug_event ifup -- cgit v1.2.3