Index: trunk/DNSDB/ExportBIND.pm
===================================================================
--- trunk/DNSDB/ExportBIND.pm	(revision 873)
+++ trunk/DNSDB/ExportBIND.pm	(revision 874)
@@ -117,5 +117,5 @@
           my (@zsoa) = $soasth->fetchrow_array();
 ##fixme: do we even need @loclist passed in?
-          publishrec_bind(\%zonefiles, \@loclist, $zsoa[7], 'y', \%recflags, $revzone,
+          publishrec_bind(\%zonefiles, \@loclist, $zsoa[7], 'y', \%recflags, $cidr,
             $zsoa[0], $zsoa[1], $zsoa[2], $zsoa[3], $zsoa[4], $zsoa[5], $zsoa[6], $loc, '');
         } # if force_refresh etc
@@ -217,4 +217,13 @@
   $zonesth = $dnsdb->{dbh}->prepare("UPDATE domains SET changed='n' WHERE domain_id=?");
   $domsth->execute();
+
+  # Clear %reclfags, since we explicitly want to NOT carry "I've published this
+  # record" over from rDNS, since we have to regenerate any templates for forward
+  # zones.  downside: small mismatches due to overridden entries.  not sure how
+  # best to manage that.  :/
+##fixme:  selectively delete entries to allow template_always_publish_a to flag
+# whether extra A records get published or not.  should default to not (nb, of
+# *course* that's the complex case) to match original tinydns template masking behaviour
+#  %recflags = ();
 
   while (my ($domid,$dom,$domstat,$changed) = $domsth->fetchrow_array) {
@@ -318,4 +327,16 @@
 
       } # while ($recsth)
+
+      # retrieve NS records for subdomains.  not strictly required in current production
+      # context but may matter sometime down the road
+      my $subnssth = $dnsdb->{dbh}->prepare("SELECT r.host,r.val,r.ttl,r.record_id,r.loc,r.stamp,r.expires,r.stampactive ".
+        "FROM records r ".
+        "JOIN domains d ON r.domain_id=d.domain_id ".
+        "WHERE r.type=2 AND d.domain LIKE ?");
+      $subnssth->execute('%.'.$dom);
+      while (my ($host,$val,$ttl,$recid,$loc,$stamp,$expires,$stampactive) = $subnssth->fetchrow_array) {
+        printrec_bind(\%zonefiles, \@loclist, $recid, 'n', \%recflags, $dom,
+          $host, 2, $val, '', '', '', $ttl, $loc, $stamp, $expires, $stampactive);
+      } # subdomain-ns-recsth
 
 
