2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-08-28 09:36:40 +00:00

fix(xcatd): stop a noderange from running a command through the ^ operator

The ^ noderange operator reads node names from a file. NodeRange opened
that file with a two-argument open. A two-argument open reads shell
metacharacters in the path, so a noderange such as ^"id|" ran a command.
xcatd expands a noderange while it processes a request, so the command
ran on the management node.

Use a three-argument open with an explicit read mode. The value is then
only ever a file name. The ^ operator keeps working: ^/tmp/nodes still
reads the file.

This fix was recovered from the lenovobuild branch. The original there
(commit for "Remove load from file in noderange support") removed the ^
operator. This keeps the documented operator and closes the command path
instead.
This commit is contained in:
Vinícius Ferrão
2026-08-17 12:24:20 -03:00
parent 875a6ef40d
commit e3e132967c
+4 -3
View File
@@ -678,8 +678,9 @@ sub noderange {
if ($atom eq '') { next; }
if ($atom =~ /^\^(.*)$/) { # get a list of nodes from a file
open(NRF, $1);
while (<NRF>) {
my $nrfile = $1;
open(my $nrf, '<', $nrfile) or next;
while (<$nrf>) {
my $line = $_;
unless ($line =~ m/^[\^#]/) {
$line =~ m/^([^: ]*)/;
@@ -692,7 +693,7 @@ sub noderange {
}
}
}
close(NRF);
close($nrf);
next;
}