mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-11-19 08:52:15 +00:00
fix(xcat-core): an xCAT installation turns off the SELinux policy of the node
xcatconfig set the running system permissive and wrote SELINUX=disabled into /etc/selinux/config on a Red Hat or openEuler management node. The node lost the SELinux policy of the site during the installation, and the log reported only a warning. Every CI cell that declares SELINUX=enforcing ran its test cases permissive for this reason, and two measurements needed setenforce 1 after the install to get an enforcing node. xCAT::SELinux->xcatconfig_action now returns the mode and asks for no change. xcatconfig reports the mode and leaves the running system and /etc/selinux/config alone. A node that already has SELinux off gets no warning, as before. xCAT-test/unit/xcatconfig_selinux_policy.t fails 10 of its 27 checks on the parent commit. Signed-off-by: Daniel Hilst <392820+dhilst@users.noreply.github.com>
This commit is contained in:
+11
-19
@@ -81,17 +81,16 @@ sub config_mode {
|
||||
=head3 xcatconfig_action
|
||||
|
||||
Descriptions:
|
||||
Decides what xcatconfig does about SELinux on this node. The caller
|
||||
makes the changes the answer asks for.
|
||||
Decides what xcatconfig does about SELinux on this node. The answer
|
||||
asks for no change, because the SELinux policy belongs to the site.
|
||||
The caller reports the warning.
|
||||
Arguments:
|
||||
root - a prefix for the paths this module reads.
|
||||
Returns:
|
||||
A hash reference:
|
||||
mode - the mode runtime_mode reports
|
||||
config_mode - the mode config_mode reports
|
||||
warning - a message for the admin, or undef
|
||||
disable - true when xcatconfig must turn SELinux off
|
||||
enforce_file - the selinuxfs file that sets the running mode
|
||||
mode - the mode runtime_mode reports
|
||||
config_mode - the mode config_mode reports
|
||||
warning - a message for the admin, or undef when SELinux is off
|
||||
Example:
|
||||
my $answer = xCAT::SELinux->xcatconfig_action();
|
||||
|
||||
@@ -104,22 +103,15 @@ sub xcatconfig_action {
|
||||
|
||||
my $mode = $class->runtime_mode(root => $root);
|
||||
my %answer = (
|
||||
mode => $mode,
|
||||
config_mode => $class->config_mode(root => $root),
|
||||
warning => undef,
|
||||
disable => 0,
|
||||
enforce_file => undef,
|
||||
mode => $mode,
|
||||
config_mode => $class->config_mode(root => $root),
|
||||
warning => undef,
|
||||
);
|
||||
|
||||
return \%answer if $mode eq 'disabled';
|
||||
|
||||
$answer{warning} = 'SELINUX is not disabled, disabling it now...';
|
||||
$answer{disable} = 1;
|
||||
foreach my $path (@ENFORCE_FILES) {
|
||||
next unless -f "$root$path";
|
||||
$answer{enforce_file} = $path;
|
||||
last;
|
||||
}
|
||||
$answer{warning} =
|
||||
"SELINUX is $mode. xCAT does not change the SELinux mode or $CONFIG_FILE.";
|
||||
|
||||
return \%answer;
|
||||
}
|
||||
|
||||
@@ -515,29 +515,6 @@ if ($::INITIALINSTALL || $::FORCE)
|
||||
{
|
||||
xCAT::MsgUtils->message('W', $selinux->{warning});
|
||||
}
|
||||
if ($selinux->{disable})
|
||||
{
|
||||
# set selinux be in permissive mode for running system,
|
||||
# if the user forgot to disable selinux,
|
||||
# try to not hurt xcat too much
|
||||
if ($selinux->{enforce_file})
|
||||
{
|
||||
my $cmd = "echo 0 > $selinux->{enforce_file}";
|
||||
my $outref = xCAT::Utils->runcmd("$cmd", 0);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
{
|
||||
xCAT::MsgUtils->message('E', "Failed to disable SELINUX.");
|
||||
}
|
||||
}
|
||||
|
||||
# Disable selinux through reboots
|
||||
my $cmd = "sed -i 's/^SELINUX=.*\$/SELINUX=disabled/' $xCAT::SELinux::CONFIG_FILE";
|
||||
my $outref = xCAT::Utils->runcmd("$cmd", 0);
|
||||
if ($::RUNCMD_RC != 0)
|
||||
{
|
||||
xCAT::MsgUtils->message('E', "Failed to disable SELINUX.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
my $ret = xCAT::Utils->stopservice("firewall");
|
||||
|
||||
Reference in New Issue
Block a user