-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import resources from selinux_policy (#79)
* add resources + integration tests from selinux_policy * Use inspec profiles instead of raw tests * use native shell_out instead of execute resources in port resource * use native shell_out instead of execute resources in fcontext resource * Use shell_out! helper in permissive resource * update documentation for new resources * add spec tests for all resources * appease yamllint * fix module list on c7 * Standardize documentation format * Review fixes * fix tests * appease mdl * Fix test idempotency * add missing header to resource * add missing documentation links to README Signed-off-by: Robert Detjens <[email protected]>
- Loading branch information
1 parent
0bce2b7
commit b35112c
Showing
57 changed files
with
1,307 additions
and
224 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
[Back to resource list](../README.md#resources) | ||
|
||
# selinux_fcontext | ||
|
||
Set the SELinux context of files with `semanage fcontext`. | ||
|
||
## Actions | ||
|
||
| 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`) | | ||
|
||
## Properties | ||
|
||
| 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 files | ||
- **`f`** - Regular files | ||
- **`d`** - Directory | ||
- **`c`** - Character device | ||
- **`b`** - Block device | ||
- **`s`** - Socket | ||
- **`l`** - Symbolic link | ||
- **`p`** - Named pipe | ||
|
||
## Examples | ||
|
||
```ruby | ||
# Allow http servers (e.g. nginx/apache) to modify moodle files | ||
selinux_policy_fcontext '/var/www/moodle(/.*)?' do | ||
secontext 'httpd_sys_rw_content_t' | ||
end | ||
|
||
# Adapt a symbolic link | ||
selinux_policy_fcontext '/var/www/symlink_to_webroot' do | ||
secontext 'httpd_sys_rw_content_t' | ||
file_type 'l' | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
[Back to resource list](../README.md#resources) | ||
|
||
# selinux_permissive | ||
|
||
Allows some types to misbehave without stopping them. Not as good as specific policies, but better than disabling SELinux entirely. | ||
|
||
> This does not set the SELinux state to permissive! Use [`selinux_state`](selinux_state.md) for that. | ||
## Actions | ||
|
||
| Action | Description | | ||
| --------- | -------------------------------------------------- | | ||
| `:add` | *(Default)* Adds a permissive, unless already set. | | ||
| `:delete` | Removes a permissive, if set. | | ||
|
||
## Properties | ||
|
||
| Name | Type | Default | Description | | ||
| --------- | ------ | ------------- | ------------------------------------------- | | ||
| `context` | String | Resource name | Name of the context to disable SELinux for. | | ||
|
||
## Examples | ||
|
||
```ruby | ||
# Disable enforcement on Apache | ||
selinux_permissive 'httpd_t' do | ||
notifies :restart, 'service[httpd]' | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
[Back to resource list](../README.md#resources) | ||
|
||
# selinux_policy_port | ||
|
||
Allows assigning a network port to a certain SELinux context, e.g. for running a webserver on a non-standard port. | ||
|
||
## Actions | ||
|
||
| Action | Description | | ||
| --------- | ------------------------------------------------------------------------------- | | ||
| `:manage` | *(Default)* Assigns the port to the right context regardless of previous state. | | ||
| `:add` | Assigns the port context if not set.(`-a`) | | ||
| `:modify` | Updates the port context if previously set.(`-m`) | | ||
| `:delete` | Removes the port context if set. (`-d`) | | ||
|
||
## Properties | ||
|
||
| Name | Type | Default | Description | | ||
| ----------- | ------ | ------------- | ------------------------------------------ | | ||
| `port` | String | Resource name | The port in question. | | ||
| `protocol` | String | | Either `tcp` or `udp`. | | ||
| `secontext` | String | | The SELinux context to assign the port to. | | ||
|
||
## Examples | ||
|
||
```ruby | ||
# Allow nginx/apache to bind to port 5678 by giving it the http_port_t context | ||
selinux_policy_port '5678' do | ||
protocol 'tcp' | ||
secontext 'http_port_t' | ||
end | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.