Fix archive.extracted ownership on tarballs with no dir members (#68227)#69428
Open
dwoz wants to merge 1 commit into
Open
Fix archive.extracted ownership on tarballs with no dir members (#68227)#69428dwoz wants to merge 1 commit into
dwoz wants to merge 1 commit into
Conversation
…bers PR saltstack#61896 added a common-prefix fallback to archive.list so that archive.extracted could enforce user/group ownership on top-level directories that aren't listed as their own member in the tarball. That fallback only consulted ret["dirs"], so archives whose members are all files - such as Oracle's GraalVM JDK tarballs, which contain ``graalvm-jdk-21.0.8+12.1/LICENSE.txt`` and friends but no entry for the ``graalvm-jdk-21.0.8+12.1/`` directory itself - still returned ``top_level_dirs=[]`` and silently skipped the ownership enforcement loop in salt/states/archive.py. Include files and links in the common-prefix computation so the top-level directory is discovered regardless of which member types the archive happens to contain. Fixes saltstack#68227
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.
What does this PR do?
Restores
archive.extracted's ability to enforceuser/groupownership on archives whose only members are files. Previously the
common-prefix fallback added in #61896 silently no-op'd for such
archives because it consulted only
ret["dirs"], leaving the extractedtop-level directory owned by
root:root.What issues does this PR fix or reference?
Fixes #68227
Follow-up to #61896 (which fixed #38605 but missed the
no-directory-members case).
Previous Behavior
For tar archives that contain only file members (e.g. Oracle's GraalVM
JDK tarballs, whose listing looks like
graalvm-jdk-21.0.8+12.1/LICENSE.txt, nograalvm-jdk-21.0.8+12.1/entry),
archive.listreturnedtop_level_dirs=[], andarchive.extracted's ownership loop insalt/states/archive.pyhadnothing to iterate over - the extracted directory stayed owned by
root:rootregardless of theuser/grouparguments.New Behavior
archive.listnow feeds files and links into theos.path.commonprefixfallback in addition to dirs, so the shared top-level directory is
discovered regardless of which member types the archive happens to
include.
Merge requirements satisfied?
Commits signed with GPG?
Yes