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

fix(mknb): reject incomplete exports

This commit is contained in:
Vinícius Ferrão
2026-08-11 20:18:27 -03:00
parent 8f837f2839
commit 8f2c508950
2 changed files with 54 additions and 3 deletions
+23 -1
View File
@@ -38,12 +38,27 @@ sub _select_network_addresses {
return (\%legacy, \%selected);
}
sub _prebuilt_genesis_requested {
sub _genesis_export_manifest_present {
my ($directory) = @_;
my $manifest = "$directory/$GENESIS_EXPORT_MANIFEST";
return -e $manifest || -l $manifest;
}
sub _prebuilt_genesis_requested {
my ($directory) = @_;
foreach my $name (
$GENESIS_EXPORT_MANIFEST,
'kernel',
'initramfs.cpio.gz',
'SHA256SUMS'
)
{
my $path = "$directory/$name";
return 0 unless -e $path || -l $path;
}
return 1;
}
sub _validate_prebuilt_genesis_manifest {
my ($directory, $arch) = @_;
my $manifest = "$directory/$GENESIS_EXPORT_MANIFEST";
@@ -353,6 +368,13 @@ sub process_request {
$invisibletouch = 1;
goto CREAT_CONF_FILE;
}
if (_genesis_export_manifest_present($genesis_dir)) {
$callback->({
error => ["Incomplete Genesis export: $genesis_dir"],
errorcode => [1],
});
return;
}
# Grab all the standard ssh public keys we can
my @ssh_pub_keys = ();
if (-r "/root/.ssh/id_rsa.pub") {
+31 -2
View File
@@ -158,8 +158,12 @@ write_file(
export_manifest('x86_64'),
);
ok(
xCAT_plugin::mknb::_prebuilt_genesis_requested($partial_export),
'a partial export still selects the prebuilt path',
!xCAT_plugin::mknb::_prebuilt_genesis_requested($partial_export),
'a partial export does not satisfy the prebuilt layout',
);
ok(
xCAT_plugin::mknb::_genesis_export_manifest_present($partial_export),
'a partial export still declares the new format',
);
(undef, $install_error) = xCAT_plugin::mknb::_install_prebuilt_genesis(
$partial_export, $tftpdir, 'x86_64'
@@ -303,4 +307,29 @@ ok(
'mknb writes boot configuration after publishing the export',
);
unlink("$process_export/SHA256SUMS");
@responses = ();
xCAT_plugin::mknb::process_request(
{ arg => ['ppc64'] },
sub { push(@responses, @_); },
);
ok(
grep(
{ ref($_) eq 'HASH' && $_->{error}
&& $_->{error}->[0] =~ /Incomplete Genesis export/ }
@responses
),
'mknb rejects an incomplete marked export',
);
is(
read_file($process_kernel),
'process kernel',
'an incomplete marked export keeps the published kernel',
);
is(
read_file($process_initramfs),
'process initramfs',
'an incomplete marked export keeps the published initramfs',
);
done_testing();