From 130c30c7d7b8166e38c30b95b9a19e3745d6240a Mon Sep 17 00:00:00 2001 From: XuWei Date: Wed, 5 Jul 2017 02:39:19 -0400 Subject: [PATCH 1/2] Fix issue 3383, do not allow setting and getting in one command for rspconfig --- xCAT-server/lib/xcat/plugins/ipmi.pm | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index 859283636..d37193ff3 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -8076,11 +8076,37 @@ sub preprocess_request { xCAT::Utils->filter_nodes($request, undef, undef, \@bmcnodes, \@nohandle); $realnoderange = \@bmcnodes; } elsif ($command eq "rspconfig") { - # filter out the nodes which should be handled by ipmi.pm my (@bmcnodes, @nohandle); xCAT::Utils->filter_nodes($request, undef, undef, \@bmcnodes, \@nohandle); $realnoderange = \@bmcnodes; + + if ($realnoderange) { + my $optset = 0; + my $optget = 0; + foreach (@exargs) { + if ($_ =~ /^(\w+)=(.*)/) { + $optset = 1; + my $option = $1; + unless ($option =~ /^USERID$|^ip$|^netmask$|^gateway$|^vlan$|^userid$|^username$|^password$|^snmpdest|^thermprofile$|^alert$|^garp$|^community$|^backupgateway$/) { + $callback->({ errorcode => [1], data => [ "Unsupported command: $command $option"] }); + $request = {}; + return; + } + } elsif ($_ =~ /^ip$|^netmask$|^gateway$|^vlan$|^userid$|^username$|^password$|^snmpdest|^thermprofile$|^alert$|^garp$|^community$|^backupgateway$/) { + $optget = 1; + } else { + $callback->({ errorcode => [1], data => [ "Unsupported command: $command $_"] }); + $request = {}; + return; + } + } + if ($optset and $optget) { + $callback->({ errorcode => [1], data => [ "Do not set and get information in the same command for $command."] }); + $request = {}; + return; + } + } } elsif ($command eq "rinv") { if ($exargs[0] eq "-t" and $#exargs == 0) { unshift @{ $request->{arg} }, 'all'; From f883d51ae54f797c5707eea7479c639bed063f68 Mon Sep 17 00:00:00 2001 From: XuWei Date: Wed, 5 Jul 2017 21:15:23 -0400 Subject: [PATCH 2/2] modified depending on comments --- xCAT-server/lib/xcat/plugins/ipmi.pm | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/ipmi.pm b/xCAT-server/lib/xcat/plugins/ipmi.pm index d37193ff3..9f66bc523 100644 --- a/xCAT-server/lib/xcat/plugins/ipmi.pm +++ b/xCAT-server/lib/xcat/plugins/ipmi.pm @@ -8082,30 +8082,32 @@ sub preprocess_request { $realnoderange = \@bmcnodes; if ($realnoderange) { - my $optset = 0; - my $optget = 0; + my $optset; + my $option; foreach (@exargs) { if ($_ =~ /^(\w+)=(.*)/) { - $optset = 1; - my $option = $1; - unless ($option =~ /^USERID$|^ip$|^netmask$|^gateway$|^vlan$|^userid$|^username$|^password$|^snmpdest|^thermprofile$|^alert$|^garp$|^community$|^backupgateway$/) { - $callback->({ errorcode => [1], data => [ "Unsupported command: $command $option"] }); + if ($optset eq 0) { + $callback->({ errorcode => [1], data => [ "Usage Error: Cannot display and change attributes on the same command."] }); $request = {}; return; } - } elsif ($_ =~ /^ip$|^netmask$|^gateway$|^vlan$|^userid$|^username$|^password$|^snmpdest|^thermprofile$|^alert$|^garp$|^community$|^backupgateway$/) { - $optget = 1; + $optset = 1; + $option = $1; } else { + if ($optset eq 1) { + $callback->({ errorcode => [1], data => [ "Usage Error: Cannot display and change attributes on the same command."] }); + $request = {}; + return; + } + $option = $_; + $optset = 0; + } + unless ($option =~ /^USERID$|^ip$|^netmask$|^gateway$|^vlan$|^userid$|^username$|^password$|^snmpdest|^thermprofile$|^alert$|^garp$|^community$|^backupgateway$/) { $callback->({ errorcode => [1], data => [ "Unsupported command: $command $_"] }); $request = {}; return; } } - if ($optset and $optget) { - $callback->({ errorcode => [1], data => [ "Do not set and get information in the same command for $command."] }); - $request = {}; - return; - } } } elsif ($command eq "rinv") { if ($exargs[0] eq "-t" and $#exargs == 0) {