mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-27 12:52:16 +00:00
c922dbcf52
xCAT has no attribute that selects the SELinux mode of a node. The site table help does not describe a selinux key, and noderes has no selinux column, so neither the admin nor the provisioning code can set a mode per site, group or node. selinux_schema.t loads xCAT::Schema and checks the noderes.selinux column, its description, the node and group object attribute, and the site.selinux help. 18 of its 19 checks fail on this commit. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
52 lines
2.1 KiB
Perl
52 lines
2.1 KiB
Perl
#!/usr/bin/env perl
|
|
use strict;
|
|
use warnings;
|
|
|
|
# Keep modules out of an installed /opt/xcat, so the checkout is what loads.
|
|
BEGIN { $ENV{XCATROOT} = '/nonexistent/xcatroot' }
|
|
|
|
use FindBin;
|
|
use lib "$FindBin::Bin/../../perl-xCAT";
|
|
|
|
use Test::More;
|
|
|
|
use xCAT::Schema;
|
|
|
|
like($INC{'xCAT/Schema.pm'}, qr/\Q$FindBin::Bin\E/,
|
|
'xCAT::Schema comes from this checkout, not from /opt/xcat');
|
|
|
|
# noderes keys on a node or a group name, so one column gives the node and the
|
|
# group settings.
|
|
my $noderes = $xCAT::Schema::tabspec{noderes};
|
|
ok((grep { $_ eq 'selinux' } @{ $noderes->{cols} }),
|
|
'noderes has a selinux column');
|
|
my $coldoc = $noderes->{descriptions}{selinux};
|
|
ok(defined $coldoc, '... and the column has a description');
|
|
like($coldoc // '', qr/\benforcing\b/, '... that names enforcing');
|
|
like($coldoc // '', qr/\bpermissive\b/, '... and permissive');
|
|
like($coldoc // '', qr/\bdisabled\b/, '... and disabled');
|
|
like($coldoc // '', qr/site\.selinux/, '... and says site.selinux is the fallback');
|
|
|
|
foreach my $type (qw(node group)) {
|
|
my @attrs = grep { $_->{attr_name} eq 'selinux' }
|
|
@{ $xCAT::Schema::defspec{$type}{attrs} };
|
|
is(scalar(@attrs), 1, "a $type object has one selinux attribute");
|
|
is($attrs[0] && $attrs[0]{tabentry}, 'noderes.selinux',
|
|
"... and the $type attribute is stored in noderes.selinux");
|
|
is($attrs[0] && $attrs[0]{access_tabentry}, 'noderes.node=attr:node',
|
|
"... and the $type row is found by the node column");
|
|
}
|
|
|
|
my $sitedoc = $xCAT::Schema::tabspec{site}{descriptions}{key};
|
|
my ($selinux_help) = $sitedoc =~ /^( selinux:.*?)(?:\n\n|\z)/ms;
|
|
ok(defined $selinux_help, 'the site table help describes the selinux key');
|
|
like($selinux_help // '', qr/\benforcing\b/, '... with the enforcing value');
|
|
like($selinux_help // '', qr/\bpermissive\b/, '... the permissive value');
|
|
like($selinux_help // '', qr/\bdisabled\b/, '... and the disabled value');
|
|
like($selinux_help // '', qr/not set.*\bdisabled\b/s,
|
|
'... and says an unset key means disabled');
|
|
like($selinux_help // '', qr/noderes\.selinux/,
|
|
'... and names the node and group override');
|
|
|
|
done_testing();
|