Changeset 264
- Timestamp:
- 03/05/12 18:05:39 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r262 r264 1260 1260 local $dbh->{RaiseError} = 1; 1261 1261 1262 #$dbh->selectrow_array("SELECT currval('users_user_id_seq')"); 1262 my $warnstr = ''; 1263 1263 1264 # Wrap all the SQL in a transaction 1264 1265 eval { … … 1268 1269 # get the ID... 1269 1270 ($rdns_id) = $dbh->selectrow_array("SELECT currval('revzones_rdns_id_seq')"); 1271 #$dbh->selectrow_array("SELECT currval('users_user_id_seq')"); 1270 1272 1271 1273 _log($dbh, (rdns_id => $rdns_id, user_id => $userinfo{id}, group_id => $group, username => $userinfo{name}, … … 1278 1280 $sth->execute($group); 1279 1281 while (my ($host,$type,$val,$ttl) = $sth->fetchrow_array()) { 1282 # Silently skip v4/v6 mismatches. This is not an error, this is expected. 1283 if ($zone->{isv6}) { 1284 next if ($type == 65280 || $type == 65283); 1285 } else { 1286 next if ($type == 65281 || $type == 65284); 1287 } 1280 1288 $host =~ s/ADMINDOMAIN/$config{domain}/g; 1289 1290 ## tmp 1291 sub _ZONE { 1292 my $zone = shift; 1293 my $string = shift; 1294 my $t1 = shift; # flag for IP/network or hostname 1295 my $t2 = shift || 'f'; # flag for forward/reverse order? nb: ignored for IP 1296 1297 my $prefix = $zone->network->addr; # Just In Case someone managed to slip in 1298 # a funky subnet that had host bits set. 1299 $prefix =~ s/(:0)+$/::/; 1300 $prefix =~ s/0$//; 1301 1302 if ($t1 eq 'net') { 1303 $string =~ s/ZONE[:.]+/$prefix/; 1304 } else { 1305 $prefix =~ s/[:.]+$//; 1306 if ($t2 eq 'f') { 1307 $prefix =~ s/[:.]+/-/g; 1308 } else { 1309 $prefix = join('-', reverse(split(/[:.]/, $prefix))); 1310 } 1311 $string =~ s/ZONE/$prefix/; 1312 } 1313 return $string; 1314 } 1315 ## tmp 1316 1317 # Check the zone; if it's v4 and smaller than a /24 (sub-octet), we need 1318 # to check any template IPs to make sure they're in range. 1319 ##fixme: need similar check on v6, except we'll just grump at non-nibble boundaries 1320 # first-pass: masklen must be divisible by 4 1321 if (!$zone->{isv6} && $zone->masklen > 24) { 1322 my $net = $zone->network->addr; 1323 my $bc = $zone->broadcast; 1324 $net =~ s/^\d+\.\d+\.\d+\.//; 1325 $bc =~ s/^\d+\.\d+\.\d+\.//; 1326 my $tmp = $host; 1327 $tmp =~ s/^ZONE\.//; 1328 if ($net <= $tmp && $tmp <= $bc) { 1329 # replace ZONE with actual netblock in IP/value 1330 unless (my $tmpval = _ZONE($zone, $val, 'net')) { 1331 $warnstr .= "$val does not fit in $zone; skipping\n"; 1332 next; 1333 } 1334 } else { 1335 $warnstr .= "Default record '$val $typemap{$type} $host' doesn't fit in $zone, skipping\n"; 1336 } 1337 } 1338 1281 1339 ##work 1282 1340 # - replace ZONE in $val 1283 # - skip records not appropriate for the zone (skip A+PTR on v6 zones, and AAAA+PTR on v4 zones)1284 1341 # $val =~ s/DOMAIN/$domain/g; 1342 1285 1343 $sth_in->execute($host,$type,$val,$ttl); 1286 1344 if ($typemap{$type} eq 'SOA') { … … 1300 1358 } 1301 1359 } 1360 1361 # If there are warnings (presumably about default records skipped for cause) log them 1362 _log($dbh, (rdns_id => $rdns_id, user_id => $userinfo{id}, group_id => $group, 1363 username => $userinfo{name}, entry => $warnstr)) 1364 if $warnstr; 1302 1365 1303 1366 # once we get here, we should have suceeded.
Note:
See TracChangeset
for help on using the changeset viewer.