目前,我希望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 ]我怎样才能防止它呢?谢谢
发布于 2016-08-10 07:46:41
管理员(根用户)将始终能够手动终止auditd进程(这就是service命令的功能)。systemd在这里所做的只是为了防止管理员通过systemctl接口执行此操作。
在这两种情况下,非特权用户都不能终止守护进程。
如果您想限制根用户可以执行的操作,则必须使用SELinux并自定义策略。
发布于 2020-04-17 22:45:41
service命令的某些操作不会重定向到systemctl,而是运行位于/usr/libexec/initscripts/legacy-actions中的某些特定脚本。在这种情况下,stop命令将调用此脚本:
/usr/libexec/initscripts/legacy-actions/auditd/stop如果你想这样做,审计的服务不能被服务命令停止,你可以删除这个脚本,“停止”操作将被重定向到systemctl,它会通过参数"RefuseManualStop=yes“的b/c阻止它。当然,这并不意味着您不能终止该进程。
https://stackoverflow.com/questions/38520295
复制相似问题