bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-tar] Suprising behavior of extract with --xattrs


From: Andreas Dilger
Subject: Re: [Bug-tar] Suprising behavior of extract with --xattrs
Date: Wed, 12 Jun 2019 14:25:23 -0600

On Jun 12, 2019, at 12:15 PM, Brian Murray <address@hidden> wrote:
> 
> On Wed, Jun 12, 2019 at 10:32:22AM -0700, Brian Murray wrote:
>> On Mon, Jun 10, 2019 at 05:49:49PM -0600, Andreas Dilger wrote:
>>> On Jun 3, 2019, at 2:27 PM, Brian Murray <address@hidden> wrote:
>>>> 
>>>> When enabling extended attribute support in a tar file (--xattrs) all
>>>> extended attributes are stored in the archive, however when the same 
>>>> archive
>>>> is extracted only the user.* extended attributes are extracted. To have all
>>>> the extended attributes read and applied on extraction one must also use 
>>>> the
>>>> '--xattrs-include=*' option. I find this behavior surprising and 
>>>> especially so
>>>> given that the documentation indicates that "By default, when `--xattr' is
>>>> used, all names are stored in the archive (or extracted, if using
>>>> `--extract')"[1].
>>>> 
>>>> I'm happy to help working on resolving this issue but it isn't clear to me
>>>> whether the program or the documentation is incorrect. I've read some of 
>>>> this
>>>> mailing list's archive but didn't find an explanation as to why 
>>>> restoration of
>>>> only 'user.*' extended attributes would not be a bug[2].
>>>> 
>>>> [1] https://www.gnu.org/software/tar/manual/tar.html#SEC70
>>>> [2] Which I reported here https://savannah.gnu.org/bugs/index.php?56421
>>> 
>>> As Pavel mentioned, it isn't necessarily safe/correct to extract all xattrs,
>>> especially in cross-platform usage.  However, it *does* make sense to save
>>> all of the xattrs, since it is then possible to extract whichever ones that
>>> are useful.  If the xattrs aren't saved at time of archive creation, they
>>> may be permanently lost.
>> 
>> Thanks for the information Pavel and Andreas. Given what you've said
>> I've created a couple of patches, one for the documentation change and
>> one adding a comment to xattrs.c which clarifies why only user.*
>> extended attributes are extracted by default.
> 
> I'd forgotten about updating the man page for tar, attached you'll find
> a patch for that too.
> 

> diff --git a/doc/tar.1 b/doc/tar.1
> index 18136cf..1bb9d30 100644
> --- a/doc/tar.1
> +++ b/doc/tar.1
> @@ -604,7 +604,9 @@ Enable SELinux context support.
>  Disable SELinux context support.
>  .TP
>  .B \-\-xattrs
> -Enable extended attributes support.
> +Enable extended attributes support. When creating an archive
> +\fB\-\-xattrs\-include\fR defaults to \fB'*'\fR and when extracing an
> +archive \fB\-\-xattrs\-include\fR defaults to \fB'^user.*'\fR.

Since the man page is the primary source of information for most users, I'd
expand this a bit, like "When creating an archive, --xattrs-include defaults
to '*' so that \fBall\fR xattrs are saved into the archive so that any of them
\fImay\fR be extracted later, but when extracting an archive --xattrs-include
defaults to '^user.*' to avoid extracting system-specific xattrs that are not
portable, and may cause errors on some systems.  Multiple '--xattrs-include`
options can be specified.  While ACLs and SELinux labels may be stored on-disk
in xattrs, they are controlled with the '--acl' and '--selinux' options."


Cheers, Andreas





Attachment: signature.asc
Description: Message signed with OpenPGP


reply via email to

[Prev in Thread] Current Thread [Next in Thread]