zoneconf.in: Allow control over query access.
[zoneconf] / zoneconf.in
index 224710f..13c269d 100755 (executable)
@@ -992,6 +992,7 @@ define-configuration-space zone ZONECFG {
   define-simple dir-mode 2775
   define-simple zone-file "%v/%z.zone"
   define-simple soa-format increment
+  define-simple allow-query nil
   define-list views *
   define-list sign-views {}
   define-list signzone-command \
@@ -1000,7 +1001,7 @@ define-configuration-space zone ZONECFG {
           "-S" \
           "-K%h/key" \
           "-d%h/ds" \
-          "-s-3600" "-e+176400" \
+          "-s-3600" "-e+176400" "-i90000" \
           "-N%q" \
           "-o%z" \
           "-f%o" \
@@ -1022,6 +1023,12 @@ define-configuration-space zone ZONECFG {
   }
 
   define primary {map} {
+    ## There's a grim hack here: a primary-address entry may have the form
+    ## REAL!FAKE.  If the REAL address is not a local address then this
+    ## is used as the master address; otherwise the FAKE address is used.
+    ## This is useful for inter-view updates of dynamic zones on the same
+    ## host.  I suggest abusing 127.0.0.0/8 addresses for this kind of
+    ## chicanery.
     if {[llength $map] % 2} {
       error "master map must have an even number of items"
     }
@@ -1141,13 +1148,28 @@ proc compute-zone-properties {view config} {
   if {[info exists zone(mapped-view)]} {
     foreach {outview hosts} $zone(master-map) {
       if {[string match $outview $zone(mapped-view)]} {
-       set zone(masters) $hosts
+       set masters {}
        set zone(config-type) slave
        foreach host $hosts {
-         if {[local-address-p $host]} {
+         set bang [string first "!" $host]
+         if {$bang >= 0} {
+           set after [string range $host [expr {$bang + 1}] end]
+           if {$bang} {
+             set before [string range $host 0 [expr {$bang - 1}]]
+           } else {
+             set before $after
+           }
+           if {[local-address-p $before]} {
+             set host $after
+           } else {
+             set host $before
+           }
+         } elseif {[local-address-p $host]} {
            set zone(config-type) master
          }
+         lappend masters $host
        }
+       set zone(masters) $masters
        break
       }
     }
@@ -1223,7 +1245,7 @@ proc sign-zone-file {info soafmt infile} {
 
   array set zone $info
   set outfile "$zone(server-file-name).new"
-  if {![run "zone `$zone(name)' in view `$zone(mapped-view)'" \
+  if {![run "sign zone `$zone(name)' in view `$zone(mapped-view)'" \
            $zone(signzone-command) \
            "%h" $zone(home-dir) \
            "%m" $zone(static-dir) \
@@ -1279,6 +1301,9 @@ proc write-zone-stanza {view chan config} {
       }
     }
   }
+  if {![string equal $zone(allow-query) nil]} {
+    puts $chan "\tallow-query {$zone(allow-query)};"
+  }
   puts $chan "};";
 }
 
@@ -1351,8 +1376,8 @@ defcmd update {} {
 defcmd install {user view name} {
   help-text "Install a new zone file.
 
-           The file is for the given zone NAME and \(user-side) VIEW.  The file is
-           provided by the named USER"
+The file is for the given zone NAME and \(user-side) VIEW.  The file is
+provided by the named USER."
 } {
   global QUIS ZONECFG ZONES CONFFILE errorInfo errorCode