From 3e57820ee6f6a68edb02fc790f7887c8a8e9dd20 Mon Sep 17 00:00:00 2001 From: wangxiaopeng Date: Fri, 24 Jun 2016 02:02:50 -0400 Subject: [PATCH] issue 1361: check the export sentence in the mypostscript to make sure no - is used in the variable name --- xCAT-server/lib/perl/xCAT/Postage.pm | 21 ++++++++++++++++++++- xCAT-server/lib/xcat/plugins/updatenode.pm | 2 +- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/Postage.pm b/xCAT-server/lib/perl/xCAT/Postage.pm index 6fac85cb1..46c1b93a3 100644 --- a/xCAT-server/lib/perl/xCAT/Postage.pm +++ b/xCAT-server/lib/perl/xCAT/Postage.pm @@ -570,6 +570,7 @@ sub makescript { # This line only is used to compatible with the old code $inc =~ s/#Subroutine:([^:]+)::([^:]+)::([^:]+):([^#]+)#/runsubroutine($1,$2,$3,$4)/eg; + # we will create a file in /tftboot/mypostscript/mypostscript_ if ((!defined($nofiles)) || ($nofiles == 0)) { # my $script; @@ -596,7 +597,25 @@ sub makescript { close($script_fp{$node}); # TODO remove the blank lines } - + + # Check the validity of new generated mypostscirpt + # export does not support - in the environment variable name + my @invalid_var_name; + foreach my $line (split(/\n/, $inc)) { + if ($line =~ /export +(.*)/) { + my $varname = $1; + if ($varname =~ /-/) { + push @invalid_var_name, $varname; + } + } + } + if (@invalid_var_name) { + my $rsp; + push @{$rsp->{data}}, "In your configuration, the invalid charactor '-' is used in the following names: " . join(',', @invalid_var_name); + xCAT::MsgUtils->message("E", $rsp, $callback); + push @::exclude_nodes, $node; + } + } #end foreach node undef(%::GLOBAL_TAB_HASH); diff --git a/xCAT-server/lib/xcat/plugins/updatenode.pm b/xCAT-server/lib/xcat/plugins/updatenode.pm index fdd503bc5..0e0dbe1ae 100644 --- a/xCAT-server/lib/xcat/plugins/updatenode.pm +++ b/xCAT-server/lib/xcat/plugins/updatenode.pm @@ -1242,7 +1242,7 @@ sub updatenode if (@exclude_nodes > 0) { my $rsp = {}; $rsp->{error}->[0] = - "Following nodes will be ignored bacause they are missing some attribute definitions: @exclude_nodes"; + "Following nodes will be ignored bacause they are missing some attributes or have incorrect configuration: @exclude_nodes"; $rsp->{errorcode}->[0] =1; $callback->($rsp); }