Skip to content

Commit

Permalink
Update sebool template for bootable containers
Browse files Browse the repository at this point in the history
  • Loading branch information
matusmarhefka committed Oct 31, 2024
1 parent 21a4c72 commit 07efcbe
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/templates/template_reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ When the remediation is applied duplicate occurrences of `key` are removed.
`var_selinuxuser_execheap` to turn on or off the SELinux
boolean.

- Languages: Ansible, Bash, OVAL
- Languages: Ansible, Bash, OVAL, SCE

#### service_disabled
- Checks if a service is disabled. Uses either systemd or SysV init
Expand Down
10 changes: 8 additions & 2 deletions shared/templates/sebool/bash.template
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,18 @@
{{{ bash_package_install("libsemanage-python") }}}
{{% endif %}}

if {{{ bash_bootc_build() }}} ; then
# In a container build environment setsebool generates many
# harmless warnings which can be ignored.
redirect_stderr="2>/dev/null"
fi

if selinuxenabled; then
{{% if SEBOOL_BOOL %}}
setsebool -P {{{ SEBOOLID }}} {{{ SEBOOL_BOOL }}}
setsebool -P {{{ SEBOOLID }}} {{{ SEBOOL_BOOL }}} $redirect_stderr
{{% else %}}
{{{ bash_instantiate_variables("var_" + SEBOOLID) }}}
setsebool -P {{{ SEBOOLID }}} $var_{{{ SEBOOLID }}}
setsebool -P {{{ SEBOOLID }}} $var_{{{ SEBOOLID }}} $redirect_stderr
{{% endif %}}
else
echo "Skipping remediation, SELinux is disabled";
Expand Down
13 changes: 13 additions & 0 deletions shared/templates/sebool/sce-bash.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash
# check-import = stdout
{{% if not SEBOOL_BOOL %}}
# check-export = var_{{{ SEBOOLID }}}=var_{{{ SEBOOLID }}}
{{% endif %}}

{{% if SEBOOL_BOOL -%}}
expected_value="{{{ SEBOOL_BOOL }}}"
{{%- else -%}}
expected_value="$XCCDF_VALUE_var_{{{ SEBOOLID }}}"
{{%- endif %}}

seinfo -xb {{{ SEBOOLID }}} "$expected_value"
1 change: 1 addition & 0 deletions shared/templates/sebool/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ supported_languages:
- ansible
- bash
- oval
- sce-bash

0 comments on commit 07efcbe

Please sign in to comment.