chiark / gitweb /
Bugfixes
authorianmdlvl <ianmdlvl>
Mon, 31 Dec 2001 15:15:13 +0000 (15:15 +0000)
committerianmdlvl <ianmdlvl>
Mon, 31 Dec 2001 15:15:13 +0000 (15:15 +0000)
scripts/named-conf

index 0f4861e2e594933be1a05f8682ec3399a24164c0..eefadcd959bf36a17a708e94649a90783139e96e 100755 (executable)
@@ -4,10 +4,12 @@ use strict;
 use IO::File;
 use Data::Dumper;
 
 use IO::File;
 use Data::Dumper;
 
-use vars qw($mode
+use vars qw($quis $mode
            $etcfile $where
            $debug $needglue $localonly $verbosity);
 
            $etcfile $where
            $debug $needglue $localonly $verbosity);
 
+$quis= $0; $quis =~ s,.*/,,;
+
 $mode= '';
 $etcfile= "/etc/bind/chiark-conf-gen.zones";
 $where= '<built-in>';
 $mode= '';
 $etcfile= "/etc/bind/chiark-conf-gen.zones";
 $where= '<built-in>';
@@ -97,12 +99,11 @@ debug_dump('@zone_cfg_list %zone_cfg');
 process_zones($mode ? @zone_cfg_list : @ARGV);
 debug_dump('%output_contents');
 
 process_zones($mode ? @zone_cfg_list : @ARGV);
 debug_dump('%output_contents');
 
-print STDERR "$0: $warnings warnings\n" if $warnings;
 exit 0;
 
 #-------------------- configuration reading
 
 exit 0;
 
 #-------------------- configuration reading
 
-sub cfg_fail ($) { die "$0: $where:\n $_[0]\n"; }
+sub cfg_fail ($) { die "$quis: $where:\n $_[0]\n"; }
 
 sub read_config ($) {
     my ($if) = @_;
 
 sub read_config ($) {
     my ($if) = @_;
@@ -231,6 +232,8 @@ sub process_zones (@) {
        }
        zone_output() if $install;
     }
        }
        zone_output() if $install;
     }
