首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >阻止Redhat 7中的stop auditd服务

阻止Redhat 7中的stop auditd服务
EN

Stack Overflow用户
提问于 2016-07-22 15:10:44
回答 2查看 12.4K关注 0票数 4

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

当前我的auditd服务:

代码语言:javascript
复制
~]# 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

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

代码语言:javascript
复制
# systemctl stop auditd.service

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

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

代码语言:javascript
复制
# service auditd stop
Stopping logging:                                          [  OK  ]

我怎样才能防止它呢?谢谢

EN

回答 2

Stack Overflow用户

发布于 2016-08-10 07:46:41

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

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

如果您想限制根用户可以执行的操作,则必须使用SELinux并自定义策略。

票数 4
EN

Stack Overflow用户

发布于 2020-04-17 22:45:41

service命令的某些操作不会重定向到systemctl,而是运行位于/usr/libexec/initscripts/legacy-actions中的某些特定脚本。在这种情况下,stop命令将调用此脚本:

代码语言:javascript
复制
/usr/libexec/initscripts/legacy-actions/auditd/stop

如果你想这样做,审计的服务不能被服务命令停止,你可以删除这个脚本,“停止”操作将被重定向到systemctl,它会通过参数"RefuseManualStop=yes“的b/c阻止它。当然,这并不意味着您不能终止该进程。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38520295

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档