mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-21 18:02:18 +00:00
test(xcat-core): no case measures SELinux on a service node or a statelite node
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>
This commit is contained in:
@@ -5,3 +5,6 @@ selinux_restapi_avc
|
||||
selinux_cn_diskful_enforcing
|
||||
selinux_cn_diskless_disabled_by_design
|
||||
selinux_cn_diskless_site_disabled
|
||||
selinux_sn_enforcing
|
||||
selinux_sn_per_node_switch
|
||||
selinux_cn_statelite_disabled_by_design
|
||||
|
||||
@@ -104,3 +104,95 @@ cmd:sh -c 'chtab key=selinux site.value="$(cat /tmp/selinux_site.orig)"'
|
||||
check:rc==0
|
||||
cmd:rm -f /tmp/selinux_site.orig
|
||||
end
|
||||
|
||||
start:selinux_sn_enforcing
|
||||
description:in a hierarchical cluster, the service node runs SELinux enforcing with the xCAT labels in place and no xCAT denial since boot
|
||||
label:selinux,sn_diskful
|
||||
os:rhels
|
||||
cmd:getenforce
|
||||
check:rc==0
|
||||
check:output=~^Enforcing$
|
||||
cmd:xdsh $$SN getenforce
|
||||
check:rc==0
|
||||
check:output=~Enforcing
|
||||
cmd:xdsh $$SN cat /proc/cmdline
|
||||
check:rc==0
|
||||
check:output!~selinux=0
|
||||
cmd:xdsh $$SN "rpm -q xCAT-selinux"
|
||||
check:rc==0
|
||||
cmd:xdsh $$SN "semodule -l | grep -x -E 'xcat([[:space:]].*)?'"
|
||||
check:rc==0
|
||||
cmd:xdsh $$SN "ls -dZ /install /tftpboot /opt/xcat /xcatpost"
|
||||
check:rc==0
|
||||
check:output!~unlabeled_t
|
||||
check:output!~default_t
|
||||
cmd:xdsh $$SN "restorecon -Rnv /xcatpost /opt/xcat /etc/xcat /var/log/xcat"
|
||||
check:rc==0
|
||||
check:output!~Would relabel
|
||||
cmd:xdsh $$SN "systemctl is-active xcatd"
|
||||
check:rc==0
|
||||
check:output=~active
|
||||
cmd:xdcp $$SN /opt/xcat/share/xcat/tools/autotest/testcase/commoncmd/selinux_avc_check.sh /tmp/
|
||||
check:rc==0
|
||||
cmd:xdsh $$SN "sh /tmp/selinux_avc_check.sh boot"
|
||||
check:rc==0
|
||||
check:output=~XCAT_AVC=0
|
||||
cmd:xdsh $$SN "rm -f /tmp/selinux_avc_check.sh"
|
||||
check:rc==0
|
||||
end
|
||||
|
||||
start:selinux_sn_per_node_switch
|
||||
description:noderes.selinux on one service node decides the SELinux mode its installer configures, without touching the rest of the cluster
|
||||
label:selinux,sn_diskful
|
||||
os:rhels
|
||||
cmd:sh -c 'lsdef -t node -o $$SN -i selinux -c > /tmp/selinux_sn_switch.orig'
|
||||
check:rc==0
|
||||
cmd:chdef -t node -o $$SN selinux=disabled
|
||||
check:rc==0
|
||||
cmd:nodeset $$SN osimage=__GETNODEATTR($$SN,os)__-__GETNODEATTR($$SN,arch)__-install-service
|
||||
check:rc==0
|
||||
cmd:grep -E "^selinux --" /install/autoinst/$$SN
|
||||
check:rc==0
|
||||
check:output=~disabled
|
||||
cmd:chdef -t node -o $$SN selinux=enforcing
|
||||
check:rc==0
|
||||
cmd:nodeset $$SN osimage=__GETNODEATTR($$SN,os)__-__GETNODEATTR($$SN,arch)__-install-service
|
||||
check:rc==0
|
||||
cmd:grep -E "^selinux --" /install/autoinst/$$SN
|
||||
check:rc==0
|
||||
check:output=~enforcing
|
||||
cmd:grep -c restorecon /install/autoinst/$$SN
|
||||
check:rc==0
|
||||
check:output!~^0$
|
||||
cmd:chdef -t node -o $$CN selinux=permissive
|
||||
check:rc==0
|
||||
cmd:nodeset $$SN osimage=__GETNODEATTR($$SN,os)__-__GETNODEATTR($$SN,arch)__-install-service
|
||||
check:rc==0
|
||||
cmd:grep -E "^selinux --" /install/autoinst/$$SN
|
||||
check:rc==0
|
||||
check:output=~enforcing
|
||||
cmd:chdef -t node -o $$CN selinux=
|
||||
check:rc==0
|
||||
cmd:sh -c 'chdef -z < /tmp/selinux_sn_switch.orig'
|
||||
check:rc==0
|
||||
cmd:rm -f /tmp/selinux_sn_switch.orig
|
||||
end
|
||||
|
||||
start:selinux_cn_statelite_disabled_by_design
|
||||
description:a statelite compute node asked for SELinux enforcing gets selinux=0, because its root is assembled from read-only mounts, and nodeset says so
|
||||
label:selinux,provision
|
||||
os:rhels
|
||||
cmd:getenforce
|
||||
check:rc==0
|
||||
check:output=~^Enforcing$
|
||||
cmd:chdef -t node -o $$CN selinux=enforcing
|
||||
check:rc==0
|
||||
cmd:nodeset $$CN osimage=$$STATELITE
|
||||
check:rc==0
|
||||
check:output=~SELinux is disabled
|
||||
cmd:sh -c 'grep -rh "selinux=0" /tftpboot/xcat/xnba/nodes/$$CN /tftpboot/pxelinux.cfg/$$CN /tftpboot/petitboot/$$CN 2>/dev/null | wc -l'
|
||||
check:rc==0
|
||||
check:output!~^0$
|
||||
cmd:chdef -t node -o $$CN selinux=
|
||||
check:rc==0
|
||||
end
|
||||
|
||||
@@ -30,8 +30,9 @@ 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_/;
|
||||
ok(!$mn{$case}, "$case needs a compute node, so the management node bundle leaves it out");
|
||||
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();
|
||||
|
||||
Reference in New Issue
Block a user