On Mon, Jun 10, 2019 at 05:49:49PM -0600, Andreas Dilger wrote:
> On Jun 3, 2019, at 2:27 PM, Brian Murray <br...@ubuntu.com> 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.

Cheers,
--
Brian Murray
diff --git a/doc/tar.texi b/doc/tar.texi
index 0296c42..843e96d 100644
--- a/doc/tar.texi
+++ b/doc/tar.texi
@@ -5648,9 +5648,9 @@ Disable extended attributes support.  This is the default.
 Attribute names are strings prefixed by a @dfn{namespace} name and a dot.
 Currently, four namespaces exist: @samp{user}, @samp{trusted},
 @samp{security} and @samp{system}.  By default, when @option{--xattr}
-is used, all names are stored in the archive (or extracted, if using
-@option{--extract}).  This can be controlled using the following
-options:
+is used, all names are stored in the archive. However, when using
+@option{--extract} only @samp{user} is extracted by default).  This can
+be controlled using the following options:
 
 @table @option
 @item --xattrs-exclude=@var{pattern}
diff --git a/src/xattrs.c b/src/xattrs.c
index df65460..ed8d4e5 100644
--- a/src/xattrs.c
+++ b/src/xattrs.c
@@ -636,6 +636,9 @@ xattrs_matches_mask (const char *kw, struct xattrs_mask_map *mm)
   return false;
 }
 
+/* during extraction xattrs are checked against the user supplied
+   include/exclude mask but if no mask is given then only the user.*
+   domain is included as it may not be compatible across platforms. */
 #define USER_DOT_PFX "user."
 
 static bool

Reply via email to