Changeset 209 for trunk


Ignore:
Timestamp:
12/19/11 17:58:57 (13 years ago)
Author:
Kris Deugau
Message:

/trunk

Fix up error reporting in addRec(); don't want to cause unintelligible
database errors where we can catch data-type mismatches before touching
the DB.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r208 r209  
    13681368  }
    13691369
     1370  return ('FAIL', "TTL must be numeric") unless $ttl =~ /^\d+$/;
     1371
    13701372  my $fields = ($defrec eq 'y' ? 'group_id' : 'domain_id').",host,type,val,ttl";
    13711373  my $vallen = "?,?,?,?,?";
     
    13751377  if ($rectype == $reverse_typemap{MX} or $rectype == $reverse_typemap{SRV}) {
    13761378    $dist = shift;
    1377     return ('FAIL',"Need distance for $typemap{$rectype} record") if !defined($dist);
     1379    return ('FAIL',"Distance is required for $typemap{$rectype} records") unless defined($dist);
     1380    $dist =~ s/\s*//g;
     1381    return ('FAIL',"Distance is required, and must be numeric") unless $dist =~ /^\d+$/;
    13781382    $fields .= ",distance";
    13791383    $vallen .= ",?";
     
    13861390    # it just says (paraphrased) "... is prepended with _ to prevent DNS collisions"
    13871391    return ('FAIL',"SRV records must begin with _service._protocol [$host]")
    1388         if $host !~ /^_[A-Za-z]+\._[A-Za-z]+\.[a-zA-Z0-9-]+/;
     1392        unless $host =~ /^_[A-Za-z]+\._[A-Za-z]+\.[a-zA-Z0-9-]+/;
    13891393    $weight = shift;
    13901394    $port = shift;
    1391     return ('FAIL',"Need weight and port for SRV record") if !defined($weight) or !defined($port);
     1395    return ('FAIL',"Port and weight are required for SRV records") unless defined($weight) && defined($port);
     1396    $weight =~ s/\s*//g;
     1397    $port =~ s/\s*//g;
     1398    return ('FAIL',"Port and weight are required, and must be numeric")
     1399        unless $weight =~ /^\d+$/ && $port =~ /^\d+$/;
    13921400    $fields .= ",weight,port";
    13931401    $vallen .= ",?,?";
  • trunk/dns.cgi

    r207 r209  
    535535      } else {
    536536        my $restr = "Added record '$webvar{name} $typemap{$webvar{type}}";
    537         $restr .= " [distance $webvar{dist}]" if $typemap{$webvar{type}} eq 'MX';
    538         $restr .= " [priority $webvar{dist}] [weight $webvar{weight}] [port $webvar{port}]"
     537        $restr .= " [distance $webvar{distance}]" if $typemap{$webvar{type}} eq 'MX';
     538        $restr .= " [priority $webvar{distance}] [weight $webvar{weight}] [port $webvar{port}]"
    539539                if $typemap{$webvar{type}} eq 'SRV';
    540540        $restr .= " $webvar{address}', TTL $webvar{ttl}";
     
    552552      $page->param(id           => $webvar{id});
    553553      fill_recdata();   # populate the form... er, mostly.
     554      $page->param(name => $webvar{name});
    554555      if ($config{log_failures}) {
    555556        if ($webvar{defrec} eq 'y') {
Note: See TracChangeset for help on using the changeset viewer.