Release openresolv-3.5.2
[openresolv] / pdnsd.in
index 5fbe2a076a579c4209a76363a9926f9f0893510a..0a0241a7c7b3df92e85fee20a020f8b6d598083e 100644 (file)
--- a/pdnsd.in
+++ b/pdnsd.in
@@ -48,7 +48,7 @@ remove_markers()
                sed "/^$m1/,/^$m2/d" $@
        else
                for x; do
-                       while read line; do
+                       while read -r line; do
                                case "$line" in
                                "$m1"*) in_marker=1;;
                                "$m2"*) in_marker=0;;
@@ -85,13 +85,21 @@ change_file()
 newresolv="# Generated by resolvconf\n"
 changed=false
 
+# Try to ensure that config dirs exist
+if type config_mkdirs >/dev/null 2>&1; then
+       config_mkdirs "$pdnsd_resolv" "$pdnsd_conf"
+else
+       @PREFIX@/sbin/resolvconf -D "$pdnsd_resolv" "$pdnsd_conf"
+fi
+
 if [ -n "$pdnsd_resolv" ]; then
        for n in $NAMESERVERS; do
                newresolv="${newresolv}nameserver $n\n"
        done
 fi
 
-if [ -n "$pdnsd_conf" ]; then
+# Only modify the configuration if it exists and we can write to it
+if [ -w "$pdnsd_conf" ]; then
        cf="$pdnsd_conf.new"
        newconf=