From cf46cb42cf1001da12ce4f4a4ed9f82345b9d44c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20=C5=A0vamberg?= Date: Fri, 27 Jun 2025 00:00:46 +0200 Subject: [PATCH] add import SSHFP records --- ChangeLog | 1 + Sauron/UtilZone.pm | 14 ++++++++++++-- import-zone | 5 +++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 77d34bd..398b99f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -9,6 +9,7 @@ - add import CAA records into Custom zone file entries by Michal Švamberg - fix import of multiple TXT zone records by Michal Švamberg - add import DS records into Custom zone file entries by Michal Švamberg + - add import SSHFP records by Michal Švamberg 0.7.4 [project moved to sourceforge and switched to use git instead of cvs] diff --git a/Sauron/UtilZone.pm b/Sauron/UtilZone.pm index d71f141..13b9ff7 100644 --- a/Sauron/UtilZone.pm +++ b/Sauron/UtilZone.pm @@ -124,7 +124,7 @@ sub process_zonefile($$$$) { unless ($class =~ /^(IN|CS|CH|HS)$/); # type - unless ($type =~ /^(SOA|A|AAAA|PTR|CNAME|MX|NS|TXT|HINFO|WKS|MB|MG|MD|MF|MINFO|MR|AFSDB|ISDN|RP|RT|X25|PX|SRV|NAPTR|CAA|DS)$/) { + unless ($type =~ /^(SOA|A|AAAA|PTR|CNAME|MX|NS|TXT|HINFO|WKS|MB|MG|MD|MF|MINFO|MR|AFSDB|ISDN|RP|RT|X25|PX|SRV|NAPTR|CAA|DS|SSHFP)$/) { if ($ext_flag > 0) { unless ($type =~ /^(DHCP|ALIAS|AREC|ROUTER|PRINTER|BOOTP|INFO|ETHER2?|GROUP|BOOTP|MUUTA[0-9]|TYPE|SERIAL|PCTCP)$/) { print STDERR "$filename($.): unsupported RR type '$type'\n"; @@ -152,6 +152,7 @@ sub process_zonefile($$$$) { WKS => [], CAA => [], DS => [], + SSHFP => [], RP => [], SRV => [], @@ -243,6 +244,11 @@ sub process_zonefile($$$$) { unless ($line[0]=~/^[01]$/ && $line[1]=~/^[a-zA-Z0-9]+$/ && $line[2] ne ''); push @{$rec->{CAA}}, "$line[0] $line[1] $line[2]"; } + elsif ($type eq 'SSHFP') { + fatal("$filename($.): invalid SSHFP record: $fline") + unless ($line[0]=~/^\d+$/ && $line[1]=~/^\d+$/ && $line[2]=~/^[0-9a-f]+$/); + push @{$rec->{SSHFP}}, "$line[0] $line[1] $line[2]"; + } elsif ($type eq 'DS') { fatal("$filename($.): invalid DS record: $fline") unless ($line[0]=~/^\d+$/ && $line[1]=~/^\d+$/ && $line[2]=~/^\d+$/ && $line[3]=~/^[0-9A-Fa-f]+$/); @@ -365,7 +371,7 @@ sub process_zonedns($$$$) { $ttl = $rr->ttl; next unless ($class eq 'IN'); - unless ($type =~ /^(SOA|A|PTR|CNAME|MX|NS|TXT|HINFO|SRV|WKS|CAA|DS)$/) { + unless ($type =~ /^(SOA|A|PTR|CNAME|MX|NS|TXT|HINFO|SRV|WKS|CAA|DS|SSHFP)$/) { $ucount++; print "Skipping: " . $rr->string . "\n" if ($verbose); next; @@ -384,6 +390,7 @@ sub process_zonedns($$$$) { TXT => [], HINFO => ['',''], CAA => [], + SSHFP => [], DS => [], WKS => [], SRV => [] @@ -430,6 +437,9 @@ sub process_zonedns($$$$) { elsif ($type eq 'CAA') { push @{$rec->{CAA}}, join(" ",($rr->flags,$rr->tag,$rr->value)); } + elsif ($type eq 'SSHFP') { + push @{$rec->{SSHFP}}, join(" ",($rr->flags,$rr->tag,$rr->value)); + } elsif ($type eq 'DS') { push @{$rec->{DS}}, join(" ",($rr->keytag,$rr->algorithm,$rr->digtype,$rr->digest)); } diff --git a/import-zone b/import-zone index f13d472..7621a21 100755 --- a/import-zone +++ b/import-zone @@ -258,6 +258,10 @@ foreach $host (sort keys %zonedata) { for $k (0..$#{$rec->{SRV}}) { push @srv_l, [0,split(' ', $rec->{SRV}->[$k]),'']; } + undef @sshfp_l; + for $k (0..$#{$rec->{SSHFP}}) { + push @sshfp_l, [0,split(' ', $rec->{SSHFP}->[$k]),'']; + } $res = add_host({zone=>$zoneid, type=>$hosttype, @@ -272,6 +276,7 @@ foreach $host (sort keys %zonedata) { txt_l=>\@txt_l, ns_l=>\@ns_l, srv_l=>\@srv_l, + sshfp_l=>\@sshfp_l, ip=>\@ip_l });