From dceba492cb40c4ec7112859967f5a0cda625e8d4 Mon Sep 17 00:00:00 2001 From: ligc Date: Wed, 18 May 2011 01:31:14 +0000 Subject: [PATCH] fix for bug 3219819: do not add hosts into /etc/hosts if the ip field is not an ip git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@9625 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/hosts.pm | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/hosts.pm b/xCAT-server/lib/xcat/plugins/hosts.pm index 9552090da..a2eb58692 100644 --- a/xCAT-server/lib/xcat/plugins/hosts.pm +++ b/xCAT-server/lib/xcat/plugins/hosts.pm @@ -225,10 +225,12 @@ sub process_request { if ($DELNODE) { delnode $ref->{node},$ref->{ip},$ref->{hostnames},$domain; } else { - addnode $ref->{node},$ref->{ip},$ref->{hostnames},$domain; - if (defined($ref->{otherinterfaces})){ - addotherinterfaces $ref->{node},$ref->{otherinterfaces},$domain; - } + if ( xCAT::Utils->isIpaddr($ref->{ip}) ) { + addnode $ref->{node},$ref->{ip},$ref->{hostnames},$domain; + if (defined($ref->{otherinterfaces})){ + addotherinterfaces $ref->{node},$ref->{otherinterfaces},$domain; + } + } } } #end foreach } # end else @@ -238,10 +240,12 @@ sub process_request { } my @hostents = $hoststab->getAllNodeAttribs(['ip','node','hostnames','otherinterfaces']); foreach (@hostents) { - addnode $_->{node},$_->{ip},$_->{hostnames},$domain; - if (defined($_->{otherinterfaces})){ - addotherinterfaces $_->{node},$_->{otherinterfaces},$domain; - } + if ( xCAT::Utils->isIpaddr($_->{ip}) ) { + addnode $_->{node},$_->{ip},$_->{hostnames},$domain; + if (defined($_->{otherinterfaces})){ + addotherinterfaces $_->{node},$_->{otherinterfaces},$domain; + } + } } } writeout();