From 0b8f6e1e6251758ccdcc9bcf102a67a9e39dd54a Mon Sep 17 00:00:00 2001 From: Sergey Poznyakoff Date: Sat, 24 Aug 2019 22:35:19 +0300 Subject: Fix the mess with logical conjunction and disjunction --- axfr2acl/axfr2acl | 6 +++--- dnsdbck/dnsdbck | 26 +++++++++++++------------- nsdbimport/nsdbimport | 16 ++++++++-------- rpsl2acl/rpsl2acl | 4 ++-- vhostcname/vhostcname | 22 +++++++++++----------- whoseip/Whoseip/DB.pm | 8 ++++---- whoseip/whoseip.pl | 18 +++++++++--------- 7 files changed, 50 insertions(+), 50 deletions(-) diff --git a/axfr2acl/axfr2acl b/axfr2acl/axfr2acl index 19e4f24..d9fe1a5 100755 --- a/axfr2acl/axfr2acl +++ b/axfr2acl/axfr2acl @@ -64,7 +64,7 @@ sub logit { } sub loginit { - if ($logfile and (!-e $logfile or -w $logfile)) { + if ($logfile && (!-e $logfile || -w $logfile)) { print STDERR "$script: logging to $logfile\n"; open(LOG, ">$logfile"); } else { @@ -272,7 +272,7 @@ foreach my $zone (@zones) { $serial{$zone} = $rr->serial; } -if ($update and keys(%oldserial)) { +if ($update && keys(%oldserial)) { debug('GENERAL', 1, "some zones removed: forcing update"); $need_update = 1; } @@ -325,7 +325,7 @@ if ($update) { delete $oldset{$net}; } } - unless ($update or keys(%oldset) > 0) { + unless ($update || keys(%oldset) > 0) { if ($need_update && !$dry_run) { debug('GENERAL', 1, "list unchanged; proceeding to save serials"); } else { diff --git a/dnsdbck/dnsdbck b/dnsdbck/dnsdbck index 16fb4c4..aa2e558 100755 --- a/dnsdbck/dnsdbck +++ b/dnsdbck/dnsdbck @@ -77,7 +77,7 @@ sub logit { } sub loginit { - if ($logfile and (!-e $logfile or -w $logfile)) { + if ($logfile && (!-e $logfile || -w $logfile)) { print STDERR "$script: logging to $logfile\n"; open(LOG, ">$logfile"); } else { @@ -241,8 +241,8 @@ sub check_zone_ns($) { } } else { debug('DNS', 1, "query failed: ", $resolver->errorstring); - return 2 if (($resolver->errorstring eq "NXDOMAIN") or - ($resolver->errorstring eq "NOERROR")); + return 2 if (($resolver->errorstring eq "NXDOMAIN") + || ($resolver->errorstring eq "NOERROR")); return -1; } debug('DNS', 1, "$zone: not ours"); @@ -262,9 +262,9 @@ sub check_host_name($$) { ($s = $rr->rdatastr) =~ s/\.$//; return 1 if ($s eq $name); return 2 if ((length($s) > length($name) - and substr($s, - (length($name) + 1)) eq ".$name") or - (length($name) > length($s) - and substr($name, - (length($s) + 1)) eq ".$s")) + && substr($s, - (length($name) + 1)) eq ".$name") + || (length($name) > length($s) + && substr($name, - (length($s) + 1)) eq ".$s")) } } else { debug('DNS', 1, "query failed: ", $resolver->errorstring); @@ -392,7 +392,7 @@ if ($username) { setgid($gid); setuid($uid); die("cannot switch to $username privileges") - unless ($< == $uid and $( == $gid); + unless ($< == $uid && $( == $gid); $home = $dir; } @@ -401,7 +401,7 @@ unless (defined($author)) { $author = $login; } -if ($#ARGV == -1 and !$all_zones) { +if ($#ARGV == -1 && !$all_zones) { print STDERR "$script: no zones specified, try `$script --help' for more info\n"; exit(1); } @@ -483,7 +483,7 @@ while (my ($key, $value) = each(%reverse_zone)) { next if ($ignored_zone{$key}); unless (has_soa($key)) { - if (private_network($key) and create_soa_allowed($key)) { + if (private_network($key) && create_soa_allowed($key)) { debug('GENERAL', 1, "creating SOA/NS for $key"); my $query = build_soa($key, 'internal'); print $sqlfile "$query"; @@ -530,9 +530,9 @@ while (my ($key, $value) = each(%reverse_zone)) { my $fullkey = $row{'host'}.".".$key; my $revhost; ($revhost = $row{'data'}) =~ s/\.$//; - next if ($ignored_host{$revhost} or - $ignored_zone{$revhost} or - $ignored_host{$fullkey}); + next if ($ignored_host{$revhost} + || $ignored_zone{$revhost} + || $ignored_host{$fullkey}); debug('MISSING', 1, $row{'serial'}.": $fullkey => " .$row{'data'} @@ -544,7 +544,7 @@ while (my ($key, $value) = each(%reverse_zone)) { $dir =~ s/\.$//; next if ($ignored_zone{$dir}); - unless (has_soa($revhost) or has_soa($dir)) { + unless (has_soa($revhost) || has_soa($dir)) { my $msg = $row{'serial'} .": $fullkey => " .$row{'data'} diff --git a/nsdbimport/nsdbimport b/nsdbimport/nsdbimport index 8b8fcca..49b1c11 100755 --- a/nsdbimport/nsdbimport +++ b/nsdbimport/nsdbimport @@ -64,7 +64,7 @@ sub abend { } END { - if ($record_count and ($verbose or $?)) { + if ($record_count && ($verbose || $?)) { print "$progname: $record_count records processed successfully\n"; } } @@ -146,7 +146,7 @@ sub istrue { sub parse_named_conf { my %zone; abend(EX_OSFILE, "$bind_config doesn't exist or is unreadable") - unless -f $bind_config and -r $bind_config; + unless -f $bind_config && -r $bind_config; open(my $fd, '-|', "cfpeek --parser=bind $bind_config") or die "can't run cfpeek: $!"; @@ -160,7 +160,7 @@ sub parse_named_conf { close $fd; my %files; while (my ($name, $ref) = each %zone) { - if ($ref->{type} eq 'master' and defined($ref->{file})) { + if ($ref->{type} eq 'master' && defined($ref->{file})) { debug(1, "register zone $name, file $ref->{file}"); $files{$ref->{file}} = $name; } @@ -197,10 +197,10 @@ sub replvar { } if ($val ne '') { - if ($val eq '@' and defined($opt->{'@'})) { + if ($val eq '@' && defined($opt->{'@'})) { $val = $opt->{'@'} || $rec->{origin}; $val .= '.' unless $val =~ /\.$/; - } elsif (defined($opt->{'.'}) and $val !~ /\.$/) { + } elsif (defined($opt->{'.'}) && $val !~ /\.$/) { $val .= '.' . ($opt->{'.'} || $rec->{origin}); $val .= '.' unless $val =~ /\.$/; } @@ -360,7 +360,7 @@ sub import_record { my $rec = shift; my $kw = lc($rec->{rr}).'-query'; - if (defined($rrfun{$rec->{rr}}) and defined($config{$kw})) { + if (defined($rrfun{$rec->{rr}}) && defined($config{$kw})) { &{$rrfun{$rec->{rr}}}($rec, $config{$kw}); } else { insert_rr($rec, $config{$kw}); @@ -371,7 +371,7 @@ sub zimport { my ($file, $origin) = @_; $file = "$bind_directory/$file" - if $file !~ m#^/# and defined($bind_directory); + if $file !~ m#^/# && defined($bind_directory); debug(1, "processing file $file, origin $origin"); open(my $fd, "<", $file) or abend(EX_NOINPUT, "can't open input file $file: $!"); @@ -491,7 +491,7 @@ $arg .= ":;mysql_read_default_file=$config{'db-default-file'}" if defined $config{'db-default-file'}; if (!$arg - or (!defined($config{user}) and !defined($config{'db-default-file'}))) { + || (!defined($config{user}) && !defined($config{'db-default-file'}))) { my $my_cnf = "$ENV{HOME}/.my.cnf"; if (-r $my_cnf) { debug(1, "using mysql option file $my_cnf"); diff --git a/rpsl2acl/rpsl2acl b/rpsl2acl/rpsl2acl index daeec78..b6180b4 100755 --- a/rpsl2acl/rpsl2acl +++ b/rpsl2acl/rpsl2acl @@ -51,7 +51,7 @@ sub logit { } sub loginit { - if ($logfile and (!-e $logfile or -w $logfile)) { + if ($logfile && (!-e $logfile || -w $logfile)) { print STDERR "$script: logging to $logfile\n"; open(LOG, ">$logfile"); } else { @@ -295,7 +295,7 @@ if ($update) { delete $oldset{$net}; } } - unless ($update or keys(%oldset) > 0) { + unless ($update || keys(%oldset) > 0) { debug('GENERAL', 1, "shutdown: list unchanged"); logdone(); exit(1); diff --git a/vhostcname/vhostcname b/vhostcname/vhostcname index 78d0a4c..4b6b701 100755 --- a/vhostcname/vhostcname +++ b/vhostcname/vhostcname @@ -108,8 +108,8 @@ sub check_mandatory { my $err = 0; while (my ($k, $d) = each %{$kw}) { if (ref($d) eq 'HASH' - and $d->{mandatory} - and !exists($section->{$k})) { + && $d->{mandatory} + && !exists($section->{$k})) { if (exists($d->{section})) { if ($s) { err("$loc: mandatory section [$k] not present"); @@ -170,7 +170,7 @@ sub readconfig { if (ref($param{kw}) eq 'HASH') { if (defined($rootname)) { if (ref($param{kw}{$rootname}) eq 'HASH' - and exists($param{kw}{$rootname}{section})) { + && exists($param{kw}{$rootname}{section})) { $kw = $param{kw}{$rootname}{section}; } else { err("$file:$line: unknown section"); @@ -216,7 +216,7 @@ sub readconfig { next; } if (exists($x->{check}) - and !&{$x->{check}}($k, $v, "$file:$line")) { + && !&{$x->{check}}($k, $v, "$file:$line")) { ++$err; next; } @@ -225,9 +225,9 @@ sub readconfig { ++$err; next; } - } elsif (!exists($x->{var}) and - !exists($x->{parser}) and - !exists($x->{mandatory})) { + } elsif (!exists($x->{var}) + && !exists($x->{parser}) + && !exists($x->{mandatory})) { err("$file:$line: unknown keyword $k"); ++$err; next; @@ -261,7 +261,7 @@ sub valid_domain_name { foreach my $label (split(/\./, $name)) { $label =~ s/-+/-/g; $label =~ s/[a-zA-Z0-9]-[a-zA-Z0-9]//g; - return 0 if $label =~ /^-/ or $label =~ /-$/; + return 0 if $label =~ /^-/ || $label =~ /-$/; return 0 if $label =~ /[^a-zA-Z0-9]/; } return 1; @@ -293,7 +293,7 @@ sub get_cnames($) { } foreach my $z (keys %{$config{zone}}) { if ($name =~ /.*\.$z$/) { - if ($name =~ /^\*\.(.+)/ and $1 eq $z) { + if ($name =~ /^\*\.(.+)/ && $1 eq $z) { err("$file:$line: $name: first-level wildcard"); next; } @@ -596,7 +596,7 @@ my %comtab = ( sub getcom { my $com = shift; - while (exists($comtab{$com}) and ref($comtab{$com}) ne 'CODE') { + while (exists($comtab{$com}) && ref($comtab{$com}) ne 'CODE') { die "internal error: unresolved command alias" unless exists $comtab{$com}; $com = $comtab{$com}; @@ -696,7 +696,7 @@ readconfig($config_file, \%config, kw => \%kw); unless (exists($config{core}{'apache-config-directory'})) { foreach my $dir ("/etc/apache2", "/etc/httpd") { - if (-e "$dir/sites-enabled" and -e "$dir/sites-available") { + if (-e "$dir/sites-enabled" && -e "$dir/sites-available") { $config{core}{'apache-config-directory'} = $dir; last; } diff --git a/whoseip/Whoseip/DB.pm b/whoseip/Whoseip/DB.pm index 4a63aff..cecb070 100644 --- a/whoseip/Whoseip/DB.pm +++ b/whoseip/Whoseip/DB.pm @@ -248,7 +248,7 @@ sub ipdb_open { croak "$filename is not a valid IP cache file" unless $sign eq $dbsign; croak "$filename is of wrong version ($maj.$min, expected $vmajor.$vminor)" - unless ($maj == $vmajor and $min == $vminor); + unless ($maj == $vmajor && $min == $vminor); croak "$filename: page size too small ($size)" if ($size < 1032); $ipdbfile{uuid} = $uuid; @@ -343,7 +343,7 @@ sub ipdb_locker { return 1 if $mode == LOCK_UN; } - return 1 if (defined($_{sync} and $_{sync} == 0)); + return 1 if (defined($_{sync} && $_{sync} == 0)); if (sysseek($dbf->{fd}, 0, SEEK_SET) != 0) { croak "$dbf->{filename}: can't seek: $!"; @@ -764,7 +764,7 @@ sub ipdb_lookup_unlocked($$) { if (($ipn & $r->[1]) == $r->[0]) { print STDERR "ipdb_lookup: MATCH $r->[3]\n" if $dbf->{debug}; - if (defined($dbf->{ttl}) and + if (defined($dbf->{ttl}) && (time - $r->[2]) > $dbf->{ttl}) { print STDERR "ipdb_lookup: record expired, removing\n" if $dbf->{debug}; @@ -781,7 +781,7 @@ sub ipdb_lookup_unlocked($$) { $res{ttl} = $dbf->{ttl} - (time - $r->[2]) if (defined($dbf->{ttl})); @res{keys %{$r->[4]}} = values %{$r->[4]} - if (defined($r->[4]) and ref($r->[4]) eq 'HASH'); + if (defined($r->[4]) && ref($r->[4]) eq 'HASH'); return %res; } ++$i; diff --git a/whoseip/whoseip.pl b/whoseip/whoseip.pl index 225a159..fe41ae0 100644 --- a/whoseip/whoseip.pl +++ b/whoseip/whoseip.pl @@ -183,19 +183,19 @@ sub arin_fmt { sub arin_decode { my ($input, $ref) = @_; - return if ($input =~ /^#/ or $input eq ''); + return if ($input =~ /^#/ || $input eq ''); if ($input =~ /^NetRange:\s+(.+)/) { my $r = $1; $r =~ s/\s+//g; my $n = range2count($r); - if (!defined($ref->{count}) or $ref->{count} > $n) { + if (!defined($ref->{count}) || $ref->{count} > $n) { $ref->{range} = $r; $ref->{cidr} = join ',', Net::CIDR::range2cidr($r); $ref->{count} = $n; delete $ref->{country} } - } elsif ($input =~ /^Country:\s+(.+)/ and !defined($ref->{country})) { + } elsif ($input =~ /^Country:\s+(.+)/ && !defined($ref->{country})) { $ref->{country} = $1; } } @@ -308,7 +308,7 @@ sub ntt_decode { my $r = $1; $r =~ s/\s+//g; my $c = range2count($r); - if (!defined($ref->{count}) or $ref->{count} > $c) { + if (!defined($ref->{count}) || $ref->{count} > $c) { $ref->{count} = $c; $ref->{range} = $r; $ref->{cidr} = join ',', Net::CIDR::range2cidr($r); @@ -359,7 +359,7 @@ sub nic_or_kr_decode { my $r = $1; $r =~ s/\s+//g; my $c = range2count($r); - if (!defined($ref->{count}) or $ref->{count} > $c) { + if (!defined($ref->{count}) || $ref->{count} > $c) { $ref->{count} = $c; $ref->{range} = $r; $ref->{cidr} = join ',', Net::CIDR::range2cidr($r); @@ -493,15 +493,15 @@ sub serve { } my $srv = findsrv($term); - if (defined($srv) and $srv ne 'UNKNOWN') { + if (defined($srv) && $srv ne 'UNKNOWN') { my %prev; while (%res = whois($term, $srv), - and defined($res{referto})) { + && defined($res{referto})) { %prev = %res if $res{status} = 'OK'; $srv = $res{referto}; } %res = %prev - if (!defined($res{country}) and defined($prev{country})); + if (!defined($res{country}) && defined($prev{country})); if (!defined($res{country})) { $res{status} = 'NO'; $res{diag} = 'IP unknown'; @@ -804,7 +804,7 @@ if (defined($fastcgi)) { $fastcgi = $0 =~ /\.fcgi$/; } -if (defined($output_format) and $output_format =~ /@(.+)/) { +if (defined($output_format) && $output_format =~ /@(.+)/) { abend(EX_USAGE, "format $1 not defined") unless defined $fmtab{$1}; $output_format = $fmtab{$1}; } -- cgit v1.2.1