Skip to content

add import SSHFP records #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
14 changes: 12 additions & 2 deletions Sauron/UtilZone.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -152,6 +152,7 @@ sub process_zonefile($$$$) {
WKS => [],
CAA => [],
DS => [],
SSHFP => [],

RP => [],
SRV => [],
Expand Down Expand Up @@ -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]+$/);
Expand Down Expand Up @@ -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;
Expand All @@ -384,6 +390,7 @@ sub process_zonedns($$$$) {
TXT => [],
HINFO => ['',''],
CAA => [],
SSHFP => [],
DS => [],
WKS => [],
SRV => []
Expand Down Expand Up @@ -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));
}
Expand Down
5 changes: 5 additions & 0 deletions import-zone
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
});

Expand Down