Skip to content

Commit 70c5712

Browse files
LSM_apparmor_selinux: add small example psuedo SELinux config
1 parent 26c7fab commit 70c5712

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

write-ups_unpublished/LSM_apparmor_selinux.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,25 @@ Example: \
104104
The boolean 'allow_ftpd_anon_write'[3] modifies the policy for ftpd to allow so-called anonymous users to write to disk. This is achieved with the _type_ 'public_content_rw_t' (to put it simply: like a special file permission), which is applied to files or directories that the anonymous user should have access to.
105105
As the application (ftpd) itself is not aware of SELinux, SELinux bases this on the process and file _types_. _**TODO:** question, how does SELinux correctly identify that the FTP user writing is anonymous?_
106106
- **Domain**: processes (to put it simply: processes run in domains and are thereby separated from each other and can be granted different permissions)
107-
- **Macros**: ...similar to macros in programming... [6]
107+
- **Macros**: ...similar to macros in programming... [6] \
108+
- **Type attributes**: A grouping of multiple types and can be referenced in the same way (example below)
109+
110+
```bash
111+
# Minor example, a bit out of context: Domains, types, type attributes
112+
113+
# Give some types the attribute of file_type.
114+
# Then grant access to a domain (some_domain) to read all files with those types
115+
# (i.e. types included in the file_type type attribute, which to reiterate is a collection of types)
116+
typeattribute app_data_file_t file_type;
117+
typeattribute system_log_file_t file_type;
118+
allow some_domain file_type: file { read getattr };
119+
120+
# Normal apps however does not have access to file_type objects, as we defined above.
121+
# We can instead grant them more granular permissions
122+
# by granting them only access to one of the smaller types (and not the whole type attribute)
123+
allow untrusted_app app_data_file_t: file { read write open getattr };
124+
allow system_app system_log_file_t: file { read write getattr };
125+
```
108126
109127
¹ See Multi-Level Security (**MLS**) and Multi-Category Security (**MCS**): _<https://selinuxproject.org/page/MLSStatements>, <https://selinuxproject.org/page/MultiCategorySecurity>, <https://www.redhat.com/en/blog/why-you-should-be-using-multi-category-security-your-linux-containers>_
110128

0 commit comments

Comments
 (0)