Restore selinux context when replacing config files #822
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.
Description
Several ASB ModuleTest steps have started failing after the release of RHEL 9.5. Looking into them, I found that they are failing due to issues with selinux file contexts. The failure comes from
chage
when changing password expiration settings, after a previous rule modified/etc/shadow
,/etc/shadow-
,/etc/passwd
,/etc/passwd-
. With additional output fromchage
one can see the following:Looking at syslog shows:
Restoring the selinux context shows that the file has the wrong context after ASB runs:
The selinux context is lost when a temporary file is created to edit the contents of the config file. Restore it after renaming by running
restorecon -F
.Checklist
main
branch prior to this PR submission.main
branch.