Fix for myplc-native:
authorMarc Fiuczynski <mef@cs.princeton.edu>
Tue, 29 Jan 2008 22:17:49 +0000 (22:17 +0000)
committerMarc Fiuczynski <mef@cs.princeton.edu>
Tue, 29 Jan 2008 22:17:49 +0000 (22:17 +0000)
 - only create a new /etc/resolv.conf if PLC_NET_DNS1 or PLC_NET_DNS2
   is specified

plc.d/network

index 6fac27b..5d3d443 100755 (executable)
@@ -46,12 +46,18 @@ case "$1" in
        rm -f $hfile
 
        # Set up nameservers
+       rfile=$(mktemp)
        (
            echo "; generated by /etc/plc.d/network"
            [ -n "$PLC_NET_DNS1" ] && echo "nameserver $PLC_NET_DNS1"
            [ -n "$PLC_NET_DNS2" -a "$PLC_NET_DNS1" != "$PLC_NET_DNS2" ] && echo "nameserver $PLC_NET_DNS2"
-       ) > /etc/resolv.conf
-       chmod +r /etc/resolv.conf
+       ) > $rfile
+       if [ -n "$PLC_NET_DNS1" -o -n "$PLC_NET_DNS2" ] ; then
+           mv $rfile /etc/resolv.conf
+           chmod 444 /etc/resolv.conf
+       else
+           rm -f $rfile
+       fi
 
        result "$MESSAGE"
        ;;