Changeset 984 for branches/cname-collision
- Timestamp:
- 01/15/26 11:29:54 (12 days ago)
- Location:
- branches/cname-collision
- Files:
-
- 4 edited
-
DNSDB.pm (modified) (2 diffs)
-
t/cname.t (modified) (2 diffs)
-
t/dns-unitbase.sql (modified) (5 diffs)
-
t/test-cname-timestamps.sql (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
branches/cname-collision/DNSDB.pm
r983 r984 665 665 # Check timestamps of pending active-after records. Coerce expires-at fields to soonest match if found. 666 666 if ($args{defrec} eq 'n') { 667 $sql = "SELECT extract(epoch from stamp) FROM "._rectable($args{defrec}, $args{revrec}).668 " WHERE "._recparent($args{defrec}, $args{revrec})." = ? AND type $tcompare 5 AND $hfield = ?".669 " AND stampactive = 't' AND expires = 'f' AND stamp >= now()";667 $sql = "SELECT extract(epoch from stamp),stamp < now() FROM "._rectable($args{defrec}, $args{revrec}). 668 " WHERE "._recparent($args{defrec}, $args{revrec})." = ? AND type $tcompare 5 AND $hfield = ?". 669 " AND stampactive = 't' AND expires = 'f'"; 670 670 my @lookupargs = ($args{id}, $hcheck); 671 671 if ($args{update}) { 672 $sql .= " AND record_id <> ?";672 $sql .= " AND record_id <> ?"; 673 673 push @lookupargs, $args{update}; 674 674 } 675 $sql .= " ORDER BY stamp LIMIT 1";675 $sql .= " ORDER BY stamp LIMIT 1"; 676 676 my @t = $dbh->selectrow_array($sql, undef, @lookupargs); 677 677 if (@t) { … … 693 693 } 694 694 } else { 695 # no expiry requested, but we found a valid-after, so coerce the new record down to expiring at that time 696 ${$args{stamp}} = strftime('%Y-%m-%d %H:%M:%S', localtime($t[0])); 697 ${$args{expires}} = 't'; 698 return ('WARN', "CNAME added with expiry time; conflicting valid-after record found"); 695 if ($t[1]) { 696 return('FAIL', "Cannot add CNAME, a record with a valid-after time in the past is already present"); 697 } else { 698 # no expiry requested, but we found a valid-after, so coerce the new record down to expiring at that time 699 ${$args{stamp}} = strftime('%Y-%m-%d %H:%M:%S', localtime($t[0])); 700 ${$args{expires}} = 't'; 701 return ('WARN', "CNAME added with expiry time; conflicting valid-after record found"); 702 } 699 703 } 700 704 } -
branches/cname-collision/t/cname.t
r982 r984 226 226 } 227 227 }; 228 subtest ' - collision with active-after record' => sub {228 subtest ' - collision with pending active-after record' => sub { 229 229 $newname = 'active-after1.expiry1.test'; 230 230 ($code, $msg) = $dnsdb->addRec('n', 'n', 4, \$newname, \$rectype, \$newval, 900); … … 243 243 } 244 244 }; 245 subtest ' - collision with active active-after record' => sub { 246 $newname = 'active-after2.expiry1.test'; 247 ($code, $msg) = $dnsdb->addRec('n', 'n', 4, \$newname, \$rectype, \$newval, 900); 248 ok( $code eq 'FAIL', "addRec() claimed failure" ); 249 if ($code eq 'FAIL') { 250 ($rcount) = $dbh->selectrow_array("SELECT count(*) FROM records WHERE domain_id = 4 AND host = '$newname' AND type <> 5"); 251 ok( $rcount == 1, " ... [$rcount] record(s) with $newname already exist" ); 252 like( $msg, qr/record with a valid-after time in the past/, " ... returned matching error" ); 253 } 254 }; 245 255 }; # add non-timestamp CNAME 246 256 -
branches/cname-collision/t/dns-unitbase.sql
r976 r984 657 657 2 example.org 1 1 2025121800 D f ac 658 658 3 example.net 1 1 2025121800 D f ab 659 4 expiry1.test 1 1 202601 0702D t659 4 expiry1.test 1 1 2026011400 D t 660 660 \. 661 661 … … 764 764 57 4 1 1 admin Initial User Added record 'expired2.expiry1.test TXT imma expire soon', TTL 5400, expires at 2026-01-10 07:00 2026-01-07 17:57:07.015962-05 0 0 765 765 58 4 1 1 admin Initial User Added record 'active-after1.expiry1.test TXT not active yet', TTL 5400, valid after 2026-01-11 11:30 2026-01-07 18:12:57.491476-05 0 0 766 59 4 1 1 admin Initial User Added record 'active-after2.expiry1.test TXT I'm done waiting', TTL 5400, expires at 2025-12-31 14:00 2026-01-14 18:02:13.876839-05 0 0 766 767 \. 767 768 … … 771 772 -- 772 773 773 SELECT pg_catalog.setval('public.log_log_id_seq', 5 8, true);774 SELECT pg_catalog.setval('public.log_log_id_seq', 59, true); 774 775 775 776 … … 861 862 4 48 expired2.expiry1.test 16 imma expire soon 0 0 0 5400 \N 0 2026-01-10 07:00:00-05 t t \N 862 863 4 49 active-after1.expiry1.test 16 not active yet 0 0 0 5400 \N 0 2026-01-11 11:30:00-05 f t \N 864 4 50 active-after2.expiry1.test 16 I'm done waiting 0 0 0 5400 \N 0 2025-12-31 14:00:00-05 f t \N 863 865 \. 864 866 … … 868 870 -- 869 871 870 SELECT pg_catalog.setval('public.records_record_id_seq', 49, true);872 SELECT pg_catalog.setval('public.records_record_id_seq', 50, true); 871 873 872 874 -
branches/cname-collision/t/test-cname-timestamps.sql
r979 r984 6 6 UPDATE records SET stamp = date_trunc('day', now() + interval '3 day') + '07:00' WHERE record_id = 48; 7 7 UPDATE records SET stamp = date_trunc('day', now() + interval '5 day') + '11:30' WHERE record_id = 49; 8 UPDATE records SET stamp = date_trunc('day', now() - interval '3 day') + '14:00' WHERE record_id = 50;
Note:
See TracChangeset
for help on using the changeset viewer.
![[ DNS Administrator ]](/fx/dnsadmin-logo.png)