Changeset 834
- Timestamp:
- 04/19/22 16:34:34 (3 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r833 r834 1798 1798 my $tmpl = shift; 1799 1799 my $ip = shift; 1800 my $subnet = shift; # for %ngb and %c1800 my $subnet = shift; # %ngb, %c, and %x 1801 1801 my $ipindex = shift; # for %c 1802 1802 … … 1842 1842 1843 1843 if ($cn) { 1844 # "natural n'th IP in the block" pattern 1845 $$tmpl =~ s/$cn/$ipindex+1/e; 1844 # "n'th natural IP in the block" pattern. 1845 my $iptmp = new NetAddr::IP $ip; 1846 my $natdex = scalar($iptmp - $$subnet); 1847 $natdex++; 1848 $$tmpl =~ s/$cn/$natdex/; 1846 1849 } 1847 1850 -
trunk/compact-recs.pl
r797 r834 4 4 ## 5 5 # $Id$ 6 # Copyright 2013 ,2014,2018,2020Kris Deugau <kdeugau@deepnet.cx>6 # Copyright 2013-2022 Kris Deugau <kdeugau@deepnet.cx> 7 7 # 8 8 # This program is free software: you can redistribute it and/or modify … … 23 23 use warnings; 24 24 25 # push "the directory the script is in" into @INC 26 use FindBin; 27 use lib "$FindBin::RealBin/"; 25 # Taint-safe (ish) voodoo to push "the directory the script is in" into @INC. 26 # See https://secure.deepnet.cx/trac/dnsadmin/ticket/80 for more gory details on how we got here. 27 use File::Spec (); 28 use File::Basename (); 29 my $path; 30 BEGIN { 31 $path = File::Basename::dirname(File::Spec->rel2abs($0)); 32 if ($path =~ /(.*)/) { 33 $path = $1; 34 } 35 } 36 use lib $path; 28 37 29 38 use DNSDB; … … 85 94 $dbh->{RaiseError} = 1; 86 95 87 my ($zone ,$ploc) = $dbh->selectrow_array("SELECTrdns_id,default_location FROM revzones WHERE revnet >>= ?",96 my ($zonecidr,$zone,$ploc) = $dbh->selectrow_array("SELECT revnet,rdns_id,default_location FROM revzones WHERE revnet >>= ?", 88 97 undef, ($cidr) ); 89 98 if (!$zone) { … … 106 115 107 116 eval { 117 # First, clean up the records that match the template. 108 118 my $getsth = $dbh->prepare("SELECT record_id,host,val FROM records ". 109 "WHERE (type = 12 OR type > 65000) AND inetlazy(val) << ? ");119 "WHERE (type = 12 OR type > 65000) AND inetlazy(val) << ? AND rdns_id = ?"); 110 120 my $delsth = $dbh->prepare("DELETE FROM records WHERE record_id = ?"); 111 $getsth->execute($cidr );121 $getsth->execute($cidr, $zone); 112 122 my $i = 0; 113 123 while (my ($id,$host,$val) = $getsth->fetchrow_array) { 114 124 my $cmp = $patt; 115 DNSDB::_template4_expand(\$cmp, $val );125 DNSDB::_template4_expand(\$cmp, $val, \$cidr); 116 126 $delsth->execute($id) if $cmp eq $host; 117 127 $delcnt++ if $cmp eq $host; 118 # print "got $id, '$host', '$val'; compare '$cmp'\t";119 # print " delete\n" if $cmp eq $host;120 # print " keep\n" if $cmp ne $host;121 # last if $i++ >8;122 128 } 123 129 … … 129 135 entry => "A+PTR and/or PTR records in $cidr matching $patt replaced by $typemap{$newtype} record for $cidr"); 130 136 131 # $dbh->rollback;132 137 $dbh->commit; 133 138 };
Note:
See TracChangeset
for help on using the changeset viewer.