通过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
打开支持案例后,我发现我被 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)
归档时间: |
|
查看次数: |
2407 次 |
最近记录: |