SELinux 文件上下文,restorecon 不会更改“用户”上下文

LJK*_*ims 5 rhel selinux

通过matchpathcon对文件(如/usr/lib64/gconv/gconv-modules.cache)我得到:

/usr/lib64/gconv/gconv-modules.cache  system_u:object_r:lib_t:s0
Run Code Online (Sandbox Code Playgroud)

然而:

# ls -alZ /usr/lib64/gconv/gconv-modules.cache
-rw-r--r--. root root unconfined_u:object_r:lib_t:s0
Run Code Online (Sandbox Code Playgroud)

因此,该文件似乎没有正确的上下文(不匹配的用户部分)。但是,运行时restorecon -v文件不会改变。

我可以做这个:

# chcon -t httpd_sys_content_t /usr/lib64/gconv/gconv-modules.cache
# ls -alZ /usr/lib64/gconv/gconv-modules.cache
-rw-r--r--. root root unconfined_u:object_r:httpd_sys_content_t:s0
# restorecon -v /usr/lib64/gconv/gconv-modules.cache
unconfined_u:object_r:httpd_sys_content_t:s0 -> unconfined_t:object_r:lib_t:s0
Run Code Online (Sandbox Code Playgroud)

所以restorecon似乎只更新type文件的 SELinux而不是user上下文。这是一个错误还是对这种行为有解释?我认为这可能是一个错误,因为文档(https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security-Enhanced_Linux/sect-Security-Enhanced_Linux-Working_with_SELinux-SELinux_Contexts_Labeling_Files.html)在user上下文不匹配的文件上显示 restorecon并且它unconfined_u->system_u按预期更改。

操作系统:红帽 7.3
SELinux:3.13.1-102.el7_3.16

LJK*_*ims 9

打开支持案例后,我发现我被 Red Hat 文档误导了,应该更仔细地阅读手册页:

# man restorecon
...
If  a  file  object  does not have a context, restorecon will write the
default context to the file object's extended  attributes.  **If  a  file
object  has  a context, restorecon will only modify the type portion of
the security context.  The -F option will force a  replacement  of  the
entire context.**
...
Run Code Online (Sandbox Code Playgroud)