Changeset 121 for trunk


Ignore:
Timestamp:
09/08/11 18:09:58 (13 years ago)
Author:
Kris Deugau
Message:

/trunk

checkpoint
Flesh out getSOA() stub in dns-rpc.cgi
Tweak getSOA() in DNSDB.pm for better error handling

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r118 r121  
    10481048  $sth->execute($id);
    10491049
    1050   my ($recid,$host,$val,$ttl,$serial) = $sth->fetchrow_array();
     1050  my ($recid,$host,$val,$ttl,$serial) = $sth->fetchrow_array() or return;
    10511051  my ($prins,$contact) = split /:/, $host;
    10521052  my ($refresh,$retry,$expire,$minttl) = split /:/, $val;
  • trunk/dns-rpc.cgi

    r119 r121  
    55use warnings;
    66use DNSDB;      # note we're not importing subs;  this lets us (ab)use the same sub names here for convenience
     7use Data::Dumper;
    78
    89#use Frontier::RPC2;
     
    1920# need to create a DNSDB object too
    2021my ($dbh,$msg) = DNSDB::connectDB("dnsdb","dnsdb","secret","dnsdbhost");
     22DNSDB::initGlobals($dbh);
    2123
    2224my $methods = {
    2325        'dnsdb.addDomain'       => \&addDomain,
    2426        'dnsdb.delDomain'       => \&delDomain,
     27        'dnsdb.addGroup'        => \&addGroup,
     28        'dnsdb.delGroup'        => \&delGroup,
     29        'dnsdb.addUser'         => \&addUser,
     30        'dnsdb.updateUser'      => \&updateUser,
     31        'dnsdb.delUser'         => \&delUser,
     32        'dnsdb.getSOA'          => \&getSOA,
     33
    2534        'dnsdb.getMethods'      => \&get_method_list
    2635};
     
    7988  die "Missing remote system name" if !$args{rpcsystem};        # for logging
    8089
     90  my ($code,$msg);
    8191  # Let's be nice;  delete based on domid OR domain name.  Saves an RPC call round-trip, maybe.
    8292  if ($args{domain} =~ /^\d+$/) {
    83     my ($code,$msg) = DNSDB::delDomain($dbh, $args{domain});
     93    ($code,$msg) = DNSDB::delDomain($dbh, $args{domain});
    8494  } else {
    8595    my $domid = DNSDB::domainID($dbh, $args{domain});
    8696    die "Can't find domain" if !$domid;
    87     my ($code,$msg) = DNSDB::delDomain($dbh, $domid);
     97    ($code,$msg) = DNSDB::delDomain($dbh, $domid);
    8898  }
    8999  die $msg if $code eq 'FAIL';
     
    101111
    102112# not sure how to usefully represent permissions from any further out from DNSDB.pm :/
     113# not to mention, permissions are checked at the UI layer, not the DB layer.
    103114  my $perms = {domain_edit => 1, domain_create => 1, domain_delete => 1,
    104115        record_edit => 1, record_create => 1, record_delete => 1
     
    117128  die "Missing remote system name" if !$args{rpcsystem};        # for logging
    118129
     130  my ($code,$msg);
    119131  # Let's be nice;  delete based on groupid OR group name.  Saves an RPC call round-trip, maybe.
    120132  if ($args{group} =~ /^\d+$/) {
    121     my ($code,$msg) = DNSDB::delGroup($dbh, $args{group});
     133    ($code,$msg) = DNSDB::delGroup($dbh, $args{group});
    122134  } else {
    123135    my $grpid = DNSDB::groupID($dbh, $args{group});
    124136    die "Can't find group" if !$grpid;
    125     my ($code,$msg) = DNSDB::delGroup($dbh, $grpid);
     137    ($code,$msg) = DNSDB::delGroup($dbh, $grpid);
    126138  }
    127139  die $msg if $code eq 'FAIL';
     
    139151  die "Missing remote system name" if !$args{rpcsystem};        # for logging
    140152
     153# not sure how to usefully represent permissions from any further out from DNSDB.pm :/
     154# not to mention, permissions are checked at the UI layer, not the DB layer.
     155  my $perms = {domain_edit => 1, domain_create => 1, domain_delete => 1,
     156        record_edit => 1, record_create => 1, record_delete => 1
     157        };
    141158  # bend and twist;  get those arguments in in the right order!
    142159  $args{type} = 'u' if !$args{type};
     
    162179
    163180  die "Missing UID" if !$args{uid};
     181
     182# not sure how to usefully represent permissions from any further out from DNSDB.pm :/
     183# not to mention, permissions are checked at the UI layer, not the DB layer.
     184  my $perms = {domain_edit => 1, domain_create => 1, domain_delete => 1,
     185        record_edit => 1, record_create => 1, record_delete => 1
     186        };
    164187  # bend and twist;  get those arguments in in the right order!
    165188  my @userargs = ($args{uid}, $args{username}, $args{group}, $args{pass}, $args{state}, $args{type});
     
    196219  die "Missing remote username" if !$args{rpcuser};             # for logging
    197220  die "Missing remote system name" if !$args{rpcsystem};        # for logging
     221
     222  my %ret = DNSDB::getSOA($dbh, $args{def}, $args{id});
     223  if (!$ret{recid}) {
     224    if ($args{def} eq 'y') {
     225      die "No default SOA record in group";
     226    } else {
     227      die "No SOA record in domain";
     228    }
     229  }
     230  return \%ret;
    198231}
    199232
Note: See TracChangeset for help on using the changeset viewer.