ius/local.pm
changeset 25 2a7ec071b455
parent 24 6c4ec099c4a8
child 26 69db99842596
equal deleted inserted replaced
24:6c4ec099c4a8 25:2a7ec071b455
    11 #       src ip
    11 #       src ip
    12 # out:  0 failure ($@ contains message)
    12 # out:  0 failure ($@ contains message)
    13 #      !0 ok      ($@ may contain message)
    13 #      !0 ok      ($@ may contain message)
    14 sub addZone($$) {
    14 sub addZone($$) {
    15     my ($zone, $src) = @_;
    15     my ($zone, $src) = @_;
       
    16     my $hdns = '84.19.194.5';
    16 
    17 
    17     # Filename ist für das File selbst und auch für die Konfig
    18     # Filename ist für das File selbst und auch für die Konfig
    18     (my $file = $zone) =~ s/[\/&|]/_/g;
    19     (my $file = $zone) =~ s/[\/&|]/_/g;
    19 
    20 
    20     my $txt = <<__;
    21     my $txt = <<__;
    22 zone "$zone" IN {
    23 zone "$zone" IN {
    23     type slave;
    24     type slave;
    24     file "/etc/bind/s/$file";
    25     file "/etc/bind/s/$file";
    25     masters { %masters; };
    26     masters { %masters; };
    26     allow-query { any; };
    27     allow-query { any; };
    27     allow-transfer { none; };
    28     allow-transfer { %transferees; };
    28 };
    29 };
    29 
    30 
    30 __
    31 __
    31 
    32 
       
    33     # 84.19.194.5 ist die ip unseres hidden master
       
    34     my $transferees = $src eq $hdns ?  'localhost; key hh.schlittermann.de' : 'none';
       
    35 
    32     $txt =~ s/%time/scalar localtime/eg;
    36     $txt =~ s/%time/scalar localtime/eg;
    33     $txt =~ s/%masters/$src/g;
    37     $txt =~ s/%masters/$src/g;
       
    38     $txt =~ s/%transferees/$transferees/g;
    34 
    39 
    35     if (-f ($_ = "/etc/bind/zones.d/$file")) {
    40     if (-f ($_ = "/etc/bind/zones.auto/$file")) {
    36 	$@ = "$_ already exists";
    41 	$@ = "$_ already exists";
    37 	return 0;
    42 	return 0;
    38     }
    43     }
       
    44 
       
    45     if (-f ($_ = "/etc/bind/zones.auto/.removed/$file")) {
       
    46 	$@ = "$_ removed";
       
    47 	return 0;
       
    48     }
       
    49     
       
    50     s/\.removed\///;
    39 
    51 
    40     open(OUT, $_ = ">$_") or die "Can't open $_: $!\n";
    52     open(OUT, $_ = ">$_") or die "Can't open $_: $!\n";
    41     print OUT $txt;
    53     print OUT $txt;
    42 
    54 
    43     open(OUT, $_ = ">>/etc/bind/zones.all") or die "Can't open $_: $!\n";
    55     open(OUT, $_ = ">>/etc/bind/zones.all") or die "Can't open $_: $!\n";