on it road .com

解决方法

SELinux 为系统中的资源提供了另外的安全层。
与 DAC(自由访问控制)相反,它提供 MAC(强制访问控制)。
在我们深入设置 SELinux 模式之前,让我们看看有哪些不同的 SELinux 操作模式以及它们是如何工作的。
SELinux 可以在以下 3 种模式中的任何一种下运行:

  1. Enforced :阻止违反策略的操作,并在审核日志中记录相应的事件。

  2. Permissive : 违反政策的行为只记录在审计日志中。

  3. Disabled :SELinux 完全禁用。

要完全禁用 SELinux ,请使用以下任一方法:

  1. 编辑/etc/selinux/config(需要重启)
    在文件 /etc/selinux/config 中将 SELINUX 值更改为 SELINUX=disabled。
# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of three two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

重新启动服务器。

# shutdown -r now
  1. 添加内核启动选项
    编辑 /boot/grub/grub.conf 中的内核引导行,并将 selinux=0 添加到内核引导选项。
    例如:
title Red Hat Enterprise Linux AS (2.6.9-42.ELsmp)
root (hd0,0)
kernel /vmlinuz-2.6.9-42.ELsmp ro root=LABEL=/ rhgb quiet selinux=0
initrd /initrd-2.6.9-42.ELsmp.img

重新启动服务器。

# shutdown -r now

要将 SELinux 设置为 Permissive mode ,请使用以下任一方法:

  1. 将SELinux模式设置为Permissive临时(无需重启)
    setenforce 命令用于在强制和许可模式之间切换。
    要更改为许可模式:
# setenforce 0

使用 getenforce 命令查看当前 SELinux 模式:

# getenforce
Permissive
  1. 永久设置 SELinux 为 Permissive 模式

编辑 /etc/selinux/config

将 SELINUX 值更改为“SELINUX=permissive”

# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
SELINUX=permissive
# SELINUXTYPE= can take one of these two values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

添加内核启动选项

编辑内核引导行并将“enforcing=0”添加到内核引导选项(假设 SELinux 未设置为禁用,如上一节所述)。
例如:

title Red Hat Enterprise Linux AS (2.6.9-42.ELsmp)
root (hd0,0)
kernel /vmlinuz-2.6.9-42.ELsmp ro root=LABEL=/ rhgb quiet enforcing=0
initrd /initrd-2.6.9-42.ELsmp.img

重新启动服务器。

# shutdown -r now

要检查 SELinux 的状态,请发出:

# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /sys/fs/selinux
SELinux root directory:         /etc/selinux
Loaded policy name:             targeted
Current mode:                   permissive
Mode from config file:          permissive
Policy MLS status:              enabled
Policy deny_unknown status:     allowed
Max kernel policy version:      28
如何禁用或者设置 SELinux 为许可模式

问题

如何完全禁用 SELinux(Security Enhanced Linux)或者将其设置为“permissive”模式

日期:2020-09-17 00:13:32 来源:oir作者:oir