2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-06-17 11:50:32 +00:00

Merge pull request #1762 from bybai/makedns_1

fix issue 1553 makedns failed when input invalid hostname into /etc/h…
This commit is contained in:
Xiaopeng Wang
2016-09-02 18:08:42 +08:00
committed by GitHub

View File

@ -423,6 +423,8 @@ sub process_request {
my $names;
my @hosts;
my %nodehash;
my @eachhost;
my $invalid;
foreach (@contents) {
chomp; #no newline
@ -439,6 +441,18 @@ sub process_request {
xCAT::SvrUtils::sendmsg(":Ignoring line $_ in /etc/hosts, names $names contain invalid characters (valid characters include a through z, numbers and the '-', but not '_'", $callback);
next;
}
$invalid = "";
@eachhost = split(/ /,$names);
foreach my $hname (@eachhost) {
if ($hname =~ /^\./) {
xCAT::SvrUtils::sendmsg(":Ignoring line $_ in /etc/hosts, name $hname start with . ", $callback);
$invalid = $names;
last;
}
}
if ($invalid) {
next;
}
my ($host, $ip) = xCAT::NetworkUtils->gethostnameandip($addr);
push @hosts, $host;