On CentOS 7.5, Linux 3.10.0-862.3.2.el7.x86_64, I'm trying to understand how file contexts work.
semanage seem to work as expected, but
restorecon seems stubbornly silent.
$ cd $ mkdir context $ ls -laZ drwxrwxr-x liteyear liteyear ? context $ chcon -v unconfined_u:object_r:user_home_t:s0 context $ ls -laZ drwxrwxr-x. liteyear liteyear unconfined_u:object_r:user_home_t:s0 context $ rmdir context
All good, and
$ mkdir context $ sudo semanage fcontext -a -t user_home_t /home/liteyear/context $ cat /etc/selinux/targeted/contexts/files/file_contexts.local # This file is auto-generated by libsemanage # Do not edit directly. /home/liteyear/context system_u:object_r:user_home_t:s0
All good, but the
$ restorecon -v /home/liteyear/context $ ls -laZ drwxrwxr-x liteyear liteyear ? context
doesn't apply the file context.
I've tried various iterations, with existing contexts, different contexts, other folders and files, and
restorecon has never produced anything. There are various similar reports (eg. [CentOS] SELinux restorecon does not work) but no one seems to have confirmed there's an issue.
Is this the way
restorecon is supposed to work?