Set the SELinux context of files with semanage fcontext
.
Action | Description |
---|---|
:manage |
(Default) Assigns the file to the right context regardless of previous state. |
:add |
Assigns the file context if not set.(-a ) |
:modify |
Updates the file context if previously set.(-m ) |
:delete |
Removes the file context if set. (-d ) |
Name | Type | Default | Description |
---|---|---|---|
file_spec |
String | Resource name | Path or regular expression to files to modify. |
secontext |
String | The SELinux context to assign the file to. | |
file_type |
String | a (all files) |
Restrict the resource to only modifying specific file types. See list below. |
Supported file types:
a
- All filesf
- Regular filesd
- Directoryc
- Character deviceb
- Block devices
- Socketl
- Symbolic linkp
- Named pipe
# Allow http servers (e.g. nginx/apache) to modify moodle files
selinux_fcontext '/var/www/moodle(/.*)?' do
secontext 'httpd_sys_rw_content_t'
end
# Adapt a symbolic link
selinux_fcontext '/var/www/symlink_to_webroot' do
secontext 'httpd_sys_rw_content_t'
file_type 'l'
end