Forward SELinux relabel flags for non-bind mounts - #1538
Open
Sanjays2402 wants to merge 1 commit into
Open
Conversation
The short volume syntax parser stores z/Z from a mount spec like db:/var/lib/mysql:Z as a bind propagation option. Since --mount became the default for named volumes, mount_desc_to_mount_args() only read the selinux option for bind mounts, so the relabel flag was silently dropped and the container got an unlabeled volume. Forward z/Z for the other mount types too, mirroring what mount_desc_to_volume_args() already does for the -v syntax. Closes containers#1516 Signed-off-by: Sanjay Santhanam <51058514+Sanjays2402@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Closes #1516
Contributor Checklist:
Please make sure to read development guidelines in CONTRIBUTING.md.
Compose spec for the short volume syntax the relabel flag comes from:
https://github.com/compose-spec/compose-spec/blob/main/spec.md#short-syntax-5
For any user-visible change please add a release note to newsfragments directory.
I could not add the
newsfragments/*.bugfixfile from my side; please tell me if you want me topush one, or feel free to add it with this text: "The SELinux relabel flags
zandZgiven inthe short volume syntax are no longer dropped for named volumes when the mount is passed to podman
as
--mount."All changes require additional unit tests.
Added
test_selinux_named_volume_short_syntaxintests/unit/test_container_to_args.py, next tothe existing
test_selinux_volume. It fails on main (the,Zis missing from the generated--mountargument) and passes with the fix;python -m unittest discover tests/unitis green(480 tests), and
ruff format --check/ruff checkare clean on both changed files.parse_short_mountstores thez/Zofdb:/var/lib/mysql:Zas a bind propagation option. Since--mountbecame the default for named volumes,mount_desc_to_mount_args()only read the selinuxoption for bind mounts, so the relabel flag was silently dropped — which is the 1.5.0 → 1.6.0
regression reported in #1516. This forwards
z/Zfor the other mount types too, mirroring whatmount_desc_to_volume_args()already does for the-vsyntax.This change was prepared with AI assistance; the regression test was run locally and fails without the fix.