目前,我希望 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/