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; }