avoid a race condition that might lead to dnsmasq reading an empty resolv.conf (...
authorFelix Fietkau <nbd@openwrt.org>
Thu, 12 Jul 2007 21:59:38 +0000 (21:59 +0000)
committerFelix Fietkau <nbd@openwrt.org>
Thu, 12 Jul 2007 21:59:38 +0000 (21:59 +0000)
SVN-Revision: 7952

package/base-files/files/usr/share/udhcpc/default.script

index a3a696be70a5c361dcf282a6672a5898fe7f6358..7ce3d2aa89c3bb7f346a7e1e1b7c611da97742c2 100755 (executable)
@@ -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