linux - 防止在 Redhat 7 中停止 auditd 服务

标签 linux service redhat systemd

目前,我希望 auditd 服务永远运行,用户无法通过任何命令停止它。

当前我的 auditd 服务:

~]# systemctl cat auditd

# /usr/lib/systemd/system/auditd.service
[Unit]
Description=Security Auditing Service
DefaultDependencies=no
After=local-fs.target systemd-tmpfiles-setup.service
Conflicts=shutdown.target
Before=sysinit.target shutdown.target
RefuseManualStop=yes
ConditionKernelCommandLine=!audit=0

[Service]
ExecStart=/sbin/auditd -n
## To not use augenrules, copy this file to /etc/systemd/system/auditd.service
## and comment/delete the next line and uncomment the auditctl line.
## NOTE: augenrules expect any rules to be added to /etc/audit/rules.d/
ExecStartPost=-/sbin/augenrules --load
#ExecStartPost=-/sbin/auditctl -R /etc/audit/audit.rules
ExecReload=/bin/kill -HUP $MAINPID

[Install]
WantedBy=multi-user.target


# /etc/systemd/system/auditd.service.d/override.conf
[Service]
ExecReload=
ExecReload=/bin/kill -HUP $MAINPID ; /sbin/augenrules --load

我无法通过命令停止此服务:

# systemctl stop auditd.service

Failed to stop auditd.service: Operation refused, unit auditd.service may be requested by dependency only.

但是当我使用 service auditd stop 命令时。我可以正常停止这个服务。

# service auditd stop
Stopping logging:                                          [  OK  ]

我该如何预防?谢谢

最佳答案

管理员 (root) 将始终能够手动终止 auditd 进程(这是 service 命令所做的)。 systemd 在这里所做的只是为了防止管理员通过 systemctl 接口(interface)进行操作。

在这两种情况下,非特权用户都无法终止守护进程。

如果你想限制 root 可以做什么,你将不得不使用 SELinux 并自定义策略。

关于linux - 防止在 Redhat 7 中停止 auditd 服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38520295/

相关文章:

python - 安装位数组时出错。编译器错误?

regex - 删除部分文件名

linux - 在命令行中使用 weka

spring - 将 Spring 组件导出为 OSGi 服务

javascript - 以 Angular 将服务添加到 Controller

java - jax-ws Web 方法可以返回具有静态方法的对象吗?

linux - Linux 到 OpenSolaris 的迁移有多痛苦?

linux - Docker加载并保存: "archive/tar: invalid tar header"

AjaXplorer 连接到数据库

linux - Windows 程序内存与 Linux 程序内存