From 1616e26c948da318a6f0bbfe33743ecc582f16aa Mon Sep 17 00:00:00 2001 From: leiaibj Date: Fri, 8 Feb 2013 01:57:33 +0000 Subject: [PATCH] Fix a bug for hostname validation, merge into 2.8 branch git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.8@15108 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/NetworkUtils.pm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/perl-xCAT/xCAT/NetworkUtils.pm b/perl-xCAT/xCAT/NetworkUtils.pm index d2b45b953..6f65ea2e2 100755 --- a/perl-xCAT/xCAT/NetworkUtils.pm +++ b/perl-xCAT/xCAT/NetworkUtils.pm @@ -2186,12 +2186,17 @@ sub isValidMAC sub isValidHostname { my ($class, $hostname) = @_; - if ($hostname =~ /^[a-z0-9][\-a-z0-9]+[a-z0-9]$/){ - return 1; + if ($hostname =~ /^[a-z0-9]/){ + if ($hostname =~ /[a-z0-9]$/){ + if ($hostname =~ /[\-a-z0-9]+/){ + return 1; + } + } } return 0; } + #------------------------------------------------------------------------------- =head3 isValidFQDN