Changeset 586 for trunk


Ignore:
Timestamp:
01/17/14 10:34:43 (11 years ago)
Author:
Kris Deugau
Message:

/trunk

Fix subtle validation bug on TXT and SRV records.

SRV records would fail if entered as "_service._protocol" without the
domain. Move the domain coercion up above the check for _service._protocol
so its regex has a domain to chew on.


TXT records did not have any domain-part validation; you could end up
with bare-hostname TXT records instead of the correct hostname.domain
records. This only affects forward zones since TXT in reverse zones are
attached to an IP, which is validated as such elsewhere.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/DNSDB.pm

    r585 r586  
    648648# TXT record
    649649sub _validate_16 {
     650  my $self = shift;
     651
     652  my %args = @_;
     653
     654  if ($args{revrec} eq 'y') {
     655    # Coerce all hostnames to end in ".DOMAIN" for group/default records,
     656    # or the intended parent domain for live records.
     657    my $pname = ($args{defrec} eq 'y' ? 'DOMAIN' : $self->domainName($args{id}));
     658    ${$args{host}} =~ s/\.*$/\.$pname/ if ${$args{host}} !~ /$pname$/;
     659  }
     660
    650661  # Could arguably put a WARN return here on very long (>512) records
    651662  return ('OK','OK');
     
    694705  ${$args{dist}} =~ s/\s*//g;
    695706  return ('FAIL',"Distance is required, and must be numeric") unless ${$args{dist}} =~ /^\d+$/;
     707
     708  # Coerce all hostnames to end in ".DOMAIN" for group/default records,
     709  # or the intended parent domain for live records.
     710  my $pname = ($args{defrec} eq 'y' ? 'DOMAIN' : $self->domainName($args{id}));
     711  ${$args{host}} =~ s/\.*$/\.$pname/ if ${$args{host}} !~ /$pname$/;
    696712
    697713  return ('FAIL',"SRV records must begin with _service._protocol [${$args{host}}]")
     
    707723  ${$args{fields}} = "distance,weight,port,";
    708724  push @{$args{vallist}}, (${$args{dist}}, ${$args{weight}}, ${$args{port}});
    709 
    710   # Coerce all hostnames to end in ".DOMAIN" for group/default records,
    711   # or the intended parent domain for live records.
    712   my $pname = ($args{defrec} eq 'y' ? 'DOMAIN' : $self->domainName($args{id}));
    713   ${$args{host}} =~ s/\.*$/\.$pname/ if ${$args{host}} !~ /$pname$/;
    714725
    715726  return ('OK','OK');
Note: See TracChangeset for help on using the changeset viewer.