From 9c69cb198a7a8b03f08117fdedcdfd4f288cc08c Mon Sep 17 00:00:00 2001 From: leiaibj Date: Fri, 8 Feb 2013 01:56:46 +0000 Subject: [PATCH] Fix a bug for hostname valiation pattern git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@15107 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/NetworkUtils.pm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/perl-xCAT/xCAT/NetworkUtils.pm b/perl-xCAT/xCAT/NetworkUtils.pm index d2b45b953..1020310ba 100755 --- a/perl-xCAT/xCAT/NetworkUtils.pm +++ b/perl-xCAT/xCAT/NetworkUtils.pm @@ -2186,8 +2186,12 @@ 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; }