Changeset 522 for trunk


Ignore:
Timestamp:
06/12/13 17:03:30 (12 years ago)
Author:
Kris Deugau
Message:

/trunk

Add option to tiny-import to be less strict about importing = records.
-l will import the = record as-is, even if the forward or reverse zone
doesn't exist. Note if the zone is imported or added later this will
*NOT* automatically import the record!

Records that are not in either a forward or reverse zone will still be
treated as "failed".

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tiny-import.pl

    r520 r522  
    3737        conv    => 0,
    3838        trial   => 0,
     39        legacy  => 0,
    3940        );
    4041# Handle some command-line arguments
    4142while ($ARGV[0] =~ /^-/) {
    4243  my $arg = shift @ARGV;
    43   usage() if $arg !~ /^-[rct]+$/;
     44  usage() if $arg !~ /^-[rclt]+$/;
    4445  # -r  rewrite imported files to comment imported records
    4546  # -c  coerce/downconvert A+PTR = records to PTR
     47  # -l  swallow A+PTR as-is
    4648  # -t  trial mode;  don't commit to DB or actually rewrite flatfile (disables -r)
    4749  $arg =~ s/^-//;
     
    5052    $importcfg{rw} = 1 if $_ eq 'r';
    5153    $importcfg{conv} = 1 if $_ eq 'c';
     54    $importcfg{legacy} = 1 if $_ eq 'l';
    5255    $importcfg{trial} = 1 if $_ eq 't';
    5356  }
     
    6568            Multiple passes may be necessary if SOA and = records are heavily
    6669            intermixed and not clustered together.
     70        -l  (for "legacy")  Force import of A+PTR records as-is.  Mutually exclusive
     71            with -c.  -l takes precedence as -c is lossy.
    6772        -t  Trial run mode;  spits out records that would be left unimported.
    6873            Disables -r if set.
     
    272277        $recsth->execute($fparent, $rparent, $host, 65280, $ip, 0, 0, 0, $ttl, $loc);
    273278      } else {
    274         if ($importcfg{conv}) {
     279        if ($importcfg{legacy}) {
     280          # Just import it already!  Record may still be subject to downconversion on editing.
     281          $fparent = 0 if !$fparent;
     282          $rparent = 0 if !$rparent;
     283          if ($fparent || $rparent) {
     284            $recsth->execute($fparent, $rparent, $host, 65280, $ip, 0, 0, 0, $ttl, $loc);
     285          } else {
     286            # No parents found, cowardly refusing to add a dangling record
     287            push @deferred, $rec unless $nodefer;
     288            $impok = 0;
     289          }
     290        } elsif ($importcfg{conv}) {
    275291          # downconvert A+PTR if forward zone is not found
    276292          $recsth->execute(0, $rparent, $host, 12, $ip, 0, 0, 0, $ttl, $loc);
Note: See TracChangeset for help on using the changeset viewer.