Ignore:
Timestamp:
01/28/26 12:52:41 (16 hours ago)
Author:
Kris Deugau
Message:

/branches/cname-collision

Revise logic branch for new/updated record with valid-after potentially
colliding with existing record with expiry stamp to match intended behaviour
in truth table, including adjusting valid-after timestamp to match the
existing expiry if the appropriate ocnfiguration flag is set.
See #72

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/cname-collision/DNSDB.pm

    r1000 r1003  
    723723    if (@t) {
    724724      # caller requested an expiry time
     725      my $reqstamp = str2time(${$args{stamp}});
    725726      if (${$args{expires}} eq 'f') {
    726         # valid-after can't be used together with expires-at on one record, so we can't
    727         # coerce the new record to expire as well as keeping valid-after
    728         if ($tcompare eq '<>') {
    729           return ('FAIL', "Cannot ".($args{update} ? 'update' : 'add')." CNAME, another record".
     727        if ($reqstamp > $t[0]) {
     728          # do nothing, new record goes valid after the expiring record we found
     729        } else {
     730          if ($self->{coerce_cname_timestamp} eq 'adjust') {
     731            # coerce the valid-after timestamp
     732            ${$args{stamp}} = strftime('%Y-%m-%d %H:%M:%S', localtime($t[0]));
     733            return ('WARN', $typemap{${$args{rectype}}}." ".($args{update} ? 'updated' : 'added').
     734                " with modified valid-after time;  conflicting expiring record found");
     735          } else {
     736            # New valid-after overlaps existing expiry, and not configured to adjust it
     737            my $fill = ($tcompare eq '<>' ? ' CNAME, another record' : $typemap{${$args{rectype}}}.', a CNAME');
     738            return ('FAIL', "Cannot ".($args{update} ? 'update' : 'add').$fill.
    730739                " with a valid-after time already exists for this name");
    731         } else {
    732           return ('FAIL', "Cannot ".($args{update} ? 'update' : 'add')." ".$typemap{${$args{rectype}}}.
    733                 ", a CNAME with a valid-after time already exists for this name");
    734         }
     740          }
     741        } # else ($reqstamp < $t[0])
    735742      } else {
    736         my $reqstamp = str2time(${$args{stamp}});
    737743        if ($reqstamp < $t[0]) {
    738744          # do nothing, new record will expire before the one we found
Note: See TracChangeset for help on using the changeset viewer.