Allow pdnsd_conf to work without pdnsd_resolv.
authorRoy Marples <roy@marples.name>
Fri, 29 Oct 2010 18:37:55 +0000 (18:37 +0000)
committerRoy Marples <roy@marples.name>
Fri, 29 Oct 2010 18:37:55 +0000 (18:37 +0000)
pdnsd.in
resolvconf.conf.5.in

index 72a20d3dac735c49ab5d1b3399162c11df65eb31..e78d703eb153fb15a37db68f595f8d6736932237 100644 (file)
--- a/pdnsd.in
+++ b/pdnsd.in
@@ -28,7 +28,7 @@
 
 [ -f "@SYSCONFDIR@"/resolvconf.conf ] || exit 0
 . "@SYSCONFDIR@/resolvconf.conf" || exit 1
-[ -z "$pdnsd_resolv" ] && exit 0
+[ -z "$pdnsd_conf" -a -z "$pdnsd_resolv" ] && exit 0
 [ -z "$RESOLVCONF" ] && eval "$(@PREFIX@/sbin/resolvconf -v)"
 
 : ${pdnsd_restart:=pdnsd-ctl config $pdnsd_conf}
@@ -83,16 +83,37 @@ change_file()
 newresolv="# Generated by resolvconf\n"
 changed=false
 
-for n in $NAMESERVERS; do
-       newresolv="${newresolv}nameserver $n\n"
-done
+if [ -n "$pdnsd_resolv" ]; then
+       for n in $NAMESERVERS; do
+               newresolv="${newresolv}nameserver $n\n"
+       done
+fi
 
 if [ -n "$pdnsd_conf" ]; then
        cf="$pdnsd_conf.new"
        newconf=
+
+       if [ -z "$pdnsd_resolv" ]; then
+               newconf="${newconf}server {\n"
+               newconf="${newconf}\tlabel=resolvconf;\n"
+               if [ -n "$NAMESERVERS" ]; then
+                       newconf="${newconf}\tip="
+                       first=true
+                       for n in $NAMESERVERS; do
+                               if $first; then
+                                       first=false
+                               else
+                                       newconf="${newconf},"
+                               fi
+                               newconf="$newconf$n"
+                       done
+                       newconf="${newconf};\n}\n"
+               fi
+       fi
+
        for d in $DOMAINS; do
                newconf="${newconf}server {\n"
-               newconf="${newconf}\tinclude=\"${d%%:*}\";\n"
+               newconf="${newconf}\tinclude=.${d%%:*}.;\n"
                newconf="${newconf}\tpolicy=excluded;\n"
                newconf="${newconf}\tip="
                ns="${d#*:}"
index c295e72872cb8cccbbee57ff27e97691673e0149..0682ca0535d8cd2154a078fabf315d3a6714a5b6 100644 (file)
@@ -138,13 +138,19 @@ Example named.conf:
 .It Sy pdnsd_conf
 This is the main pdnsd configuration file which we modify to add our
 forward domains to.
+If this variable is not set then we rely on the pdnsd configuration file
+setup to read
+.Pa pdnsd_resolv
+as documented below.
 .It Sy pdnsd_resolv
 This file tells pdnsd about global nameservers.
+If this variable is not set then it's written to
+.Pa pdnsd_conf .
 .Pp
 Example resolvconf.conf for pdnsd:
 .D1 nameservers=127.0.0.1
 .D1 pdnsd_conf=/etc/pdnsd.conf
-.D1 pdnsd_resolv=/etc/pdnsd-resolv.conf
+.D1 pdnsd_resolv=/etc/pdnsd-resolv.conf
 .Pp
 Example pdnsd.conf:
 .D1 global {
@@ -152,8 +158,10 @@ Example pdnsd.conf:
 .D1    status_ctl = on;
 .D1 }
 .D1 server {
-.D1    label="resolvconf";
-.D1    file="/etc/pdnsd-resolv.conf";
+.D1    # A server definition is required, even if emtpy.
+.D1    label="empty";
+.D1    proxy_only=on;
+.D1    # file="/etc/pdnsd-resolv.conf";
 .D1 }
 .It Sy unbound_conf
 This file tells unbound about specific and global nameservers.