From 5812c849817258ecde6763c216e952d40d261c1d Mon Sep 17 00:00:00 2001 From: ianmdlvl Date: Sun, 26 May 2002 18:50:23 +0000 Subject: [PATCH] no syntax errs --- scripts/named-conf | 47 +++++++++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/scripts/named-conf b/scripts/named-conf index bc355be..1520fd8 100755 --- a/scripts/named-conf +++ b/scripts/named-conf @@ -4,12 +4,13 @@ use strict; use IO::File; use Data::Dumper; use POSIX; -use Fcntl; +use Fcntl qw(:DEFAULT :flock); use vars qw($quis $mode $doall $domail $etcfile $where $debug $needglue $localonly $repeat $verbosity + $admin $mail_state_dir $mail_max_warnfreq $progress_fh $warn_fh $modifiers %group2modcmd %group2used); @@ -239,7 +240,7 @@ sub read_config ($) { $admin=$1; } elsif (m/^mail\-state\-dir\s+(\S+)$/) { $mail_state_dir= $1; - } elsif (m/^mail\-max\-warnfreq\s+(\d{1,3}(?:\.\d{0,5})?+)$/) { + } elsif (m/^mail\-max\-warnfreq\s+(\d{1,3}(?:\.\d{0,5})?)$/) { cfg_fail("mail-max-warnfreq must be <=100") if $1>100; $mail_max_warnfreq= $1; } else { @@ -249,7 +250,7 @@ sub read_config ($) { } } foreach $group (keys %group2modcmd) { - next if exists $group2used{$group); + next if exists $group2used{$group}; cfg_fail("command line specifies modifier group $group". " but missing in configuration file"); } @@ -296,7 +297,7 @@ sub zone_conf ($$$$$@) { # followed by modifiers, first per-zone, then default $zone_cfg{$zone}{'servers'}= [ @servers ]; if ($domail) { - length $admin_email && length $mail_state_dir or + length $admin && length $mail_state_dir or cfg_fail("mailing but failed to specify admin". " or mail-state-dir before zone"); $zone_cfg{$zone}{'admin'}= $admin; @@ -349,7 +350,7 @@ sub process_zones (@) { mail_zone_before() if $domail; zone_reset(); progress(1, sprintf "%-20s %s", $zone, $$cfg{'style_p'}); - if ($check && ($doall || !zone_style('?',0)) { + if ($check && ($doall || !zone_style('?',0))) { eval { if ($localonly && $cfg->{'s'} =~ m/f/) { zone_warning("foreign zone specified with -l",''); @@ -684,22 +685,24 @@ sub zone_style ($$) { #-------------------- mailing use vars qw($m_base $m_lastok @m_ok @m_fail - $m_info $m_time); + $m_info $m_time $m_lock $m_m); sub mail_zone_before () { + my (@s1,@s2); + $m_base= $$cfg{'maildir'}.'/'.$zone; $m_lastok= '-'; @m_ok= (); @m_fail= (); for (;;) { - $m_lock= IO::File "${m_base}_lock", O_RDWR|O_CREAT, 0600 + $m_lock= new IO::File "${m_base}_lock", O_RDWR|O_CREAT, 0600 or die "$quis: create lockfile ${m_base}_lock"; if (!flock($m_lock, LOCK_EX|LOCK_NB)) { <$m_lock> =~ m/^\d+ /; die "$quis: $zone: concurrrency? - flock $&$!\n"; $m_lock->close; - continue; + next; } (@s1= $m_lock->fstat) or die "$quis: fstat ${m_base}_lock: $!\n"; (@s2= stat "${m_base}_lock") or @@ -707,11 +710,11 @@ sub mail_zone_before () { last if ($s1[0] eq $s2[0] && $s1[1] eq $s2[1]); $m_lock->close; } - print $m_lock "$$ \n" or $m_lock->flush - die "$quis: write pid to ${m_base}_lock: $!\n"; + (print $m_lock "$$ \n" and $m_lock->flush) + or die "$quis: write pid to ${m_base}_lock: $!\n"; - if ($m_info= IO::File "${m_base}_info", 'r') { - $!=0; $_= ; + if ($m_info= new IO::File "${m_base}_info", 'r') { + $!=0; $_= <$m_info>; $_ =~ m/\n/ or die "$quis: read ${m_base}_info: $!\n"; m/^\d+ (\d+|-) ([0-9:]*) ([0-9:]*) / or die "$quis: ${m_base}_info malformed\n"; @@ -758,9 +761,9 @@ sub mail_zone_after () { $progress_fh= $warn_fh= 'STDERR'; if ($domail eq 'final') { - if (100*@m_fail <= $$cfg{'mailmwarn'}*(@m_mail + @m_ok)) { + if (100*@m_fail <= $$cfg{'mailmwarn'}*(@m_fail + @m_ok)) { printf " %-40s ok\n" or die "$quis: mail ok report: $!\n"; - } elsif (zone_style('@',0)) ) { + } elsif (zone_style('@',0)) { printf " %-40s mail suppressed\n" or die "$quis: mail suppress report: $!\n"; } else { @@ -781,12 +784,18 @@ sub mail_zone_after () { } -sub pmail ($) { print $m_m $_[0] or die "$quis: write ${m_base}_mail: $!\n"; } -sub ptime ($) { my ($time)=@_; return gmtime($time)." GMT ($time)"; } +sub pmail ($) { + print $m_m $_[0] + or die "$quis: write ${m_base}_mail: $!\n"; +} +sub ptime ($) { + my ($time) = @_; + return gmtime($time)." GMT ($time)"; +} sub mail_zone_mail () { - my ($log, $zone_to, $zterr, $c, $r); - $m_m= new IO::File, "${m_base}_mail", 'w', 0666 + my ($log, $zone_to, $zterr, $c, $r, $t); + $m_m= new IO::File "${m_base}_mail", 'w', 0666 or die "$quis: create ${m_base}_mail: $!\n"; $zone_to=''; $zterr=''; if (!zone_style("\$",$$cfg{'s'} =~ m/u/)) { @@ -798,7 +807,7 @@ sub mail_zone_mail () { $zone_to= $1; }; $zterr= $@; - $zterr =~ s/\n$/; + $zterr =~ s/\n$//; } pmail < -- 2.30.2