4.2. 使用哪个日志文件
在 Red Hat Enterprise Linux 中,默认情况下会安装 dbus 和 audit 软件包,除非它们已从默认软件包选择中删除。必须使用 Yum 安装 setroubleshoot-server (使用 yum install setroubleshoot-server 命令)。
如果
auditd
守护进程正在运行,则 SELinux 拒绝消息(如下所示)会被写入 /var/log/audit/audit.log
:
type=AVC msg=audit(1223024155.684:49): avc: denied { getattr } for pid=2000 comm="httpd" path="/var/www/html/file1" dev=dm-0 ino=399185 scontext=unconfined_u:system_r:httpd_t:s0 tcontext=system_u:object_r:samba_share_t:s0 tclass=file
另外,类似以下的消息会写入
/var/log/message
文件:
May 7 18:55:56 localhost setroubleshoot: SELinux is preventing httpd (httpd_t) "getattr" to /var/www/html/file1 (samba_share_t). For complete SELinux messages. run sealert -l de7e30d6-5488-466d-a606-92c9f40d316d
在 Red Hat Enterprise Linux 7 中,
setroubleshootd
不再作为服务持续运行。但是,它仍用于分析 AVC 信息。如果需要,两个新程序充当启动 setroubleshoot
的方法:
sedispatch
工具作为审计子系统的一部分运行
。当返回 AVC 拒绝消息时,sedispatch
使用dbus
发送消息。如果这些消息已在运行,这些消息将直接变为setroubleshootd
。如果没有运行,sedispatch
会自动启动。seapplet
实用程序在系统工具栏中运行,等待setroubleshootd
中的 dbus 消息。它启动通知 bubble,允许用户查看 AVC 消息。
过程 4.1. 自动启动守护进程
- 要将
auditd
和rsyslog
守护进程配置为在引导时自动启动,请以 root 用户身份输入以下命令:~]#
systemctl enable auditd.service~]#
systemctl enable rsyslog.service - 要确保启用了守护进程,在 shell 提示符后输入以下命令:
~]$
systemctl is-enabled auditd enabled~]$
systemctl is-enabled rsyslog enabled或者,使用 systemctl status service-name.service 命令并搜索命令输出中启用
的关键字,例如:~]$
systemctl status auditd.service | grep enabled auditd.service - Security Auditing Service Loaded: loaded (/usr/lib/systemd/system/auditd.service; enabled)
要了解更多有关
systemd
守护进程如何管理系统服务的信息,请参阅系统管理员指南中的管理系统章节。https://access.redhat.com/documentation/zh-cn/red_hat_enterprise_linux/7/html-single/system_administrators_guide/index#sect-Managing_Services_with_systemd-Services