mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-21 01:42:15 +00:00
cec69be3d2
The selinux cases cover the management node and a compute node. A hierarchical cluster has a service node, which installs xCAT itself and serves /install and /tftpboot to its own nodes, and nothing measured it under SELinux. A statelite node was not measured either, although node_modes resolves it to disabled on purpose. selinux_sn_enforcing reads the provisioned service node: getenforce, the kernel command line, the xcat policy module, the labels of /install, /tftpboot, /opt/xcat and /xcatpost, a restorecon dry run that must find nothing to relabel, xcatd active, and no xCAT denial since boot. selinux_sn_per_node_switch sets noderes.selinux on the service node and reads the mode out of the kickstart that nodeset writes for it, in all three directions, and checks that a value on the compute node does not reach the service node. selinux_cn_statelite_disabled_by_design asks for enforcing on a statelite node and requires selinux=0 on its boot configuration, with nodeset saying why. selinux_bundle.t now keeps a service-node case out of the management-node bundle, the same way it keeps a compute-node case out. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
39 lines
1.3 KiB
Perl
39 lines
1.3 KiB
Perl
#!/usr/bin/env perl
|
|
use strict;
|
|
use warnings;
|
|
|
|
use FindBin;
|
|
use File::Slurper qw(read_lines);
|
|
use Test::More;
|
|
|
|
# A case that no bundle names is a case no run selects. The six SELinux cases were in no
|
|
# bundle and in no pipeline conf, so none of them had ever run, and eight checks that
|
|
# could never pass went unnoticed for that reason.
|
|
my $root = "$FindBin::Bin/../..";
|
|
my $dir = "$root/xCAT-test/autotest/testcase/selinux";
|
|
|
|
my @cases;
|
|
foreach my $file (sort glob("$dir/cases*")) {
|
|
push @cases, map { /^start:(\S+)/ ? $1 : () } read_lines($file);
|
|
}
|
|
ok(scalar(@cases) >= 6, "the selinux testcase files declare @{[scalar @cases]} cases");
|
|
|
|
my %bundled;
|
|
foreach my $bundle (sort glob("$root/xCAT-test/autotest/bundle/*.bundle")) {
|
|
$bundled{$_} = 1 for grep { /\S/ } read_lines($bundle);
|
|
}
|
|
ok(scalar(keys %bundled) > 100, "the bundles name @{[scalar keys %bundled]} cases in total");
|
|
|
|
my @orphans = grep { !$bundled{$_} } @cases;
|
|
is_deeply(\@orphans, [], 'every selinux case is named by a bundle');
|
|
|
|
my @mn = grep { /\S/ } read_lines("$root/xCAT-test/autotest/bundle/selinux_mn.bundle");
|
|
my %mn = map { $_ => 1 } @mn;
|
|
foreach my $case (@cases) {
|
|
next unless $case =~ /_(cn|sn)_/;
|
|
my $needs = $1 eq 'cn' ? 'a compute node' : 'a service node';
|
|
ok(!$mn{$case}, "$case needs $needs, so the management node bundle leaves it out");
|
|
}
|
|
|
|
done_testing();
|