Show Table of Contents
2.11. 安全性及访问控制
本小节总结了 Red Hat Enterprise Linux 6 和 Red Hat Enterprise Linux 7 对安全性、访问控制以及相关配置工具支持的不同。
2.11.1. 新防火墙(firewalld)
在 Red Hat Enterprise Linux 6 中是由 iptables 程序提供防火墙功能,并使用命令行或者图形配置工具 system-config-firewall 配置。在 Red Hat Enterprise Linux 7 中仍由 iptables 提供。但管理员现在可以通过同台防火墙守护进程
firewalld 及其配置工具与 iptables 互动:firewall-config、firewall-cmd 和 firewall-applet 不包含在 Red Hat Enterprise Linux 7 的默认安装中。
因为
firewalld 是动态的,所以可随时更改其配置,并立即实施。防火墙的所有部分都不需要重新载入,因此对现有网络连接不会产生意外中断。
Red Hat Enterprise Linux 6 和 7 中防火墙的主要不同之处在于:
- Firewalld 配置详情不再保存在
/etc/sysconfig/iptables中,而是保存在/usr/lib/firewalld和/etc/firewalld目录的不同文件中。 - 在 Red Hat Enterprise Linux 6 中,每次配置更改时都会删除防火墙系统并重新采用所有规则,而
firewalld只采用配置更改的部分。结果是firewalld可以在运行时并不丢失显示连接的情况下更改设置。
有关 Red Hat Enterprise Linux 7 中防火墙配置的附加信息及帮助手段,请参考《Red Hat Enterprise Linux 7 安全指南》,网址:http://access.redhat.com/site/documentation/Red_Hat_Enterprise_Linux/。
2.11.1.1. firewalld 的迁移规则
重要
如果在 Red Hat Enterprise Linux 7 中使用其他 Red Hat 产品,比如 Red Hat Enterprise Linux OpenStack Platform,继续使用
iptables 或者 ip6tables,而不是改用 firewalld 可能会更恰当。
如果您不确定应该使用哪个防火墙工具,请查看您的产品文档,或联络 Red Hat Support。
Red Hat Enterprise Linux 6 提供两种防火墙配置方法:
- 使用图形 system-config-firewall 工具配置规则。这个工具将配置详情保存在
/etc/sysconfig/system-config-firewall文件中,并在/etc/sysconfig/iptables和/etc/sysconfig/ip6tables文件中为iptables和ip6tables生成配置。 - 手动编辑
/etc/sysconfig/iptables和/etc/sysconfig/ip6tables文件(可以从头开始,也可以编辑由 system-config-firewall 生成的初始配置)。
如果您是使用 system-config-firewall 配置 Red Hat Enterprise Linux 6 防火墙,则在升级系统并安装 firewalld 后,就可以使用 firewall-offline-cmd 工具将
/etc/sysconfig/system-config-firewall 中的配置迁移到 firewalld 的默认区中。
$ firewall-offline-cmd
但如果您是手动创建或者编辑
/etc/sysconfig/iptables 或者 /etc/sysconfig/ip6tables,安装 firewalld 后就必须使用 firewall-cmd 或者 firewall-config 创建新的配置,或者禁用 firewalld,并继续使用原来的 iptables 和 ip6tables 服务。有关生成新配置或者禁用 firewalld 的详情请参考《Red Hat Enterprise Linux 7 安全指南》,网址:http://access.redhat.com/site/documentation/Red_Hat_Enterprise_Linux/。
2.11.2. PolicyKit 的变化
之前 PolicyKit 使用
.pkla 文件中的密钥值对定义附加本地授权。Red Hat Enterprise Linux 7 引进了使用 JavaScript 定义本地授权的功能,可让您在需要时使用脚本授权。
polkitd 以字典顺序读取 /etc/polkit-1/rules.d 和 /usr/share/polkit-1/rules.d 目录中的 .rules 文件。如果两个文件采用同样的名称,/etc 中的文件在 /usr 中的文件前面。处理旧的 .pkla 文件时,最先采用的是最后的规则。使用新的 .rules 文件时,首先采用的是第一个匹配的规则。
迁移后,
/etc/polkit-1/rules.d/49-polkit-pkla-compat.rules 文件采用您现有的规则。因此他们可被 /usr 或者 /etc 目录中名称按字典顺序在 49-polkit-pkla-compat 前面的 .rules 文件覆盖。确保原有文件不被覆盖的最简单方法是所有其他 .rules 文件都采用比 49 这个数字大的名称。
有关详情请参考《Red Hat Enterprise Linux 7 桌面迁移及管理指南》,网址:http://access.redhat.com/site/documentation/Red_Hat_Enterprise_Linux/。
2.11.3. 用户识别符的更改
在 Red Hat Enterprise Linux 6 中,基本用户识别符为
500。在 Red Hat Enterprise Linux 中,基本用户识别符为 1000。这个变化涉及在升级过程中替换 /etc/login.defs 文件。
如果您没有修改默认
/etc/login.defs 文件,则会在升级过程中替换该文件。将基本用户识别符号改为 1000,同时为新用户分配的识别符在 1000 以上(包括 1000)。在这个变化之前创建的用户账户仍保留其现有用户识别符,并照常工作。
如果您修改了默认
/etc/login.defs 文件,则在升级过程中不会替换该文件,同时基本识别符数字仍保留为 500。
2.11.4. libuser 的变化
从 Red Hat Enterprise Linux 7 开始,
libuser 程序可不再支持包含 ldap 和 files 模块,或者同时包含 ldap 和 files 模块的配置。合用这些模块的结果是造成处理密码时歧义,同时此类配置现在回在初始化过程中被拒绝。
如果您使用
libuser 管理 LDAP 中的用户或者组,则必须删除配置文件(默认为 /etc/libuser.conf)modules 和 create_modules 指令中的 files 和 shadow 模块。

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.