【问题标题】:Disable SELinux in-session on CentOS 5.10 box在 CentOS 5.10 机器上禁用 SELinux in-session
【发布时间】:2015-02-04 16:39:20
【问题描述】:

我在更改看起来与 SELinux 相关的目录权限时遇到了一些问题。我正在尝试弄清楚如何在厨师客户端会话的剩余部分中禁用 SELinux a) 以及 b) 永久禁用。

资源:

# Change permissions for mounted repository
directory "/home/analytics" do
  owner "analytics"
  mode "711"
end

错误:

/sbin/restorecon set context /analytics/file failed:'Operation not supported'

环境:

看起来 SELinux 搞砸了。伟大的。让我们禁用 SELinux!

Chef's box 中的库存配置设置为许可。

[root@analytics selinux]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#   enforcing - SELinux security policy is enforced.
#   permissive - SELinux prints warnings instead of enforcing.
#   disabled - SELinux is fully disabled.
SELINUX=permissive
# SELINUXTYPE= type of policy in use. Possible values are:
#   targeted - Only targeted network daemons are protected.
#   strict - Full SELinux protection.
SELINUXTYPE=targeted

我可以将配置模板化并设置为禁用,但这只会在重新启动后应用。通常在当前会话中禁用 SELinux 是通过 CLI(sestatus、setenforce 等)完成的。我们的食谱(和the official one)依赖于这个功能。不过这里好像坏了……

[root@analytics selinux]# sestatus
bash: sestatus: command not found
[root@analytics selinux]# getstatus
bash: getstatus: command not found

[root@analytics selinux]# rpm -q policycoreutils
policycoreutils-1.33.12-14.13.el5

那么如何在不重启机器或运行 Chef 两次的情况下禁用 SELinux?

【问题讨论】:

  • sestatus 和 getenforce 在 '/usr/sbin' 目录中,所以尝试使用绝对路径调用它们。如果找不到,请尝试重新安装 policycoreutils 包。
  • 谢谢!我在 /sbin 中寻找这些。我的错。 [vagrant@analytics-centos-510 sbin]$ ls /usr/sbin/se* /usr/sbin/selinuxenabled /usr/sbin/semodule /usr/sbin/sestatus /usr/sbin/semanage /usr/sbin/setenforce

标签: chef-infra centos5 selinux test-kitchen


【解决方案1】:

我通过创建一个新的 .box 解决了我的问题,并将 /etc/selinux/config 中的设置设置为 DISABLED。

但是@szpal 是对的。二进制文件位于 /usr/sbin 下(而不是 /sbin,我一直在寻找):

[vagrant@analytics-centos-510 sbin]$ ls /usr/sbin/se* /usr/sbin/selinuxenabled /usr/sbin/semodule /usr/sbin/sestatus /usr/sbin/semanage /usr/sbin/setenforce

一项快速测试表明您可以通过简单地提供执行资源的完整路径来禁用 SELinux 会话:

execute "disable selinux - running" do
      command "/usr/sbin/setenforce 0"
end

【讨论】:

  • 仅供参考,这不是禁用 SELinux,而是将其设置为许可模式。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-09-04
  • 2023-03-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多