From b61ff287399847ff1e3353303a50dc09f8d585f4 Mon Sep 17 00:00:00 2001 From: leiaibj Date: Mon, 19 Nov 2012 09:03:03 +0000 Subject: [PATCH] Create FQDN verify while createing a unmanaged node git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14359 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/NetworkUtils.pm | 20 +++++++++++++++++++ xCAT-server/lib/xcat/plugins/profilednodes.pm | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/NetworkUtils.pm b/perl-xCAT/xCAT/NetworkUtils.pm index 339b6add4..2a115b26d 100755 --- a/perl-xCAT/xCAT/NetworkUtils.pm +++ b/perl-xCAT/xCAT/NetworkUtils.pm @@ -2211,6 +2211,26 @@ sub isValidHostname return 0; } +#------------------------------------------------------------------------------- + +=head3 isValidFQDN + Description : Validate whether specified string is a valid FQDN. + Arguments : hostname - the string to be validated. + Returns : 1 - valid hostname FQDN. + 0 - invalid hostname FQDN. +=cut + +#------------------------------------------------------------------------------- +sub isValidFQDN +{ + my ($class, $hostname) = @_; + if ($hostname =~ /^[\-\.a-zA-Z0-9]+$/){ + return 1; + } + return 0; +} + + #------------------------------------------------------------------------------- =head3 ip_to_int diff --git a/xCAT-server/lib/xcat/plugins/profilednodes.pm b/xCAT-server/lib/xcat/plugins/profilednodes.pm index e2d221e6f..574400262 100644 --- a/xCAT-server/lib/xcat/plugins/profilednodes.pm +++ b/xCAT-server/lib/xcat/plugins/profilednodes.pm @@ -603,7 +603,7 @@ Usage: setrsp_errormsg("Specified hostname $args_dict{'hostname'} conflicts with records in database"); return; } - if (! xCAT::NetworkUtils->isValidHostname($args_dict{'hostname'})){ + if (! xCAT::NetworkUtils->isValidFQDN($args_dict{'hostname'})){ setrsp_errormsg("Specified hostname: $args_dict{'hostname'} is invalid"); return; }