Chef infra 在CentOS 5.10机器上禁用会话中的SELinux

Chef infra 在CentOS 5.10机器上禁用会话中的SELinux,chef-infra,centos5,selinux,test-kitchen,Chef Infra,Centos5,Selinux,Test Kitchen,我在更改目录权限时遇到一些问题,这些权限看起来与SELinux相关。我试图找出如何在chef客户端会话的其余部分禁用SELinux a)和永久禁用b)的方法 资源: # Change permissions for mounted repository directory "/home/analytics" do owner "analytics" mode "711" end 错误: /sbin/restorecon set context /analytics/file faile

我在更改目录权限时遇到一些问题,这些权限看起来与SELinux相关。我试图找出如何在chef客户端会话的其余部分禁用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

厨师席中的库存配置设置为“允许”

[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
我可以将配置模板设置为disabled,但这只会在重新启动后应用。通常,在当前会话中禁用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

那么,如何在不重新启动box或运行Chef两次的情况下禁用SELinux呢?

我通过创建一个新的.box并将/etc/SELinux/config中的设置设置为DISABLED来修复我的问题

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

快速测试表明,只需提供执行资源的完整路径,即可在会话中禁用SELinux:

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

sestatus和getenforce位于'/usr/sbin'目录中,因此请尝试使用绝对路径调用它们。如果未找到,请尝试重新安装policycoreutils包。谢谢!我正在/sbin中寻找这些。我的错误<代码>[vagrant@analytics-centos-510 sbin]$ls/usr/sbin/se*/usr/sbin/SELinux启用/usr/sbin/semodule/usr/sbin/sestatus/usr/sbin/semanage/usr/sbin/setenforce仅供参考,这不是禁用SELinux,而是将其设置为许可模式。
execute "disable selinux - running" do
      command "/usr/sbin/setenforce 0"
end