Changeset 274 for trunk/dns.cgi


Ignore:
Timestamp:
03/14/12 18:01:42 (13 years ago)
Author:
Kris Deugau
Message:

/trunk

Flesh out most reverse zone deletion. See #26.

  • Convert delDomain() to delZone()
  • Add checks to coerce the shared-zone record types down to standard types on removal of the second parent, either way around. (IE, A+PTR will be converted to PTR if the parent domain is removed, or A if the parent revzone is removed)

Make sure to show result or error messages on the reverse zone
list page

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/dns.cgi

    r272 r274  
    416416    my $pargroup = parentID($dbh, (id => $webvar{id}, type => 'domain', revrec => $webvar{revrec}));
    417417    my $dom = domainName($dbh, $webvar{id});
    418     my ($code,$msg) = delDomain($dbh, $webvar{id});
     418    my ($code,$msg) = delZone($dbh, $webvar{id}, $webvar{revrec});
    419419    if ($code eq 'OK') {
    420420      logaction($webvar{id}, $session->param("username"), $pargroup, "Deleted domain $dom");
     
    434434
    435435  $webvar{revrec} = 'y';
     436
     437  if ($session->param('resultmsg')) {
     438    $page->param(resultmsg => $session->param('resultmsg'));
     439    $session->clear('resultmsg');
     440  }
     441  if ($session->param('errmsg')) {
     442    $page->param(errmsg => $session->param('errmsg'));
     443    $session->clear('errmsg');
     444  }
     445
    436446  $page->param(curpage => $webvar{page});
    437447  listzones();
     
    480490  }
    481491
    482 #} elsif ($webvar{page} eq 'delrevzone') {
     492} elsif ($webvar{page} eq 'delrevzone') {
     493
     494  changepage(page => "revzones", errmsg => "You are not permitted to delete reverse zones")
     495        unless ($permissions{admin} || $permissions{domain_delete});
     496
     497  # security check - does the user have permission to access this entity?
     498  if (!check_scope(id => $webvar{id}, type => 'revzone')) {
     499    changepage(page => "revzones", errmsg => "You do not have permission to delete the requested reverse zone");
     500  }
     501
     502  $page->param(id => $webvar{id});
     503
     504  # first pass = confirm y/n (sorta)
     505  if (!defined($webvar{del})) {
     506
     507    $page->param(del_getconf => 1);
     508    $page->param(revzone => revName($dbh,$webvar{id}));
     509
     510  } elsif ($webvar{del} eq 'ok') {
     511    my $pargroup = parentID($dbh, (id => $webvar{id}, type => 'revzone', revrec => $webvar{revrec}));
     512    my $zone = revName($dbh, $webvar{id});
     513    my ($code,$msg) = delZone($dbh, $webvar{id}, 'y');
     514    if ($code eq 'OK') {
     515##fixme: logaction needs to take "domid OR revid" and some way to know which it is
     516      logaction($webvar{id}, $session->param("username"), $pargroup, "Deleted reverse zone $zone");
     517      changepage(page => "revzones", resultmsg => "Deleted reverse zone $zone");
     518    } else {
     519      logaction($webvar{id}, $session->param("username"), $pargroup, "Failed to delete domain $zone ($msg)")
     520        if $config{log_failures};
     521#push @debugbits, "got back $code, $msg\n";
     522      changepage(page => "revzones", errmsg => "Error deleting reverse zone $zone: $msg");
     523    }
     524
     525  } else {
     526    # cancelled.  whee!
     527    changepage(page => "revzones");
     528  }
    483529
    484530} elsif ($webvar{page} eq 'reclist') {
     
    12051251      my $pargroup = parentID($dbh, (id => $webvar{$_}, type => 'domain', revrec => $webvar{revrec}));
    12061252      my $dom = domainName($dbh, $webvar{$_});
    1207       my ($code, $msg) = delDomain($dbh, $webvar{$_});
     1253      my ($code, $msg) = delZone($dbh, $webvar{$_}, 'n');
    12081254      if ($code eq 'OK') {
    12091255        logaction($webvar{$_}, $session->param("username"), $pargroup, "Deleted domain $dom");
Note: See TracChangeset for help on using the changeset viewer.