2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-30 17:46:38 +00:00

Merge pull request #5025 from chenglch/check_cons

Check if cons script is excutable before register into console server
This commit is contained in:
zet809 2018-03-28 15:57:45 +08:00 committed by GitHub
commit 9220422ed7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 0 deletions

View File

@ -192,6 +192,10 @@ sub init_local_console {
unless ($_->{cons}) {
$_->{cons} = $_->{mgt};
}
if ( $_->{cons} ne 'openbmc' && ! -x $::XCATROOT . "/share/xcat/cons/".$_->{cons}) {
xCAT::MsgUtils->message("S", $_->{node} .": ignore, ". $::XCATROOT . "/share/xcat/cons/".$_->{cons}." is not excutable. Please check mgt or cons attribute.");
next;
}
if ($_->{conserver} && exists($iphash{ $_->{conserver} })) {
$cons_map{ $_->{node} } = $_;
}
@ -406,6 +410,11 @@ sub get_cons_map {
if ($_->{cons} or defined($_->{'serialport'})) {
unless ($_->{cons}) { $_->{cons} = $_->{mgt}; } #populate with fallback
if ($isSN && $_->{conserver} && exists($iphash{ $_->{conserver} }) || !$isSN) {
if ( $_->{cons} ne 'openbmc' && ! -x $::XCATROOT . "/share/xcat/cons/".$_->{cons}) {
$rsp->{data}->[0] = $_->{node} .": ignore, ". $::XCATROOT . "/share/xcat/cons/".$_->{cons}." is not excutable. Please check mgt or cons attribute.";
xCAT::MsgUtils->message("I", $rsp, $::callback);
next;
}
$cons_map{ $_->{node} } = $_; # also put the ref to the entry in a hash for quick look up
} else {
$rsp->{data}->[0] = $_->{node} .": ignore, the host for conserver could not be determined.";

View File

@ -201,6 +201,7 @@ sub preprocess_request {
sub process_request {
my $req = shift;
my $cb = shift;
$::callback = $cb;
if ($req->{command}->[0] eq "makeconservercf") {
if (-x "/usr/bin/goconserver") {
require xCAT::Goconserver;
@ -603,6 +604,10 @@ sub donodeent {
# either there is no console method (shouldnt happen) or not one of the supported terminal servers
return $node;
}
if (!grep(/^$cmeth$/, @cservers) && ! -x $::XCATROOT . "/share/xcat/cons/" . $cmeth) {
xCAT::SvrUtils::sendmsg([ 0, "ignore, ". $::XCATROOT . "/share/xcat/cons/$cmeth is not excutable. Please check mgt or cons attribute." ], $::callback, $node);
next;
}
push @$content, "#xCAT BEGIN $node CONS\n";
push @$content, "console $node {\n";
if (grep(/^$cmeth$/, @cservers)) {