From e6ba4e4be11eebb61da2f40cc19f7b7ff587a9f6 Mon Sep 17 00:00:00 2001 From: Daniel Hilst <392820+dhilst@users.noreply.github.com> Date: Wed, 7 Oct 2026 19:56:06 -0300 Subject: [PATCH] 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> --- perl-xCAT/xCAT/SELinux.pm | 30 +++++++++++------------------- xCAT-server/sbin/xcatconfig | 23 ----------------------- 2 files changed, 11 insertions(+), 42 deletions(-) diff --git a/perl-xCAT/xCAT/SELinux.pm b/perl-xCAT/xCAT/SELinux.pm index f158f21ec8..64c3c1fb7e 100644 --- a/perl-xCAT/xCAT/SELinux.pm +++ b/perl-xCAT/xCAT/SELinux.pm @@ -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; } diff --git a/xCAT-server/sbin/xcatconfig b/xCAT-server/sbin/xcatconfig index ab1f69fcf8..c615d9477e 100755 --- a/xCAT-server/sbin/xcatconfig +++ b/xCAT-server/sbin/xcatconfig @@ -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");