Red Hat Training

A Red Hat training course is available for RHEL 8

8.6. SELinux

8.6.1. SELinux 软件包迁移到 Python 3

  • policycoreutils-python 已被 policycoreutils-python-utilspython3-policycoreutils 软件包替代。
  • libselinux-python 软件包的功能现在由 python3-libselinux 软件包提供。
  • setools-libs 软件包的功能现在由 python3-setools 软件包提供。
  • libsemanage-python 软件包的功能现在由 python3-libsemanage 软件包提供。

8.6.2. SELinux 子软件包的更改

  • libselinux-staticlibsemanage-staticlibsepol-staticsetools-libs-tcl 已被删除。
  • RHEL 8.0 和 8.1 提供了 setools-guisetools-console-analyses。RHEL 8.2 是包含这些子软件包的 RHEL 8 的第一个次要版本。

8.6.3. SELinux 策略的更改

init_t 域在 RHEL 8 上不再受限制。这可能会对使用不同 SELinux 标记方法的第三方应用程序造成问题。

要解决非标准位置中的 SELinux 标记问题,您可以为这些位置配置文件上下文等效性。

  1. /my/apps/ 目录配置文件上下文等效性:

    # semanage fcontext -a -e / /my/apps
  2. 通过列出 SELinux 策略的本地自定义来验证文件上下文等效性:

    # semanage fcontext -l -C
    
    SELinux Local fcontext Equivalence
    
    /my/apps = /
  3. /my/apps 的上下文恢复为默认值,这等同于 / 的上下文:

    # restorecon -Rv /my/apps
    restorecon reset /my/apps context unconfined_u:object_r:default_t:s0->unconfined_u:object_r:root_t:s0
    restorecon reset /my/apps/bin context unconfined_u:object_r:default_t:s0->unconfined_u:object_r:bin_t:s0
    restorecon reset /my/apps/bin/executable context unconfined_u:object_r:default_t:s0->unconfined_u:object_r:bin_t:s0

这种方法将正确的标签分配给安装在非标准位置的大多数文件和目录,这也会导致某些可执行文件启动正确标记的进程。

要删除文件上下文等效性,请使用以下命令:

# semanage fcontext -d -e / /my/apps
  • 如需更多信息,请参阅 semanage-fcontext 手册页。

8.6.4. SELinux 布尔值的更改

8.6.4.1. 新 SELinux 布尔值

这个 SELinux 系统策略更新引进了以下布尔值:

  • colord_use_nfs
  • deny_bluetooth
  • httpd_use_opencryptoki
  • logrotate_use_fusefs
  • mysql_connect_http
  • pdns_can_network_connect_db
  • ssh_use_tcpd
  • sslh_can_bind_any_port
  • sslh_can_connect_any_port
  • tor_can_onion_services
  • unconfined_dyntrans_all
  • use_virtualbox
  • virt_sandbox_share_apache_content
  • virt_use_pcscd

8.6.4.2. 删除的 SELinux 布尔值

以前版本中提供的以下布尔值在 RHEL 8 SELinux 策略中不提供:

  • container_can_connect_any
  • ganesha_use_fusefs

8.6.4.3. 更改默认值

在 RHEL 8 中,以下 SELinux 布尔值被设置为与上一版本不同的默认值:

  • domain_can_mmap_files 现在默认为 off
  • httpd_graceful_shutdown 现在被默认设置为 off
  • mozilla_plugin_can_network_connect 现在被默认设置为 on
  • named_write_master_zones 现在被默认设置为 on

例如,antivirus_use_jitssh_chroot_rw_homedirs 布尔值的描述已改变。

要获得包括其含义的布尔值列表,并找出它们是否被启用或禁用了,请安装 selinux-policy-devel 软件包并使用:

# semanage boolean -l

8.6.5. SELinux 端口类型更改

RHEL 8 SELinux 策略提供以下额外端口类型:

  • appswitch_emp_port_t
  • babel_port_t
  • bfd_control_port_t
  • conntrackd_port_t
  • firepower_port_t
  • nmea_port_t
  • nsca_port_t
  • openqa_port_t
  • openqa_websockets_port_t
  • priority_e_com_port_t
  • qpasa_agent_port_t
  • rkt_port_t
  • smntubootstrap_port_t
  • statsd_port_t
  • versa_tek_port_t

dns_port_tephemeral_port_t 端口类型的定义已改变,gluster_port_t 端口类型已删除。

8.6.6. sesearch 用法的变化

  • sesearch 命令不再使用 -C 选项,它要求包括有条件的表达式。
  • -T, --type 选项已被更改为:

    • -T,--type_trans - 查找 type_transition 规则。
    • --type_member - 查找 type_member 规则。
    • --type_change - 查找 type_change 规则。