Skip to content

Commit

Permalink
Check SELinux labels on container volumes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bischoff committed Jan 30, 2025
1 parent 064627e commit 4b50524
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Feature: Sanity checks
And socket "tftp" is active on "server"
And service "tomcat" is enabled on "server"
And service "tomcat" is active on "server"
And files on container volumes should all have the proper SELinux label

@proxy
Scenario: The proxy is healthy
Expand Down
3 changes: 2 additions & 1 deletion testsuite/features/core/allcli_sanity.feature
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2019-2022 SUSE LLC
# Copyright (c) 2019-2025 SUSE LLC
# Licensed under the terms of the MIT license.

Feature: Sanity checks
Expand All @@ -25,6 +25,7 @@ Feature: Sanity checks
And socket "tftp" is active on "server"
And service "tomcat" is enabled on "server"
And service "tomcat" is active on "server"
And files on container volumes should all have the proper SELinux label

@proxy
Scenario: The proxy is healthy
Expand Down
8 changes: 8 additions & 0 deletions testsuite/features/step_definitions/command_steps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -762,6 +762,14 @@
raise ScriptError, "Service #{service} not active" if output != 'active'
end

Then(/^files on container volumes should all have the proper SELinux label$/) do
node = get_target('server')
cmd = '[ "$(sestatus 2>/dev/null | head -n 1 | grep enabled)" != "" ] && ' \
'(find /var/lib/containers/storage/volumes/*/_data -exec ls -Zd {} \; | grep -v ":object_r:container_file_t:s0 ")'
output, _code = node.run_local(cmd, check_errors: false, verbose: true)
raise ScriptError, 'Wrong SELinux labels' if output != ''
end

When(/^I run "([^"]*)" on "([^"]*)"$/) do |cmd, host|
node = get_target(host)
node.run(cmd)
Expand Down

0 comments on commit 4b50524

Please sign in to comment.