Changeset 508 for branches


Ignore:
Timestamp:
11/16/11 16:28:37 (12 years ago)
Author:
Kris Deugau
Message:

/branches/stable

Prep-for-release cleanup of buglets found making sure the demo
install works

  • Clean up instructions for creating the database. Apparently the PL/pgSQL "language" module required for the last-modified triggers can't be installed by a regular user, and isn't available by default. O_o
  • Fix a missed $IPDB::webpath-in-single-quotes
  • Add a quick hack to allow automagical allocation from private net ranges. See #38.
  • Partially convert some critical bits to use bound parameters in SQL for new allocations. See #34, mostly cleaned up already on /trunk or /branches/htmlform
  • Set $privdata = internally so that an allocation via admin tools doesn't error out
Location:
branches/stable
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/stable/INSTALL

    r507 r508  
    6161  b) Edit CustIDCK.pm as needed to validate customer IDs.
    6262
    63 4) As a Postgres superuser, create a database user and the database.
    64 Create the inital tables using cgi-bin/ipdb.psql.
     634) As a Postgres superuser, create a database user and the database:
     64
     65shell> psql template1
     66pg# create user ipdb with password "ipdbpwd";
     67pg# create database ipdb owner ipdb;
     68
     69Add the PL/pgSQL language to the database.  This is not strictly
     70necessary but there are triggers on the poolips and allocations table
     71to automatically update a last-modified column.
     72
     73pg# \c ipdb
     74pg# create language plpgsql
     75
     76Create the inital tables using cgi-bin/ipdb.psql:
     77
     78shell> psql -U ipdb ipdb <cgi-bin/ipdb.psql
    6579
    66805) Configure your webserver to call the IPDB scripts at an appropriate
  • branches/stable/assign.html

    r507 r508  
    3737<tr class="color2">
    3838<td>Route/allocate from this master:&nbsp;</td><td>$$MASTERLIST$$
    39 Allow automatic allocation from private IP ranges:<input type=checkbox name=allowpriv>
     39Allow automatic allocation from private IP ranges:<input type=checkbox $$ALLOWPRIV$$ name=allowpriv>
    4040</td>
    4141</tr><tr class="color1">
  • branches/stable/cgi-bin/IPDB.pm

    r445 r508  
    7272our $syslog_facility = 'local2';
    7373
     74# Allow allocations to come from private IP ranges by default?
     75# Set to 'y' or 'on' to enable.
     76our $allowprivrange = '';
     77
    7478# Let's initialize the globals.
    7579## IPDB::initIPDBGlobals()
     
    312316sub allocateBlock {
    313317  my ($dbh,undef,undef,$custid,$type,$city,$desc,$notes,$circid,$privdata,$nodeid) = @_;
     318  $privdata = '' if !defined($privdata);
    314319
    315320  my $cidr = new NetAddr::IP $_[1];
     
    399404          $sth = $dbh->prepare("insert into allocations".
    400405                " (cidr,custid,type,city,description,notes,maskbits,circuitid,privdata)".
    401                 " values ('$cidr','$custid','$type','$city','$desc','$notes',".
    402                 $cidr->masklen.",'$circid','$privdata')");
    403           $sth->execute;
     406                " values ('$cidr','$custid','$type','$city',?,?,".
     407                $cidr->masklen.",?,?)");
     408          $sth->execute($desc,$notes,$circid,$privdata);
    404409
    405410          # And initialize the pool, if necessary
     
    509514          $sth = $dbh->prepare("insert into allocations (cidr,custid,type,city,".
    510515                "description,notes,maskbits,circuitid,privdata)".
    511                 " values ('$cidr','$custid','$type','$city','$desc','$notes',".
    512                 $cidr->masklen.",'$circid','$privdata')");
    513           $sth->execute;
     516                " values ('$cidr','$custid','$type','$city',?,?,".
     517                $cidr->masklen.",?,?)");
     518          $sth->execute($desc,$notes,$circid,$privdata);
    514519
    515520          # And initialize the pool, if necessary
  • branches/stable/cgi-bin/MyIPDB.pm

    r507 r508  
    5151#$IPDB::syslog_facility = 'daemon';
    5252
     53# Allow allocations to come from private IP ranges by default?
     54# Set to 'y' or 'on' to enable.
     55#$IPDB::allowprivrange = '';
    5356
    5457## connectDB_My()
  • branches/stable/cgi-bin/main.cgi

    r507 r508  
    446446    # If the allocation is a pool, allow listing of the IPs in the pool.
    447447    if ($data[2] =~ /^.[pd]$/) {
    448       $row[0] .= ' &nbsp; <a href="$IPDB::webpath/cgi-bin/main.cgi?action=listpool'.
     448      $row[0] .= qq( &nbsp; <a href="$IPDB::webpath/cgi-bin/main.cgi?action=listpool).
    449449        "&pool=$data[0]\">List IPs</a>";
    450450    }
     
    583583
    584584    $html =~ s|\$\$WEBPATH\$\$|$IPDB::webpath|g;
     585    if ($IPDB::allowprivrange eq 'y' or $IPDB::allowprivrange eq 'on') {
     586      $html =~ s/\$\$ALLOWPRIV\$\$/checked=checked/;
     587    } else {
     588      $html =~ s/\$\$ALLOWPRIV\$\$//;
     589    }
    585590
    586591    # This is a little dangerous, as it's *theoretically* possible to
     
    614619    close HTML;
    615620    $html =~ s|\$\$WEBPATH\$\$|$IPDB::webpath|g;
     621    if ($IPDB::allowprivrange eq 'y' or $IPDB::allowprivrange eq 'on') {
     622      $html =~ s/\$\$ALLOWPRIV\$\$/checked=checked/;
     623    } else {
     624      $html =~ s/\$\$ALLOWPRIV\$\$//;
     625    }
    616626    my $masterlist = "<select name=allocfrom><option selected>-</option>\n";
    617627    foreach my $master (@masterblocks) {
Note: See TracChangeset for help on using the changeset viewer.