semanage fcontext -a -t puppet_etc_t "/etc/puppet/environments(/.*)?" cat /etc/selinux/targeted/contexts/files/file_contexts.local # This file is auto-generated by libsemanage # Do not edit directly. /etc/puppet/environments(/.*)? system_u:object_r:puppet_etc_t:s0 touch /etc/puppet/environments/hello1 ls -Z /etc/puppet/environments/hello1 -rw-r--r--. root root unconfined_u:object_r:puppet_etc_t:s0 /etc/puppet/environments/hello1
为什么这个文件创build为“unconfined_u”而不是“system_u”? 我怎样才能改变它? 谢谢。
因为您以非限制用户身份login时创build了该文件。
由于在有针对性的政策中,用户几乎总是被忽视 ,这实际上不是问题。
如果你真的想改变它,你可以使用chcon来做到这一点。 例如:
# ls -Z /etc/nsswitch.conf.ipabkp -rw-r--r--. root root unconfined_u:object_r:etc_t:s0 /etc/nsswitch.conf.ipabkp # chcon -u system_u /etc/nsswitch.conf.ipabkp # ls -Z /etc/nsswitch.conf.ipabkp -rw-r--r--. root root system_u:object_r:etc_t:s0 /etc/nsswitch.conf.ipabkp