2020-10-17 03:41:23 -06:00
|
|
|
# semanage
|
|
|
|
|
2024-05-25 09:23:06 +08:00
|
|
|
> SELinux persistent policy management tool.
|
2024-05-27 02:28:37 +08:00
|
|
|
> Some subcommands such as `boolean`, `fcontext`, `port`, etc. have their own usage documentation.
|
2021-04-16 16:42:14 +02:00
|
|
|
> More information: <https://manned.org/semanage>.
|
2020-10-17 03:41:23 -06:00
|
|
|
|
2024-05-25 09:23:06 +08:00
|
|
|
- Set or unset a SELinux boolean. Booleans allow the administrator to customize how policy rules affect confined process types (a.k.a domains):
|
2020-10-17 03:41:23 -06:00
|
|
|
|
2025-03-09 01:35:31 +02:00
|
|
|
`sudo semanage boolean {{[-m|--modify]}} {{-1|--on|-0|--off}} {{haproxy_connect_any}}`
|
2020-10-17 03:41:23 -06:00
|
|
|
|
2024-05-25 09:23:06 +08:00
|
|
|
- Add a user-defined file context labeling rule. File contexts define what files confined domains are allowed to access:
|
2020-10-17 03:41:23 -06:00
|
|
|
|
2025-03-09 01:35:31 +02:00
|
|
|
`sudo semanage fcontext {{[-a|--add]}} {{[-t|--type]}} {{samba_share_t}} '/mnt/share(/.*)?'`
|
2020-10-17 03:41:23 -06:00
|
|
|
|
2024-05-25 09:23:06 +08:00
|
|
|
- Add a user-defined port labeling rule. Port labels define what ports confined domains are allowed to listen on:
|
2020-10-17 03:41:23 -06:00
|
|
|
|
2025-03-09 01:35:31 +02:00
|
|
|
`sudo semanage port {{[-a|--add]}} {{[-t|--type]}} {{ssh_port_t}} {{[-p|--proto]}} {{tcp}} {{22000}}`
|
2020-10-17 03:41:23 -06:00
|
|
|
|
2024-05-25 09:23:06 +08:00
|
|
|
- Set or unset permissive mode for a confined domain. Per-domain permissive mode allows more granular control compared to `setenforce`:
|
2020-10-17 03:41:23 -06:00
|
|
|
|
2024-06-25 14:46:09 +02:00
|
|
|
`sudo semanage permissive {{-a|--add|-d|--delete}} {{httpd_t}}`
|
2020-10-17 03:41:23 -06:00
|
|
|
|
2024-05-25 09:23:06 +08:00
|
|
|
- Output local customizations in the default store:
|
2020-10-17 03:41:23 -06:00
|
|
|
|
2025-03-09 01:35:31 +02:00
|
|
|
`sudo semanage export {{[-f|--output_file]}} {{path/to/file}}`
|
2024-05-25 09:23:06 +08:00
|
|
|
|
|
|
|
- Import a file generated by `semanage export` into local customizations (CAREFUL: may remove current customizations!):
|
|
|
|
|
2025-03-09 01:35:31 +02:00
|
|
|
`sudo semanage import {{[-f|--input_file]}} {{path/to/file}}`
|