Changeset 195 for trunk/dns.cgi


Ignore:
Timestamp:
12/12/11 17:52:55 (13 years ago)
Author:
Kris Deugau
Message:

/trunk

More log behaviour tweaking

  • fix broken detail-logging of MX/SRV records on record add
  • add flag to control failure logging
  • fix broken user fullname grabber in _log

Tweak config loading with a few new options

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dns.cgi

    r193 r195  
    350350    changepage(page => "reclist", id => $msg);
    351351  } else {
    352     logaction(0, $session->param("username"), $webvar{group}, "Failed adding domain $webvar{domain} ($msg)");
     352    logaction(0, $session->param("username"), $webvar{group}, "Failed adding domain $webvar{domain} ($msg)")
     353        if $config{log_failures};
    353354    $session->param('add_failed', 1);
    354355##fixme:  domain a security risk for XSS?
     
    383384      changepage(page => "domlist", resultmsg => "Deleted domain $dom");
    384385    } else {
    385       logaction($webvar{id}, $session->param("username"), $pargroup, "Failed to delete domain $dom ($msg)");
     386      logaction($webvar{id}, $session->param("username"), $pargroup, "Failed to delete domain $dom ($msg)")
     387        if $config{log_failures};
    386388      changepage(page => "domlist", errmsg => "Error deleting domain $dom: $msg");
    387389    }
     
    520522      if ($webvar{defrec} eq 'y') {
    521523        my $restr = "Added default record '$webvar{name} $typemap{$webvar{type}}";
    522         $restr .= " [distance $dist]" if $typemap{$webvar{type}} eq 'MX';
    523         $restr .= " [priority $dist] [weight $weight] [port $port]" if $typemap{$webvar{type}} eq 'SRV';
     524        $restr .= " [distance $webvar{distance}]" if $typemap{$webvar{type}} eq 'MX';
     525        $restr .= " [priority $webvar{distance}] [weight $webvar{weight}] [port $webvar{port}]"
     526                if $typemap{$webvar{type}} eq 'SRV';
    524527        $restr .= " $webvar{address}', TTL $webvar{ttl}";
    525528        logaction(0, $session->param("username"), $webvar{parentid}, $restr);
    526529        changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec}, resultmsg => $restr);
    527530      } else {
    528         my $restr = "Added record '$webvar{name} $typemap{$webvar{type}}".
    529         $restr .= " [distance $dist]" if $typemap{$webvar{type}} eq 'MX';
    530         $restr .= " [priority $dist] [weight $weight] [port $port]" if $typemap{$webvar{type}} eq 'SRV';
     531        my $restr = "Added record '$webvar{name} $typemap{$webvar{type}}";
     532        $restr .= " [distance $webvar{dist}]" if $typemap{$webvar{type}} eq 'MX';
     533        $restr .= " [priority $webvar{dist}] [weight $webvar{weight}] [port $webvar{port}]"
     534                if $typemap{$webvar{type}} eq 'SRV';
    531535        $restr .= " $webvar{address}', TTL $webvar{ttl}";
    532536        logaction($webvar{parentid}, $session->param("username"), parentID($webvar{parentid}, 'dom', 'group'), $restr);
     
    543547      $page->param(id           => $webvar{id});
    544548      fill_recdata();   # populate the form... er, mostly.
    545       if ($webvar{defrec} eq 'y') {
    546         logaction(0, $session->param("username"), $webvar{parentid},
     549      if ($config{log_failures}) {
     550        if ($webvar{defrec} eq 'y') {
     551          logaction(0, $session->param("username"), $webvar{parentid},
    547552                "Failed adding default record '$webvar{name} $typemap{$webvar{type}} $webvar{address}', TTL $webvar{ttl} ($msg)");
    548       } else {
    549         logaction($webvar{parentid}, $session->param("username"), parentID($webvar{parentid}, 'dom', 'group'),
     553        } else {
     554          logaction($webvar{parentid}, $session->param("username"), parentID($webvar{parentid}, 'dom', 'group'),
    550555                "Failed adding record '$webvar{name} $typemap{$webvar{type}} $webvar{address}', TTL $webvar{ttl} ($msg)");
     556        }
    551557      }
    552558    }
     
    610616      $page->param(id           => $webvar{id});
    611617      fill_recdata();
    612       if ($webvar{defrec} eq 'y') {
    613         logaction(0, $session->param("username"), $webvar{parentid},
     618      if ($config{log_failures}) {
     619        if ($webvar{defrec} eq 'y') {
     620          logaction(0, $session->param("username"), $webvar{parentid},
    614621                "Failed updating default record '$typemap{$webvar{type}} $webvar{name} $webvar{address}', TTL $webvar{ttl} ($msg)");
    615       } else {
    616         logaction($webvar{parentid}, $session->param("username"), parentID($webvar{parentid}, 'dom', 'group'),
     622        } else {
     623          logaction($webvar{parentid}, $session->param("username"), parentID($webvar{parentid}, 'dom', 'group'),
    617624                "Failed updating record '$typemap{$webvar{type}} $webvar{name} $webvar{address}', TTL $webvar{ttl} ($msg)");
     625        }
    618626      }
    619627    }
     
    669677    } else {
    670678## need to find failure mode
    671       if ($webvar{defrec} eq 'y') {
    672         logaction(0, $session->param("username"), $rec->{parid},
     679      if ($config{log_failures}) {
     680        if ($webvar{defrec} eq 'y') {
     681          logaction(0, $session->param("username"), $rec->{parid},
    673682                "Failed deleting default record '$rec->{host} $typemap{$rec->{type}} $rec->{val}',".
    674683                " TTL $rec->{ttl} ($msg)");
    675       } else {
    676         logaction($rec->{parid}, $session->param("username"), parentID($rec->{parid}, 'dom', 'group'),
     684        } else {
     685          logaction($rec->{parid}, $session->param("username"), parentID($rec->{parid}, 'dom', 'group'),
    677686                "Failed deleting record '$rec->{host} $typemap{$rec->{type}} $rec->{val}', TTL $rec->{ttl} ($msg)");
     687        }
    678688      }
    679689      changepage(page => "reclist", id => $webvar{parentid}, defrec => $webvar{defrec},
     
    740750    $page->param(msg => $DBI::errstr);
    741751    fillsoa($webvar{defrec},$webvar{id});
     752##fixme: faillog
    742753  } else {
    743754
     
    820831      }
    821832    } # fallthrough else
    822     logaction(0, $session->param("username"), $webvar{pargroup}, "Failed to add group $webvar{newgroup}: $msg");
     833    logaction(0, $session->param("username"), $webvar{pargroup}, "Failed to add group $webvar{newgroup}: $msg")
     834        if $config{log_failures};
    823835    # no point in doing extra work
    824836    fill_permissions($page, \%newperms);
     
    864876    } else {
    865877# need to find failure mode
    866       logaction(0, $session->param("username"), $delparent, "Failed to delete group $deleteme: $msg");
     878      logaction(0, $session->param("username"), $delparent, "Failed to delete group $deleteme: $msg")
     879        if $config{log_failures};
    867880      changepage(page => "grpman", errmsg => "Error deleting group $deleteme: $msg");
    868881    }
     
    913926    } # fallthrough else
    914927    logaction(0, $session->param("username"), $webvar{gid}, "Failed to update default permissions in group ".
    915         groupName($dbh, $webvar{gid}).": $msg");
     928        groupName($dbh, $webvar{gid}).": $msg")
     929        if $config{log_failures};
    916930    # no point in doing extra work
    917931    fill_permissions($page, \%chperms);
     
    10021016      } else {
    10031017        logaction($webvar{$_}, $session->param("username"), parentID($webvar{$_}, 'dom', 'group'),
    1004                 "Failed to move domain ".domainName($dbh, $webvar{$_})." to group $newgname: $msg");
     1018                "Failed to move domain ".domainName($dbh, $webvar{$_})." to group $newgname: $msg")
     1019                if $config{log_failures};
    10051020      }
    10061021      $row{domerr} = $msg;
     
    10591074        $row{domok} = ($code eq 'OK');
    10601075      } else {
    1061         logaction($webvar{$_}, $session->param("username"), $pargroup, "Failed to delete domain $dom: $msg");
     1076        logaction($webvar{$_}, $session->param("username"), $pargroup, "Failed to delete domain $dom: $msg")
     1077                if $config{log_failures};
    10621078      }
    10631079      $row{domerr} = $msg;
     
    12511267      fill_clonemelist();
    12521268      logaction(0, $session->param("username"), $curgroup, "Failed to $webvar{action} user ".
    1253         "$webvar{uname}: $msg");
     1269        "$webvar{uname}: $msg")
     1270        if $config{log_failures};
    12541271    }
    12551272
     
    13301347      list_users($curgroup);
    13311348      logaction(0, $session->param("username"), $curgroup, "Failed to delete user ".
    1332         "$webvar{id}/".$userref->{username}.": $msg");
     1349        "$webvar{id}/".$userref->{username}.": $msg")
     1350        if $config{log_failures};
    13331351    }
    13341352  } else {
Note: See TracChangeset for help on using the changeset viewer.