saving uncommitted changes; auto add transferees if our hidden master notifies us
authorMatthias Förste foerste@schlittermann.de
Mon, 15 Aug 2011 14:51:23 +0200
changeset 25 2a7ec071b455
parent 24 6c4ec099c4a8
child 26 69db99842596
saving uncommitted changes; auto add transferees if our hidden master notifies us
ius/local.pm
--- a/ius/local.pm	Mon Aug 15 14:48:04 2011 +0200
+++ b/ius/local.pm	Mon Aug 15 14:51:23 2011 +0200
@@ -13,6 +13,7 @@
 #      !0 ok      ($@ may contain message)
 sub addZone($$) {
     my ($zone, $src) = @_;
+    my $hdns = '84.19.194.5';
 
     # Filename ist für das File selbst und auch für die Konfig
     (my $file = $zone) =~ s/[\/&|]/_/g;
@@ -24,19 +25,30 @@
     file "/etc/bind/s/$file";
     masters { %masters; };
     allow-query { any; };
-    allow-transfer { none; };
+    allow-transfer { %transferees; };
 };
 
 __
 
+    # 84.19.194.5 ist die ip unseres hidden master
+    my $transferees = $src eq $hdns ?  'localhost; key hh.schlittermann.de' : 'none';
+
     $txt =~ s/%time/scalar localtime/eg;
     $txt =~ s/%masters/$src/g;
+    $txt =~ s/%transferees/$transferees/g;
 
-    if (-f ($_ = "/etc/bind/zones.d/$file")) {
+    if (-f ($_ = "/etc/bind/zones.auto/$file")) {
 	$@ = "$_ already exists";
 	return 0;
     }
 
+    if (-f ($_ = "/etc/bind/zones.auto/.removed/$file")) {
+	$@ = "$_ removed";
+	return 0;
+    }
+    
+    s/\.removed\///;
+
     open(OUT, $_ = ">$_") or die "Can't open $_: $!\n";
     print OUT $txt;