Changeset 286
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r285 r286 1327 1327 my $msg = $@; 1328 1328 eval { $dbh->rollback; }; 1329 _log($dbh, ( domain_id => $dom_id,group_id => $group, entry => "Failed adding domain $domain ($msg)"))1329 _log($dbh, (group_id => $group, entry => "Failed adding domain $domain ($msg)")) 1330 1330 if $config{log_failures}; 1331 1331 $dbh->commit; # since we enabled transactions earlier … … 1470 1470 ## DNSDB::addRDNS 1471 1471 # Adds a reverse DNS zone 1472 # Takes a database handle, CIDR block, numeric group, boolean(ish) state (active/inactive),1473 # and user info hash (for logging).1472 # Takes a database handle, CIDR block, reverse DNS pattern, numeric group, 1473 # and boolean(ish) state (active/inactive) 1474 1474 # Returns a status code and message 1475 1475 sub addRDNS { … … 1481 1481 my $state = shift; 1482 1482 1483 my %userinfo = @_; # remaining bits.1484 # user ID, username, user full name1485 1486 1483 $state = 1 if $state =~ /^active$/; 1487 1484 $state = 1 if $state =~ /^on$/; … … 1513 1510 ($rdns_id) = $dbh->selectrow_array("SELECT currval('revzones_rdns_id_seq')"); 1514 1511 1515 _log($dbh, (rdns_id => $rdns_id, user_id => $userinfo{id}, group_id => $group, username => $userinfo{name},1512 _log($dbh, (rdns_id => $rdns_id, group_id => $group, 1516 1513 entry => "Added ".($state ? 'active' : 'inactive')." reverse zone $zone")); 1517 1514 … … 1576 1573 my @tmp1 = split /:/, $host; 1577 1574 my @tmp2 = split /:/, $val; 1578 _log($dbh, (rdns_id => $rdns_id, user_id => $userinfo{id}, group_id => $group, 1579 username => $userinfo{name}, entry => 1580 "[new $zone] Added SOA record [contact $tmp1[0]] [master $tmp1[1]] ". 1575 _log($dbh, (rdns_id => $rdns_id, group_id => $group, 1576 entry => "[new $zone] Added SOA record [contact $tmp1[0]] [master $tmp1[1]] ". 1581 1577 "[refresh $tmp2[0]] [retry $tmp2[1]] [expire $tmp2[2]] [minttl $tmp2[3]], TTL $ttl")); 1582 1578 $defttl = $tmp2[3]; 1583 1579 } else { 1584 1580 my $logentry = "[new $zone] Added record '$host $typemap{$type}"; 1585 _log($dbh, (rdns_id => $rdns_id, domain_id => $domid, user_id => $userinfo{id}, group_id => $group, 1586 username => $userinfo{name}, entry => 1587 $logentry." $val', TTL $ttl")); 1581 _log($dbh, (rdns_id => $rdns_id, domain_id => $domid, group_id => $group, 1582 entry => $logentry." $val', TTL $ttl")); 1588 1583 } 1589 1584 } … … 1606 1601 1607 1602 $sth_in->execute($domid,$host,$type,$val,$defttl); 1603 my $logentry = "[new $zone] Added record '$host $typemap{$type}"; 1604 _log($dbh, (rdns_id => $rdns_id, domain_id => $domid, group_id => $group, 1605 entry => $logentry." $val', TTL $defttl from pattern")); 1608 1606 } 1609 1607 1610 1608 # If there are warnings (presumably about default records skipped for cause) log them 1611 _log($dbh, (rdns_id => $rdns_id, user_id => $userinfo{id}, group_id => $group, 1612 username => $userinfo{name}, entry => "Warning(s) adding $zone:$warnstr")) 1609 _log($dbh, (rdns_id => $rdns_id, group_id => $group, entry => "Warning(s) adding $zone:$warnstr")) 1613 1610 if $warnstr; 1614 1611 … … 1620 1617 my $msg = $@; 1621 1618 eval { $dbh->rollback; }; 1619 _log($dbh, (group_id => $group, entry => "Failed adding reverse zone $zone ($msg)")) 1620 if $config{log_failures}; 1621 $dbh->commit; # since we enabled transactions earlier 1622 1622 return ('FAIL',$msg); 1623 1623 } else { 1624 return ('OK',$rdns_id); 1624 my $retcode = 'OK'; 1625 if ($warnstr) { 1626 $resultstr = $warnstr; 1627 $retcode = 'WARN'; 1628 } 1629 return ($retcode, $rdns_id); 1625 1630 } 1626 1631 -
trunk/dns.cgi
r285 r286 489 489 490 490 my ($code,$msg) = addRDNS($dbh, $webvar{revzone}, $webvar{revpatt}, $webvar{group}, 491 ($webvar{makeactive} eq 'on' ? 1 : 0), 492 (username => $session->param("username"), id => $session->param("uid")) ); 491 ($webvar{makeactive} eq 'on' ? 1 : 0)); 493 492 494 493 if ($code eq 'OK') { 495 logaction(0, $session->param("username"), $webvar{group}, "Added reverse zone $webvar{revzone}", $msg);496 494 changepage(page => "reclist", id => $msg, revrec => 'y'); 495 } elsif ($code eq 'WARN') { 496 changepage(page => "reclist", id => $msg, revrec => 'y', warnmsg => $DNSDB::resultstr); 497 497 } else { 498 logaction(0, $session->param("username"), $webvar{group}, "Failed adding reverse zone $webvar{revzone} ($msg)");499 498 $session->param('add_failed', 1); 500 499 changepage(page => "newrevzone", revzone => $webvar{revzone}, revpatt => $webvar{revpatt}, errmsg => $msg); … … 602 601 showzone($webvar{defrec}, $webvar{revrec}, $webvar{id}); 603 602 if ($webvar{defrec} eq 'n') { 604 # showzone('n',$webvar{id});605 ##fixme: permission for viewing logs?606 ##fixme: determine which slice of the log we view (group, domain, revzone)607 603 if ($webvar{revrec} eq 'n') { 608 604 $page->param(logdom => 1); … … 1868 1864 foreach my $sessme ('resultmsg','warnmsg','errmsg') { 1869 1865 if (my $tmp = $params{$sessme}) { 1866 $tmp =~ s/^\n//; 1870 1867 $tmp =~ s|\n|<br />\n|g; 1871 $session->param($sessme, $ params{$sessme});1868 $session->param($sessme, $tmp); 1872 1869 delete $params{$sessme}; 1873 1870 }
Note:
See TracChangeset
for help on using the changeset viewer.