Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r265 r269 1352 1352 # get the ID... 1353 1353 ($rdns_id) = $dbh->selectrow_array("SELECT currval('revzones_rdns_id_seq')"); 1354 #$dbh->selectrow_array("SELECT currval('users_user_id_seq')");1355 1354 1356 1355 _log($dbh, (rdns_id => $rdns_id, user_id => $userinfo{id}, group_id => $group, username => $userinfo{name}, … … 1359 1358 # ... and now we construct the standard records from the default set. NB: group should be variable. 1360 1359 my $sth = $dbh->prepare("SELECT host,type,val,ttl FROM default_rev_records WHERE group_id=?"); 1361 my $sth_in = $dbh->prepare("INSERT INTO records (rdns_id, host,type,val,ttl)".1362 " VALUES ($rdns_id,?,?,?,? )");1360 my $sth_in = $dbh->prepare("INSERT INTO records (rdns_id,domain_id,host,type,val,ttl)". 1361 " VALUES ($rdns_id,?,?,?,?,?)"); 1363 1362 $sth->execute($group); 1364 1363 while (my ($host,$type,$val,$ttl) = $sth->fetchrow_array()) { … … 1369 1368 next if ($type == 65281 || $type == 65284); 1370 1369 } 1370 1371 1371 $host =~ s/ADMINDOMAIN/$config{domain}/g; 1372 1372 … … 1375 1375 # While we're at it, we substitute $zone for ZONE in the value. 1376 1376 if ($val eq 'ZONE') { 1377 ##fixme? do we care if we have multiple whole-zone templates? 1377 1378 $val = $zone->network; 1378 1379 } elsif ($val =~ /ZONE/) { 1379 1380 my $tmpval = $val; 1380 1381 $tmpval =~ s/ZONE//; 1382 # Bend the rules and allow single-trailing-number PTR or PTR template records to be inserted 1383 # as either v4 or v6. May make this an off-by-default config flag 1384 # Note that the origin records that may trigger this **SHOULD** already have ZONE,\d 1385 if ($type == 12 || $type == 65282) { 1386 $tmpval =~ s/[,.]/::/ if ($tmpval =~ /^[,.]\d+$/ && $zone->{isv6}); 1387 $tmpval =~ s/[,:]+/./ if ($tmpval =~ /^(?:,|::)\d+$/ && !$zone->{isv6}); 1388 } 1381 1389 my $addr; 1382 1390 if (_ipparent($dbh, 'n', 'y', \$tmpval, $rdns_id, \$addr)) { 1383 1391 $val = $addr->addr; 1384 1392 } else { 1385 $warnstr .= " Default record '$val $typemap{$type} $host' doesn't fit in $zone, skipping\n";1393 $warnstr .= "\nDefault record '$val $typemap{$type} $host' doesn't fit in $zone, skipping"; 1386 1394 next; 1387 1395 } … … 1391 1399 $host = _ZONE($zone, $host); 1392 1400 1393 ##work 1394 $sth_in->execute($host,$type,$val,$ttl); 1401 # Fill in the forward domain ID if we can find it, otherwise: 1402 # Coerce type down to PTR or PTR template if we can't 1403 my $domid = 0; 1404 if ($type >= 65280) { 1405 if (!($domid = _hostparent($dbh, $host))) { 1406 $warnstr .= "\nRecord added as PTR instead of $typemap{$type}; domain not found for $host"; 1407 $type = $reverse_typemap{PTR}; 1408 $domid = 0; # just to be explicit. 1409 } 1410 } 1411 1412 $sth_in->execute($domid,$host,$type,$val,$ttl); 1413 1395 1414 if ($typemap{$type} eq 'SOA') { 1396 1415 my @tmp1 = split /:/, $host; … … 1402 1421 } else { 1403 1422 my $logentry = "[new $zone] Added record '$host $typemap{$type}"; 1404 # $logentry .= " [distance $dist]" if $typemap{$type} eq 'MX'; 1405 # $logentry .= " [priority $dist] [weight $weight] [port $port]" if $typemap{$type} eq 'SRV'; 1406 _log($dbh, (rdns_id => $rdns_id, user_id => $userinfo{id}, group_id => $group, 1423 _log($dbh, (rdns_id => $rdns_id, domain_id => $domid, user_id => $userinfo{id}, group_id => $group, 1407 1424 username => $userinfo{name}, entry => 1408 1425 $logentry." $val', TTL $ttl")); 1409 #print $logentry." $val', TTL $ttl\n";1410 1426 } 1411 1427 } 1428 1429 # Generate record based on provided pattern. 1430 my $addr; 1431 if (_ipparent($dbh, 'n', 'y', \$tmpval, $rdns_id, \$addr)) { 1432 $val = $addr->addr; 1433 } else { 1434 $warnstr .= "\nDefault record '$val $typemap{$type} $host' doesn't fit in $zone, skipping"; 1435 next; 1436 } 1412 1437 1413 1438 # If there are warnings (presumably about default records skipped for cause) log them 1414 1439 _log($dbh, (rdns_id => $rdns_id, user_id => $userinfo{id}, group_id => $group, 1415 username => $userinfo{name}, entry => $warnstr))1440 username => $userinfo{name}, entry => "Warning(s) adding $zone:$warnstr")) 1416 1441 if $warnstr; 1417 #print $warnstr; 1442 1418 1443 # once we get here, we should have suceeded. 1419 #die "horribly\n";1420 1444 $dbh->commit; 1421 1445 }; # end eval -
trunk/dns.cgi
r268 r269 445 445 fill_grouplist("grouplist"); 446 446 447 # prepopulate revpatt with the matching default record 448 # getRecByName($dbh, (revrec => $webvar{revrec}, defrec => $webvar{defrec}, host => 'string')); 449 447 450 if ($webvar{add_failed}) { 448 451 $page->param(add_failed => 1); … … 472 475 } else { 473 476 logaction(0, $session->param("username"), $webvar{group}, "Failed adding reverse zone $webvar{revzone} ($msg)"); 474 changepage(page => "newrevzone", add_failed => 1, revzone => $webvar{revzone}, revpatt => $webvar{revpatt},475 477 changepage(page => "newrevzone", revrec => 'y', add_failed => 1, revzone => $webvar{revzone}, 478 revpatt => $webvar{revpatt}, errmsg => $msg); 476 479 } 477 480 -
trunk/notes
r81 r269 309 309 #define LOG_INFO 6 /* informational */ 310 310 #define LOG_DEBUG 7 /* debug-level messages */ 311 312 313 314 another web-UI for DNS record maintenance: 315 http://www.henriknordstrom.net/code/webdns/ 316 317 318 sub-octet delegation for v4 nets: 319 p 216-218 in cricket book
Note:
See TracChangeset
for help on using the changeset viewer.