2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2026-11-19 17:02:15 +00:00
Files
xcat-core/xCAT-test/unit/netboot_xcatroot_executable.t
T
Daniel Hilst bb3bae0a48 test(xcat-core): catch a netboot handler that is not executable
dracut dispatches the network root in 45net-lib/netroot.sh with
handler=$(command -v "${netroot%%:*}root"). command -v skips a file
without the execute bit, so an xcatroot shipped mode 0644 makes the node
print "No handler for netroot type 'xcat'" and power off in its
initramfs. genimage copies the file with the mode it reads from the share
tree, and dracut's inst_script keeps that mode, so the mode in the
repository is what reaches the node.

The new test asserts the execute bit on every xcatroot under
xCAT-server/share/xcat/netboot and xCAT-genesis-base. It fails on the
current tree, on
xCAT-server/share/xcat/netboot/rh/dracut_105/stateless/xcatroot.

Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
2026-10-26 15:27:20 -03:00

37 lines
1.3 KiB
Perl

#!/usr/bin/env perl
# Every xcatroot xCAT ships must carry the execute bit.
#
# dracut dispatches the network root through 45net-lib/netroot.sh, which does
# handler=$(command -v "${netroot%%:*}root"). command -v skips a file without
# the execute bit, so a non-executable xcatroot makes netroot.sh print
# "No handler for netroot type 'xcat'" and the node powers off in its
# initramfs. genimage copies the file with the mode it finds in the share tree
# (chmod($perm & 07777)), and dracut's inst_script keeps that mode, so the mode
# in the repository is what reaches the initramfs.
use strict;
use warnings;
use File::Basename qw(dirname);
use File::Find qw(find);
use File::Spec;
use Test::More;
my $root = File::Spec->rel2abs(File::Spec->catdir(dirname(__FILE__), '..', '..'));
my @trees = grep { -d } map { File::Spec->catdir($root, $_) }
('xCAT-server/share/xcat/netboot', 'xCAT-genesis-base');
die "no netboot tree under $root" unless @trees;
my @handlers;
find(sub { push @handlers, $File::Find::name if $_ eq 'xcatroot' && -f $_ }, @trees);
# A positive control: an empty list would pass every assertion below.
cmp_ok(scalar(@handlers), '>=', 5, scalar(@handlers) . ' xcatroot handlers found');
for my $handler (sort @handlers) {
ok(-x $handler, File::Spec->abs2rel($handler, $root) . ' is executable');
}
done_testing();