Repository navigation
Add --no-same-xattrs to untar, and stop dropping xattrs quietly - #406
Merged
Merged
Conversation
Extracting an archive that carries extended attributes did one of three things depending on where it ran. It worked on Linux, macOS and FreeBSD. It failed on NetBSD on a filesystem without extattr support. On OpenBSD and DragonFly it reported success and wrote nothing, because pkg/xattr compiles in stubs that return nil there. The third is the one worth fixing: files end up missing what the archive said they should have, with a zero exit code. Refuse instead, which makes the three cases one, and give the caller a way to say they don't want the attributes. Ownership, permissions and timestamps could all already be opted out of; extended attributes were the exception. The flag is on untar only. tar has no owner or permission flags to match, and its --no-time exists to keep timestamps from churning chunks rather than as a metadata opt-out, so there is nothing on that side to be symmetric with. Existing behaviour worth knowing about, left alone here: --no-same-owner already skips extended attributes too, since all four call sites sit inside that check. That looks deliberate, both needing privileges, but it means --no-same-owner has been a partial opt-out all along. Windows never applied extended attributes, so the flag is accepted and ignored there like the other two.
Failing to write an attribute reported the errno as it came, so the common case - a filesystem with no support for them - surfaced as f: xattr.FSet /mnt/f user.test: operation not supported which names neither the attributes as the cause nor the fact that they can be skipped. It is also the case most people will meet, since it covers vfat and similar under Linux rather than only the two platforms without any support at all, and those two already had a clear message. Reword that one to match, leaving every other failure to read as itself, and keep the errno wrapped so callers can still test for it. Confirmed against a vfat image, which now gives f: extended attributes are not supported by this filesystem: ... The message deliberately doesn't name --no-same-xattrs: nothing else in the library refers to a command line flag, and the reworded text is enough to find it.
folbricht
force-pushed
the
untar-xattrs
branch
from
September 2, 2026 11:12
1f49dec to
72f0eb6
Compare
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.
Extracting an archive carrying extended attributes did one of three things depending on where it ran:
untarof an archive with xattrsThe third row is the problem.
pkg/xattrcompiles in stubs thatreturn nilon those platforms, so files end up missing what the archive said they should have, with a zero exit code. It is the same shape as the device-number bug fixed in #405: doing something other than what the archive asked for, quietly.The change
Refuse rather than pretend, which collapses the three cases into one consistent behaviour, and add
--no-same-xattrsso a caller can decline the attributes deliberately.The flag fills a gap in the existing set — every other class of metadata could already be opted out of:
--no-same-owner--no-same-permissions--no-same-xattrs(new)untaronly.tarhas no owner or permission flags to match, and its--no-timeexists to stop timestamps churning chunks between runs rather than as a metadata opt-out, so there is nothing on that side to be symmetric with.Beyond the BSDs this covers extracting onto any filesystem without xattr support — vfat, or a restricted container build.
Two paths to the same outcome
Failure arrives by one of two routes, and both now say the same kind of thing:
f: extended attributes are not supported on this platformf: extended attributes are not supported by this filesystem: ...The second route already failed before this change —
setXattrshas always propagated that error — but it surfaced as a barexattr.FSet /mnt/f user.test: operation not supported, naming neither the attributes as the cause nor the fact that they can be skipped. It is also the case most people will meet, since it covers Linux. The errno stays wrapped, so callers can still test for it, and every other failure keeps its own wording.Three cases still succeed, by design: an archive that carries no attributes (the common one, so ordinary archives still extract onto vfat),
--no-same-owner(see below), and Windows.Measured against a vfat loop image rather than reasoned about:
xattr.FSet ...: operation not supportedextended attributes are not supported by this filesystem: ...--no-same-xattrs--no-same-ownerNoted, not changed
--no-same-owneralready skips extended attributes as a side effect: all four call sites sit insideif !fs.opts.NoSameOwner. That looks deliberate, since both need privileges, but it does mean--no-same-ownerhas been a partial xattr opt-out all along. Changing it is a separate decision and is left alone here.Windows never applied extended attributes, so the flag is accepted and ignored there, as
--no-same-ownerand--no-same-permissionsalready are.Tests
TestSkipXattrscovers the decision the two setters share, with no actual xattr call — whether one succeeds depends on the filesystem under the test's temp dir, which differs across the CI matrix, so asserting on real attributes would be flaky. It asserts the refusal on platforms wherexattr.XATTR_SUPPORTEDis false, which is what the OpenBSD and DragonFly VM jobs exercise.TestXattrWriteErrorcovers the rewording, including that an unrelated failure such asEACCESis left alone and that the errno stays wrapped.TestCreateFileNoSameXattrsthreads the flag throughCreateFileend to end. The node is owned by the caller so thechownalongside the xattrs succeeds without root, andNoSameOwneris deliberately left off, since turning it on would skip the setters entirely and test nothing.Platform table and generated CLI reference updated.