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

fix(genesis): limit s390x boot to validated path

This commit is contained in:
Vinícius Ferrão
2026-09-04 15:31:33 -03:00
parent 77ada41319
commit a1e9948997
4 changed files with 7 additions and 40 deletions
-12
View File
@@ -134,14 +134,6 @@ sub kea_s390x_network_classes {
],
};
}
if ( $opts{dpm_config_present} ) {
push @classes, {
name => "xcat-s390x-dpm-$safe_network",
test => 'option[93].hex == 0x0020',
additional_only => 1,
'boot-file-name' => "pxelinux.cfg/s390x/$network_id.dpm",
};
}
return \@classes;
}
@@ -197,10 +189,6 @@ sub isc_client_architecture_lines {
" option path-prefix = \"pxelinux.cfg/s390x/\";\n",
" option conf-file = \"${net}_${maskbits}\";\n",
) : ()),
($opts{s390x_dpm_config_present} ? (
" } else if option client-architecture = 00:20 { #IBM Z DPM\n ",
" filename \"pxelinux.cfg/s390x/${net}_${maskbits}.dpm\";\n",
) : ()),
" } else if option client-architecture = 00:0e { #OPAL-v3\n ",
" option conf-file = \"http://$tftp$portsuffix/tftpboot/pxelinux.cfg/p/${net}_${maskbits}\";\n",
" } else if substring (option vendor-class-identifier,0,11) = \"onie_vendor\" { #for onie on cumulus switch\n",
@@ -345,11 +345,7 @@ void xcat_load_console_state(struct console_state *state) {
xcat_set_text(state->architecture, sizeof(state->architecture), "unknown");
xcat_set_text(state->kernel, sizeof(state->kernel), "unknown");
}
snprintf(path, sizeof(path), "%s/sysinfo", proc_root);
s390_system = strcmp(state->architecture, "s390x") == 0 ||
access(path, F_OK) == 0;
if (s390_system)
xcat_set_text(state->architecture, sizeof(state->architecture), "s390x");
s390_system = strcmp(state->architecture, "s390x") == 0;
s390_ccw_boot = s390_system &&
xcat_cmdline_value(cmdline_text, "xcat.bootloader", value,
-3
View File
@@ -3371,7 +3371,6 @@ sub kea_subnet4_intent
net => $net,
prefix => $prefix,
qemu_config_present => -f "$tftpdir/pxelinux.cfg/s390x/${net}_${prefix}",
dpm_config_present => -f "$tftpdir/pxelinux.cfg/s390x/${net}_${prefix}.dpm",
)
};
if (@client_classes) {
@@ -4538,8 +4537,6 @@ sub addnet
prefix => $maskbits,
s390x_qemu_config_present =>
-f "$tftpdir/pxelinux.cfg/s390x/${net}_${maskbits}",
s390x_dpm_config_present =>
-f "$tftpdir/pxelinux.cfg/s390x/${net}_${maskbits}.dpm",
) };
if ($range) {
+6 -20
View File
@@ -762,13 +762,9 @@ sub process_request {
if ($arch =~ /ppc/ and -r "$tftpdir/pxelinux.cfg/p/$net") {
unlink("$tftpdir/pxelinux.cfg/p/$net");
} elsif ($arch eq 's390x') {
foreach my $path (
"$tftpdir/pxelinux.cfg/s390x/$net",
"$tftpdir/pxelinux.cfg/s390x/$net.dpm",
) {
if (_is_generated_s390x_config($path)) {
unlink $path;
}
my $path = "$tftpdir/pxelinux.cfg/s390x/$net";
if (_is_generated_s390x_config($path)) {
unlink $path;
}
}
next;
@@ -933,24 +929,14 @@ sub _write_s390x_discovery_config {
my $error = _write_s390x_config($qemu_path, $qemu_config);
return (undef, $error) if $error;
my $dpm_path = "$qemu_path.dpm";
my $dpm_config = "# pxelinux.cfg xCAT Genesis s390x\n"
. "DEFAULT xCAT\n"
. "label xCAT\n"
. " kernel=xcat/genesis.kernel.s390x\n"
. " initrd=$initrd\n"
. " append=$cmdline\n";
$error = _write_s390x_config($dpm_path, $dpm_config);
if ($error) {
unlink $qemu_path;
return (undef, $error);
}
return ($qemu_path, undef);
}
sub _write_s390x_config {
my ($path, $contents) = @_;
if (-f $path && !_is_generated_s390x_config($path)) {
return "Refusing to replace unmanaged s390x configuration: $path";
}
my $config;
if (!open $config, '>', $path) {
my $open_error = $OS_ERROR;