Perform selabel lookup during file resource synchronization #229
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The default values of the SELinux-related properties of a file resource are calculated at the beginning of the catalog application phase, before the catalog resources are actually synchronized. However, by the time the file resource is synchronized, these default values might be outdated due to new policy rules being added in previous parts of the catalog.
This behavior can be easily reproduced in Rocky Linux 9 and probably other RHEL-like distros (maybe even Fedora):
The
testfile is created with the wrong SELinux context because:seltypeproperty is calculated before thegrafanapackage is installed.grafanapackage is then installed, pulling in thegrafana-selinuxpackage, which in turn creates thegrafana_var_lib_ttype.testfile is created using an outdated SELinux type.This PR fixes the described behavior:
This PR also adjusts the corresponding unit tests accordingly. As far as I cat tell, all the relevant tests pass:
More details about the actual changes can be found in the commit description.