Skip to content

Commit

Permalink
[issue sous-chefs#119] Update fcontext to allow override of built-in …
Browse files Browse the repository at this point in the history
…types

Signed-off-by: Yansheng Wei <[email protected]>
  • Loading branch information
ywei2017 committed Apr 23, 2024
1 parent 415cf27 commit 549a5b5
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion resources/fcontext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,14 @@ def relabel_files
return
end

unless current_file_context
# "add" is performed in two scenarios.
# 1: The local file_contexts.local has an entry for new_resource.file_spec, but secontext <> new_resource.secontext
# 2. The local file_contexts.local does NOT have an entry for new_resource.file_spec, AND
# either the system default (file_contexts) does not have an entry for new_resource.file_spec, or the secontext <> new_resource.secontext
# In both scenarios, file_contexts.local is created with a new entry, or the secontext is updated.

cfc = current_file_context
unless cfc && cfc == new_resource.secontext
converge_by "adding label #{new_resource.secontext} to #{new_resource.file_spec}" do
shell_out!("semanage fcontext -a -f #{new_resource.file_type} -t #{new_resource.secontext} '#{new_resource.file_spec}'")
relabel_files
Expand Down

0 comments on commit 549a5b5

Please sign in to comment.