我在更改目录权限时遇到了一些问题,这些权限看起来与 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'
环境:
- Test Kitchen,Vagrant驱动程序和VirtualBox。
- 盒子 - 厨师无配置者 centos-5.10。
看起来 SELinux 正在搞砸作品。 伟大。 让我们禁用 SELinux!
厨师盒子中的库存配置设置为宽松。
[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等)完成的。 我们的食谱(和官方食谱)依赖于此功能。 但它似乎在这里被打破了...
[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?
我通过创建一个新的 .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