Changeset 255


Ignore:
Timestamp:
03/01/12 16:39:04 (13 years ago)
Author:
Kris Deugau
Message:

/trunk

Update addGroup() to copy default reverse records. See #26.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r254 r255  
    13381338    $sth->execute($pargroup,$groupname);
    13391339
    1340     $sth = $dbh->prepare("SELECT group_id FROM groups WHERE group_name=?");
    1341     $sth->execute($groupname);
    1342     my ($groupid) = $sth->fetchrow_array();
     1340    my ($groupid) = $dbh->selectrow_array("SELECT group_id FROM groups WHERE group_name=?", undef, ($groupname));
    13431341
    13441342# Permissions
     
    13651363
    13661364# Default records
    1367     $sth = $dbh->prepare("INSERT INTO default_records (group_id,host,type,val,distance,weight,port,ttl) ".
     1365    my $sthf = $dbh->prepare("INSERT INTO default_records (group_id,host,type,val,distance,weight,port,ttl) ".
    13681366        "VALUES ($groupid,?,?,?,?,?,?,?)");
     1367    my $sthr = $dbh->prepare("INSERT INTO default_rev_records (group_id,host,type,val,ttl) ".
     1368        "VALUES ($groupid,?,?,?,?)");
    13691369    if ($inherit) {
    13701370      # Duplicate records from parent.  Actually relying on inherited records feels
     
    13731373      $sth2->execute($pargroup);
    13741374      while (my @clonedata = $sth2->fetchrow_array) {
    1375         $sth->execute(@clonedata);
     1375        $sthf->execute(@clonedata);
     1376      }
     1377      # And now the reverse records
     1378      $sth2 = $dbh->prepare("SELECT group_id,host,type,val,ttl FROM default_rev_records WHERE group_id=?");
     1379      $sth2->execute($pargroup);
     1380      while (my @clonedata = $sth2->fetchrow_array) {
     1381        $sthr->execute(@clonedata);
    13761382      }
    13771383    } else {
     
    13791385      # reasonable basic defaults for SOA, MX, NS, and minimal hosting
    13801386      # could load from a config file, but somewhere along the line we need hardcoded bits.
    1381       $sth->execute('ns1.example.com:hostmaster.example.com', 6, '10800:3600:604800:10800', 0, 0, 0, 86400);
    1382       $sth->execute('DOMAIN', 1, '192.168.4.2', 0, 0, 0, 7200);
    1383       $sth->execute('DOMAIN', 15, 'mx.example.com', 10, 0, 0, 7200);
    1384       $sth->execute('DOMAIN', 2, 'ns1.example.com', 0, 0, 0, 7200);
    1385       $sth->execute('DOMAIN', 2, 'ns2.example.com', 0, 0, 0, 7200);
    1386       $sth->execute('www.DOMAIN', 5, 'DOMAIN', 0, 0, 0, 7200);
     1387      $sthf->execute('ns1.example.com:hostmaster.example.com', 6, '10800:3600:604800:10800', 0, 0, 0, 86400);
     1388      $sthf->execute('DOMAIN', 1, '192.168.4.2', 0, 0, 0, 7200);
     1389      $sthf->execute('DOMAIN', 15, 'mx.example.com', 10, 0, 0, 7200);
     1390      $sthf->execute('DOMAIN', 2, 'ns1.example.com', 0, 0, 0, 7200);
     1391      $sthf->execute('DOMAIN', 2, 'ns2.example.com', 0, 0, 0, 7200);
     1392      $sthf->execute('www.DOMAIN', 5, 'DOMAIN', 0, 0, 0, 7200);
     1393      # reasonable basic defaults for generic reverse zone.  Same as initial SQL tabledef.
     1394      $sthr->execute('hostmaster.ADMINDOMAIN:ns1.ADMINDOMAIN', 6, '10800:3600:604800:10800', 86400);
     1395      $sthr->execute('unused-%r.ADMINDOMAIN', 65283, 'ZONE', 3600);
    13871396    }
    13881397
Note: See TracChangeset for help on using the changeset viewer.