+    print STDERR "$quis: $warnings warnings\n" or die $!
+       if $warnings;
 }
 
 sub zone_warning ($) {
 }
 
 sub zone_warning ($) {
@@ -481,17 +484,17 @@ sub lookup ($$$) {
     debug_trace("lookup ==> (->$okrcodes) $domain $type");
     $h= new IO::Handle;
 
     debug_trace("lookup ==> (->$okrcodes) $domain $type");
     $h= new IO::Handle;
 
-    defined($c= open $h, "-|") or die "$0: fork adnshost:\n $!\n";
+    defined($c= open $h, "-|") or die "$quis: fork adnshost:\n $!\n";
     if (!$c) {
        exec 'adnshost','-Fi','+Do','+Dt','+Dc','-Cf',"-t$type",
             '-',"$domain.";
     if (!$c) {
        exec 'adnshost','-Fi','+Do','+Dt','+Dc','-Cf',"-t$type",
             '-',"$domain.";
-       die "$0: exec adnshost:\n $!\n";
+       die "$quis: exec adnshost:\n $!\n";
     }
     @result= $h->getlines();
     }
     @result= $h->getlines();
-    $h->error and die "$0: read from adnshost:\n $!\n";
+    $h->error and die "$quis: read from adnshost:\n $!\n";
     chomp @result;
     $!=0; $h->close;
     chomp @result;
     $!=0; $h->close;
-    die "$0: lookup -t$type $domain $okrcodes failed $? $!\n"
+    die "$quis: lookup -t$type $domain $okrcodes failed $? $!\n"
        if $! or $?>6 or index($okrcodes,$?)<0;
     debug_trace("lookup <== $? @result");
     return ($?,@result);
        if $! or $?>6 or index($okrcodes,$?)<0;
     debug_trace("lookup <== $? @result");
     return ($?,@result);
@@ -507,18 +510,18 @@ sub dig (&$$$) {
     debug_trace("dig ==> \@$qaddr $qowner $qtype");
 
     $h= new IO::Handle;
     debug_trace("dig ==> \@$qaddr $qowner $qtype");
 
     $h= new IO::Handle;
-    defined($c= open $h, "-|") or die "$0: fork dig:\n $!\n";
+    defined($c= open $h, "-|") or die "$quis: fork dig:\n $!\n";
     if (!$c) {
        open STDERR, ">&STDOUT" or die $!;
        exec ('dig',
              '+nodef','+nosea','+nodebug','+norecurse',
              "\@$qaddr",'-t',$qtype,$qowner);
     if (!$c) {
        open STDERR, ">&STDOUT" or die $!;
        exec ('dig',
              '+nodef','+nosea','+nodebug','+norecurse',
              "\@$qaddr",'-t',$qtype,$qowner);
-       die "$0: exec dig:\n $!\n";
+       die "$quis: exec dig:\n $!\n";
     }
     $inmid='';
     for (;;) {
        if (!defined($_= $h->getline())) {
     }
     $inmid='';
     for (;;) {
        if (!defined($_= $h->getline())) {
-           $h->error() and die "$0: read from dig:\n $!\n";
+           $h->error() and die "$quis: read from dig:\n $!\n";
            last;
        }
        chomp;
            last;
        }
        chomp;
@@ -577,7 +580,7 @@ __DATA__
 sub lookup1 ($$) {
     my ($type,$domain) = @_;
     my (@result)= lookup($type,$domain);
 sub lookup1 ($$) {
     my ($type,$domain) = @_;
     my (@result)= lookup($type,$domain);
-    @result==1 or die "$0: lookup -t$type $domain gave more than one RR\n";
+    @result==1 or die "$quis: lookup -t$type $domain gave more than one RR\n";
     return $result[0];
 }
 
     return $result[0];
 }
 
@@ -626,7 +629,7 @@ sub check () {
        for $super_ns (@super_ns) {
            @deleg_ns= ();
            open DIG, "dig @$super_ns. -t ns +norecurse $zone."
        for $super_ns (@super_ns) {
            @deleg_ns= ();
            open DIG, "dig @$super_ns. -t ns +norecurse $zone."
-               or die "$0: fork for dig:\n $!\n";
+               or die "$quis: fork for dig:\n $!\n";
            while (<DIG>) {
                
 
            while (<DIG>) {
                
 
@@ -702,7 +705,7 @@ done
 endfile
 
     
 endfile
 
     
-chdir "$base/primary" or die "$0: chdir $base/primary:\n $!";
+chdir "$base/primary" or die "$quis: chdir $base/primary:\n $!";
 beginfile('primary.zones');
 
 for $f (<*_db>) {
 beginfile('primary.zones');
 
 for $f (<*_db>) {
@@ -721,19 +724,19 @@ endfile
 sub beginfile ($) {
     $currentfile= $_[0];
     $currentfile_opened= $install ? "$conf/$currentfile.new" : "/dev/null";
 sub beginfile ($) {
     $currentfile= $_[0];
     $currentfile_opened= $install ? "$conf/$currentfile.new" : "/dev/null";
-    open CFF, "> $toopen" or die "$0: begin $currentfile_opened:\n $!\n";
+    open CFF, "> $toopen" or die "$quis: begin $currentfile_opened:\n $!\n";
 }
 
 endfile () {
 }
 
 endfile () {
-    close CFF or die "$0: close $currentfile_opened:\n $!\n";
+    close CFF or die "$quis: close $currentfile_opened:\n $!\n";
     push @files, $currentfile;
 }
 
 sub installfiles () {
     return unless $install;
     push @files, $currentfile;
 }
 
 sub installfiles () {
     return unless $install;
-    chdir $conf or die "$0: chdir $conf:\n $!\n";
+    chdir $conf or die "$quis: chdir $conf:\n $!\n";
     for $f (@files) {
     for $f (@files) {
-       rename "$f.new", $f or die "$0: install new $f:\n $!\n";
+       rename "$f.new", $f or die "$quis: install new $f:\n $!\n";
     }
 }
 
     }
 }