Changeset 798 for trunk/cgi-bin/main.cgi


Ignore:
Timestamp:
12/23/15 15:46:13 (9 years ago)
Author:
Kris Deugau
Message:

/trunk

Complete adding the IP address field to the backup fields
Complete add/update handling for backup fields generally

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/main.cgi

    r793 r798  
    676676    $page->param(bkepass => $q->escapeHTML($webvar{bkepass}));
    677677    $page->param(bkport  => $webvar{bkport});
     678    $page->param(bkip    => $webvar{bkip});
    678679  }
    679680
     
    739740  if ($webvar{backupfields}) {
    740741    $insert_args{backup} = 1;
    741     $insert_args{bkbrand} = $webvar{bkbrand};
    742     $insert_args{bkmodel} = $webvar{bkmodel};
    743     for my $bkfield (qw(type src user vpass epass port)) {
     742    for my $bkfield (@IPDB::backupfields) {
    744743      $insert_args{"bk$bkfield"} = ($webvar{"bk$bkfield"} ? $webvar{"bk$bkfield"} : '');
    745744    }
     
    908907  # Backup fields.  Minimal sanity checks.
    909908  for my $bkfield (qw(brand model)) {
    910     if ($webvar{"bk$bkfield"} && $webvar{"bk$bkfield"} !~ /^[a-zA-Z0-9\s_.-]+$/) {
     909    if (!$webvar{"bk$bkfield"}) {
     910      $page->param(err => "Backup $bkfield must be filled in if IP/netblock is flagged for backup");
     911      return;
     912    }
     913    if ($webvar{"bk$bkfield"} !~ /^[a-zA-Z0-9\s_.-]+$/) {
    911914      $page->param(err => "Invalid characters in backup $bkfield");
    912915      return;
     
    924927    if ($webvar{bkport} !~ /^\d+$/) {
    925928      $page->param(err => "Backup port must be numeric");
     929      return;
     930    }
     931  }
     932##fixme:  code review:  should normalize $webvar{cidr} variants so we can
     933# check for non-/32 allocations having the backup IP field filled in here,
     934# instead of failing on the allocation or update attempt
     935  if ($webvar{bkip}) {
     936    $webvar{bkip} =~ s/^\s+//g;
     937    $webvar{bkip} =~ s/\s+$//g;
     938    if ($webvar{bkip} !~ /^[\da-fA-F:.]+$/) {
     939      $page->param(err => "Backup IP must be an IP");
    926940      return;
    927941    }
     
    9901004  if ($blockinfo->{hasbk}) {
    9911005    $page->param(hasbackup => $blockinfo->{hasbk});
    992     for my $bkfield (qw(brand model src user vpass epass port)) {
     1006    for my $bkfield (@IPDB::backupfields) {
    9931007      $page->param("bk$bkfield" => $blockinfo->{"bk$bkfield"});
    9941008    }
     
    11251139  if ($IPDBacl{$authuser} =~ /s/) {
    11261140    $updargs{privdata} = $webvar{privdata};
    1127     for my $bkfield (qw(brand model type src user vpass epass port)) {
     1141    for my $bkfield (@IPDB::backupfields) {
    11281142      $updargs{"bk$bkfield"} = $webvar{"bk$bkfield"};
    11291143    }
    1130     $updargs{backupfields} = $webvar{backupfields};
     1144    $updargs{backup} = $webvar{backupfields};
    11311145  } else {
    11321146    # If the user doesn't have permissions to monkey with NOC-things, pass
     
    12031217    $page->param(nocling  => 1);
    12041218    $page->param(privdata => $webvar{privdata});
    1205     if ($binfo->{hasbk}) {
    1206       $page->param(hasbackup => $binfo->{hasbk});
    1207       for my $bkfield (qw(brand model type src user vpass epass port)) {
    1208         $page->param("bk$bkfield" => $binfo->{"bk$bkfield"});
     1219    if ($webvar{backupfields} && $webvar{backupfields} eq 'on') {
     1220      $page->param(hasbackup => 1);
     1221      for my $bkfield (qw(@IPDB::backupfields) {
     1222        $page->param("bk$bkfield" => $webvar{"bk$bkfield"});
    12091223      }
    12101224    }
Note: See TracChangeset for help on using the changeset viewer.