Changeset 516


Ignore:
Timestamp:
05/24/13 16:58:49 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Tune up location/view handling on zone add. See #10.

Domains and revzones added with a location specified will actually use
that location. Documentation note: Zones specifying a location on
creation will only be visible to that location, because the SOA record
will be created with that location. A zone should be created with no
location set if records must be visible across multiple locations, or
publicly.

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r514 r516  
    18111811  my $state = shift;
    18121812  return ('FAIL',"Domain status must be specified\n") if !defined($state);
     1813  my $defloc = shift || '';
    18131814
    18141815  $state = 1 if $state =~ /^active$/;
     
    18381839  eval {
    18391840    # insert the domain...
    1840     $dbh->do("INSERT INTO domains (domain,group_id,status) VALUES (?,?,?)", undef, ($domain, $group, $state));
     1841    $dbh->do("INSERT INTO domains (domain,group_id,status,default_location) VALUES (?,?,?,?)", undef,
     1842        ($domain, $group, $state, $defloc));
    18411843
    18421844    # get the ID...
     
    18491851    # ... and now we construct the standard records from the default set.  NB:  group should be variable.
    18501852    my $sth = $dbh->prepare("SELECT host,type,val,distance,weight,port,ttl FROM default_records WHERE group_id=?");
    1851     my $sth_in = $dbh->prepare("INSERT INTO records (domain_id,host,type,val,distance,weight,port,ttl)".
    1852         " VALUES ($dom_id,?,?,?,?,?,?,?)");
     1853    my $sth_in = $dbh->prepare("INSERT INTO records (domain_id,host,type,val,distance,weight,port,ttl,location)".
     1854        " VALUES ($dom_id,?,?,?,?,?,?,?,?)");
    18531855    $sth->execute($group);
    1854     while (my ($host,$type,$val,$dist,$weight,$port,$ttl) = $sth->fetchrow_array()) {
     1856    while (my ($host, $type, $val, $dist, $weight, $port, $ttl) = $sth->fetchrow_array()) {
    18551857      $host =~ s/DOMAIN/$domain/g;
    18561858      $val =~ s/DOMAIN/$domain/g;
    1857       $sth_in->execute($host,$type,$val,$dist,$weight,$port,$ttl);
     1859      $sth_in->execute($host, $type, $val, $dist, $weight, $port, $ttl, $defloc);
    18581860      if ($typemap{$type} eq 'SOA') {
    18591861        my @tmp1 = split /:/, $host;
  • trunk/dns-rpc.cgi

    r515 r516  
    192192  _commoncheck(\%args, 'y');
    193193
    194   my ($code, $msg) = $dnsdb->addDomain($args{domain}, $args{group}, $args{state});
     194  my ($code, $msg) = $dnsdb->addDomain($args{domain}, $args{group}, $args{state}, $args{location});
    195195  die "$msg\n" if $code eq 'FAIL';
    196196  return $msg;  # domain ID
  • trunk/dns.cgi

    r513 r516  
    394394  $webvar{group} = $curgroup if !$webvar{group};
    395395  fill_grouplist("grouplist", $webvar{group});
    396   fill_loclist();
     396  fill_loclist($curgroup, $webvar{defloc} ? $webvar{defloc} : '');
    397397
    398398  if ($session->param('add_failed')) {
     
    420420  $webvar{makeactive} = 0 if !defined($webvar{makeactive});
    421421
    422   my ($code,$msg) = $dnsdb->addDomain($webvar{domain}, $webvar{group}, ($webvar{makeactive} eq 'on' ? 1 : 0));
     422  my ($code,$msg) = $dnsdb->addDomain($webvar{domain}, $webvar{group}, ($webvar{makeactive} eq 'on' ? 1 : 0),
     423        $webvar{defloc});
    423424
    424425  if ($code eq 'OK') {
     
    430431    $session->param('add_failed', 1);
    431432##fixme:  domain a security risk for XSS?
    432     changepage(page => "newdomain", domain => $webvar{domain}, errmsg => $msg,
    433         makeactive => ($webvar{makeactive} ? 'y' : 'n'), group => $webvar{group});
     433    changepage(page => "newdomain", errmsg => $msg, domain => $webvar{domain},
     434        group => $webvar{group}, makeactive => ($webvar{makeactive} ? 'y' : 'n'), defloc => $webvar{defloc});
    434435  }
    435436
  • trunk/templates/newdomain.tmpl

    r493 r516  
    3232<TMPL_IF location_view><TMPL_IF record_locchg>
    3333        <tr class="datalinelight">
    34                 <td>Default location/view:</td>
     34                <td>Location/view:</td>
    3535                <td><select name="defloc">
    3636<TMPL_LOOP name=loclist>                <option value="<TMPL_VAR NAME=loc>"<TMPL_IF selected> selected="selected"</TMPL_IF>><TMPL_VAR NAME=locname></option>
  • trunk/templates/newrevzone.tmpl

    r493 r516  
    2626        </tr>
    2727        <tr class="datalinelight">
    28                 <td>Default location/view:</td>
    29                 <td align="left">
    30                         <select name="location">
    31                         <TMPL_LOOP loclist>
    32                         <option value="<TMPL_VAR NAME=loc>"<TMPL_IF selected> selected</TMPL_IF>><TMPL_VAR NAME=locname></option>
    33                         </TMPL_LOOP>
    34                         </select>
    35                 </td>
    36         </tr>
    37         <tr class="datalinelight">
    3828                <td>Add reverse zone to group:</td>
    3929                <td><select name="group">
     
    4535                <td>Make reverse zone active on next DNS propagation</td><td><input type="checkbox" name="makeactive" checked="checked" /></td>
    4636        </tr>
     37<TMPL_IF location_view><TMPL_IF record_locchg>
     38        <tr class="datalinelight">
     39                <td>Location/view:</td>
     40                <td align="left">
     41                        <select name="location">
     42                        <TMPL_LOOP loclist>
     43                        <option value="<TMPL_VAR NAME=loc>"<TMPL_IF selected> selected="selected"</TMPL_IF>><TMPL_VAR NAME=locname></option>
     44                        </TMPL_LOOP>
     45                        </select>
     46                </td>
     47        </tr>
     48</TMPL_IF></TMPL_IF>
    4749        <tr><td colspan="2" class="tblsubmit"><input type="submit" value="Add reverse zone" /></td></tr>
    4850    </table>
Note: See TracChangeset for help on using the changeset viewer.