Search code examples
fedoraselinuxlibselinux

Unable to change filesystem label using selinux policy module


I am using fedora 21 I have written a selinux policy moudle for an application. I have defined new types is .te file and created a .fc file in which defines the labelling of files with the types I have created. i can successfully load the policy using "make load". But fiile contexts don't get changed when I check on files and directories using "ls -Z".

Am i missing something.


Solution

  • For clarification: "load the policy" does not set "file contexts" of existing files automatically. Existing files should relabeled according to your new policy. New files will get the new label automatically.

    To restore missingmislabeled labels you can use the following command, e.g.:

    restorecon -Rv /var/lib/docker/
    

    From the restorecon manual: "It can also be run [...] to add support for newly-installed policy"

    The normal way is having a policy activated and afterwards install the program or write files to the hard disk. The files are then automatically labeled with your new context type.