dist: tk4: add the function of disabling selinux
When kernel rpm is installed, if selinux in the host is not set, the function of selinux will be disabled. Signed-off-by: Chun Liu <kaicliu@tencent.com>
This commit is contained in:
parent
1014f31426
commit
83267df9d1
|
|
@ -1122,6 +1122,29 @@ elif command -v new-kernel-pkg > /dev/null; then
|
|||
else
|
||||
echo "NOTICE: No available kernel install handler found. Please make sure boot loader and initramfs are properly configured after the installation." > /dev/stderr
|
||||
fi
|
||||
|
||||
# If match, the selinux will be disabled.
|
||||
is_set_selinux=0
|
||||
if [ -e /proc/config.gz ]; then
|
||||
zcat /proc/config.gz | grep -q "^CONFIG_SECURITY_SELINUX=y"
|
||||
is_set_selinux=$?
|
||||
elif [ -e /boot/config-$(uname -r) ]; then
|
||||
cat /boot/config-$(uname -r) | grep -q "^CONFIG_SECURITY_SELINUX=y"
|
||||
is_set_selinux=$?
|
||||
elif [ -e /proc/kallsyms ]; then
|
||||
cat /proc/kallsyms | grep -q " selinux_init$"
|
||||
is_set_selinux=$?
|
||||
else
|
||||
echo "Ignore selinux adjustments"
|
||||
fi
|
||||
|
||||
# if CONFIG_SECURITY_SELINUX is not set, we should disable selinux.
|
||||
[ $is_set_selinux -ne 0 ] && {
|
||||
echo "Selinux is not supported by current running kernel, disabling SELinux globally to avoid potential system failure."
|
||||
echo "Please update /etc/selinux/config manually after testing SELinux functionality. Now setting SELINUX=disabled"
|
||||
grep -q "^SELINUX *= *.*$" /etc/selinux/config && sed -ri "s/^ *SELINUX *= *enforcing *$/SELINUX=disabled/" /etc/selinux/config || echo "SELINUX=disabled" >> /etc/selinux/config
|
||||
}
|
||||
|
||||
# Just in case kernel-install didn't depmod
|
||||
depmod -A %{kernel_unamer}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue