Restrict File creation types
How would I go about restricting all files created in a certain directory to a set of types. Eg:
I have Dir Types:Dir_Type1_tDir_Type2_t
and file Types:File_type_1a_tFile_type_1b_tFile_type_2a_tFile_type_2b_t
I want all files in Dir_Type1_t to be of types File_type_1a_t or File_type_1b_t no matter the domain of the creating process and all files in Dir_Type2_t to be of types File_type_2a_t or File_type_2b_t.
(mkdir -Z user:object_r:File_type_2a_t TEST in a dir of type Dir_Type2_t should fail as any user/role/domain)
I've tried looking through the logs with auditallow on for all the Dir and File types, but didn't see anything where both types where listed in the same allow statement. Is this even possible?
Kenny
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 18 lines · Kenny
How would I go about restricting all files created in a certain directory to a set of types. Eg:
I have Dir Types:Dir_Type1_tDir_Type2_t
and file Types:File_type_1a_tFile_type_1b_tFile_type_2a_tFile_type_2b_tI want all files in
Dir_Type1_tto be of typesFile_type_1a_torFile_type_1b_tno matter the domain of the creating process and all files inDir_Type2_tto be of typesFile_type_2a_torFile_type_2b_t.
(mkdir -Z user:object_r:File_type_2a_t TEST in a dir of typeDir_Type2_tshould fail as any user/role/domain)
Quoted 3 lines
I've tried looking through the logs with auditallow on for all the Dir and File types, but didn't see anything where both types where listed in the same allow statement. Is this even possible?
There isn't a particular permission that enforces an association between the parent directory type and the new file type. You can do things like:
- Prevent a domain from specifying a particular context at all for a new file, forcing new files to inherit from the parent directory or to follow any type_transition rule specified in the policy.
- Control which domains can write to a given directory, and then ensure that those domains can only create files with particular types.
It wouldn't be difficult to add a new permission check between the parent directory type and the new file type on file creation, but you would also need to ensure that the property is preserved for hard links, and possibly for bind mounts.
There is a permission check performed between the new file type and the filesystem type.
Signature · 8 lines
Stephen Smalley <[email protected]> National Security Agency -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.