I want to restrict write access to certain files so that only specific process types (domains) can modify them. For this, I need to create a custom file label and assign it to those files.
Following this answer, I used:
type <custom_label>;
files_type(<custom_label>);
But files_type() seems to implicitly allow access to all process types. If I skip files_type() and just declare:
type <custom_label>;
then semanage fcontext -a -t <custom_label> "/some/path" fails with:
ValueError: Type <custom_label> is invalid, must be a file or device type
Question: What is the correct way to declare a file label that:
- Can be assigned to paths via semanage fcontext.
 - Doesn’t allow access to any processes types except those explicitly granted via allow rules?