Skip to content

Commit

Permalink
aii-dhcp: support optional hostname ip verification
Browse files Browse the repository at this point in the history
  • Loading branch information
stdweird committed May 25, 2021
1 parent 85241ca commit b94cb6d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions aii-dhcp/src/main/pan/quattor/aii/dhcp/schema.pan
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,6 @@ type structure_dhcp_dhcp_info = {
the value you specify in templates.
}
"options" ? string{}
@{Verify hostname in DNS}
"verifyhostname" ? boolean
};
18 changes: 17 additions & 1 deletion aii-dhcp/src/main/perl/dhcp.pm
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,9 @@ sub Configure

my $tree = $config->getElement("/system/network")->getTree();
my $fqdn = $tree->{hostname} . "." . $tree->{domainname};

my $opts = $config->getElement("/system/aii/dhcp")->getTree();

# Find the bootable interface
my $cards = $config->getElement("/hardware/cards/nic")->getTree();
my $bootable = undef;
Expand All @@ -310,14 +313,27 @@ sub Configure
}
my $ip = $self->get_ip($bootable, $tree);

if ($opts->{verifyhostname}) {
my $fqdn_ip = gethostbyname($fqdn);
$fqdn_ip = inet_ntoa($fqdn_ip) if defined($fqdn_ip);
if (defined($fqdn_ip)) {
if ($fqdn_ip ne $ip) {
$self->error("aii-dhcp: fqdn $fqdn ip $fqdn_ip does not match configured ip $ip");
}
} else {
$self->error("aii-dhcp: failed to obtain IP address for fqdn $fqdn");
return;
}
}


my $server_ip = gethostbyname(hostname());
$server_ip = inet_ntoa($server_ip) if defined($server_ip);
if (!defined($server_ip)) {
$self->error("aii-dhcp: failed to obtain own IP address");
return;
}

my $opts = $config->getElement("/system/aii/dhcp")->getTree();
my $tftpserver = "";
my $filename = "";
my $additional = "";
Expand Down

0 comments on commit b94cb6d

Please sign in to comment.