Emit tar -C option before the source operands in archive.tar (fixes #57847)#69236
Open
ggiesen wants to merge 1 commit into
Open
Emit tar -C option before the source operands in archive.tar (fixes #57847)#69236ggiesen wants to merge 1 commit into
ggiesen wants to merge 1 commit into
Conversation
archive.tar appended "-C <dest>" after the source/member operands. tar (GNU, BSD and macOS) treats -C as positional in create and extract modes: it only affects the operands that follow it, so placing it last silently had no effect, or errored on newer GNU tar. This is the root cause behind the genesis.pack failure reported in saltstack#57847. genesis has since been removed from Salt core, but the archive.tar bug remains and breaks any pack with a dest, or extraction of specific members into a dest directory. Emit "-C <dest>" before the operands so it takes effect. The documented extract-into-dest case (no source members) is byte-for-byte unchanged.
4df88f5 to
901be04
Compare
Contributor
Author
|
Re-targeted to 3006.x (was master): this is a bug fix and 3006.x is the oldest supported branch that contains the affected |
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?
Fixes
archive.taremitting the-C <dest>directory-change option after the source/member operands. tar (GNU, BSD and macOS) treats-Cas positional in both create and extract modes -- it only affects the operands that follow it -- so when it is placed last it silently has no effect, or errors on newer GNU tar:The option is now emitted before the operands so it takes effect.
What issues does this PR fix or reference?
Fixes #57847
That issue was reported against
genesis.pack, which calledarchive.tar(..., sources=".", dest=root)and ended up archiving the wrong directory (root's home) because-C rootcame after the.operand.genesishas since been removed from Salt core (dc526dc, "Initial purge of community extensions"), but the underlyingarchive.tarbug -- which is the root cause the reporter identified -- is still present and affects any create-with-destcall, or extraction of specific members into adestdirectory.Previous Behavior
-Cafter the operands is ignored (or fatal on newer GNU tar), so the wrong directory is packed/extracted.New Behavior
The documented extract-into-dest case with no source members (
tar xf foo.tar dest=/d->tar xf foo.tar -C /d) is byte-for-byte unchanged.Merge requirements satisfied?
[NOTICE] Bug fixes or features added to Salt require tests.
changelog/57847.fixed.mdtests/pytests/unit/modules/test_archive.py(test_tar_dest_precedes_sources_on_create,..._on_extract,test_tar_dest_without_sources; verified the two ordering tests fail on current master and pass with this change, with no change to the existingtest_tar)Commits signed with GPG?
No