【问题标题】:Prevent stop auditd service in Redhat 7防止在 Redhat 7 中停止 auditd 服务
【发布时间】:2016-07-22 07:10:43
【问题描述】:

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

我该如何预防呢?谢谢

【问题讨论】:

  • 你应该包含systemctl cat auditd的输出
  • 我添加了这个命令的结果。

标签: linux service redhat systemd


【解决方案1】:

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

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

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

【讨论】:

    【解决方案2】:

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

    /usr/libexec/initscripts/legacy-actions/auditd/stop
    

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-23
      相关资源
      最近更新 更多