Blame SOURCES/tar-1.26-docu-xattrs.patch

b77676
diff --git a/doc/tar.texi b/doc/tar.texi
b77676
index d678db9..ab8a0c8 100644
b77676
--- a/doc/tar.texi
b77676
+++ b/doc/tar.texi
b77676
@@ -37,7 +37,8 @@ This manual is for @acronym{GNU} @command{tar} (version
b77676
 from archives.
b77676
 
b77676
 Copyright @copyright{} 1992, 1994, 1995, 1996, 1997, 1999, 2000, 2001,
b77676
-2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
b77676
+2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012 Free Software
b77676
+Foundation, Inc.
b77676
 
b77676
 @quotation
b77676
 Permission is granted to copy, distribute and/or modify this document
b77676
@@ -162,6 +163,7 @@ How to Create Archives
b77676
 How to List Archives
b77676
 
b77676
 * list dir::
b77676
+* List Extended Attributes::
b77676
 
b77676
 How to Extract Members from an Archive
b77676
 
b77676
@@ -1492,6 +1494,7 @@ for a detailed discussion of globbing patterns and related
b77676
 
b77676
 @menu
b77676
 * list dir::
b77676
+* List Extended Attributes::
b77676
 @end menu
b77676
 
b77676
 @node list dir
b77676
@@ -1522,6 +1525,116 @@ drwxrwxrwx myself/user       0 1990-05-31 21:49 practice/
b77676
 When you use a directory name as a file name argument, @command{tar} acts on
b77676
 all the files (including sub-directories) in that directory.
b77676
 
b77676
+@node List Extended Attributes
b77676
+@unnumberedsubsec Listing xattrs, POSIX ACLs and SELinux context
b77676
+
b77676
+From upstream GNU tar 1.26.9, tar is able to store, extract and list extended
b77676
+file attributes.  Listing of those attributes is then active only in verbose and
b77676
+double-verbose mode.
b77676
+
b77676
+This section exercises how to list attributes on examples.  Lets start with
b77676
+simple verbose mode.  This output is inspired by GNU @command{ls -l} command
b77676
+output.
b77676
+
b77676
+@itemize @bullet
b77676
+@item
b77676
+Show only pure extended attributes.
b77676
+
b77676
+@smallexample
b77676
+$ tar --xattrs --list -v archive.tar
b77676
+-rw-rwxr--  user/group 0 2012-08-08 15:15 acls.txt
b77676
+-rw-rw-r--* user/group 0 2012-08-08 15:15 xattrs.txt
b77676
+@end smallexample
b77676
+
b77676
+Note the asterisk on the third line!  It reflects the situation that the file
b77676
+'xattrs.txt' has some extended attribute set.  The default mode (same as if you
b77676
+are extracting extended attributes) shows information only about extended
b77676
+attributes from 'user.*' domain.  Anyway, feel free to change the sensitivity
b77676
+using @option{--xattrs-include} or @option{--xattrs-exclude} options.
b77676
+
b77676
+@item Show only POSIX ACLs - the character you should look for is '+':
b77676
+
b77676
+@smallexample
b77676
+$ tar --acls --list -v archive.tar
b77676
+-rw-rwxr--+ praiskup/praiskup 0 2012-08-08 15:15 acls.txt
b77676
+-rw-rw-r--  praiskup/praiskup 0 2012-08-08 15:15 xattrs.txt
b77676
+@end smallexample
b77676
+
b77676
+@item Show only SELinux - the key character is '.':
b77676
+
b77676
+@smallexample
b77676
+$ tar --selinux --list -v archive.tar
b77676
+-rw-rw-r--.  praiskup/praiskup 0 2012-08-08 15:16 selinux_only.txt
b77676
+-rw-rw-r--   praiskup/praiskup 0 2012-08-08 15:15 xattrs.txt
b77676
+@end smallexample
b77676
+
b77676
+@item
b77676
+Show info about ACLs, SELinux and general extended attributes together:
b77676
+
b77676
+@smallexample
b77676
+$ tar --selinux --acls --xattrs --list -v archive.tar
b77676
+-rw-rw-r--. praiskup/praiskup 0 2012-08-08 15:16 selinux_only.txt
b77676
+-rw-rwxr--+ praiskup/praiskup 0 2012-08-08 15:15 acls.txt
b77676
+-rw-rw-r--. praiskup/praiskup 0 2012-08-08 15:15 xattrs.txt
b77676
+@end smallexample
b77676
+
b77676
+In this case, the priority of character is '+' > '.' > '*'.  You don't see the
b77676
+general extended attributes flag ('*' character) on this example because it is
b77676
+hidden by '.' (meaning that the file has SELinux context set).
b77676
+
b77676
+@end itemize
b77676
+
b77676
+The example of double verbose mode is here.  In this output the single verbose
b77676
+characters '.', '+' and '*' are also present after the permission string.
b77676
+
b77676
+@smallexample
b77676
+$ tar --xattrs --selinux --acls -tvvf archive.tar
b77676
+-rw-rw-r--. praiskup/praiskup 0 2012-08-08 15:16 selinux_only.txt
b77676
+  s: unconfined_u:object_r:user_tmp_t:s0
b77676
+-rw-rwxr--+ praiskup/praiskup 0 2012-08-08 15:15 acls.txt
b77676
+  s: unconfined_u:object_r:user_tmp_t:s0
b77676
+  a: user::rw-,user:tester:rwx,group::rw-,mask::rwx,other::r--
b77676
+-rw-rw-r--. praiskup/praiskup 0 2012-08-08 15:15 xattrs.txt
b77676
+  s: unconfined_u:object_r:user_tmp_t:s0
b77676
+  x: 12 user.xattr
b77676
+  x: 12 user.we_like_tar
b77676
+@end smallexample
b77676
+
b77676
+This mode extends tar's output with additional lines beginning with
b77676
+distinguishing characters - 's' for SELinux context, 'a' for POSIX Access
b77676
+Control Lists  and 'x' for generic extended attributes.
b77676
+
b77676
+In this format, POSIX ACLs are written in SHORT TEXT FORM as specified in manual
b77676
+page @command{man 5 acl}.
b77676
+
b77676
+Use the @option{--xattrs-include} again if you want to print other than default
b77676
+'user.*' extended attributes domain:
b77676
+
b77676
+@smallexample
b77676
+$ tar --xattrs --xattrs-include='*' --acls --selinux -tvvf archive.tar
b77676
+-rw-rw-r--. praiskup/praiskup 0 2012-08-08 15:16 selinux_only.txt
b77676
+  s: unconfined_u:object_r:user_tmp_t:s0
b77676
+  x: 36 security.selinux
b77676
+-rw-rwxr--+ praiskup/praiskup 0 2012-08-08 15:15 acls.txt
b77676
+  s: unconfined_u:object_r:user_tmp_t:s0
b77676
+  a: user::rw-,user:tester:rwx,group::rw-,mask::rwx,other::r--
b77676
+  x: 36 security.selinux
b77676
+  x: 44 system.posix_acl_access
b77676
+-rw-rw-r--. praiskup/praiskup 0 2012-08-08 15:15 xattrs.txt
b77676
+  s: unconfined_u:object_r:user_tmp_t:s0
b77676
+  x: 36 security.selinux
b77676
+  x: 12 user.xattr
b77676
+  x: 12 user.we_like_tar
b77676
+@end smallexample
b77676
+
b77676
+As is in @pxref{Option Summary} section described, tar by default stores all
b77676
+extended attributes that are available (not only 'user.*' domain).  It means
b77676
+that the SELinux context and POSIX ACLs (because they are implemented using the
b77676
+generic extended attributes on usual file system) may be stored twice sometimes
b77676
+-- firstly in "raw" file system binary format and secondly in more portable way
b77676
+-- using appropriate system calls (invoked by @command{tar} options
b77676
+@option{--selinux} and @option{--acls}).
b77676
+
b77676
 @node extract
b77676
 @section How to Extract Members from an Archive
b77676
 @cindex Extraction
b77676
@@ -2371,6 +2484,10 @@ Normally when creating an archive, @command{tar} strips an initial
b77676
 @samp{/} from member names.  This option disables that behavior.
b77676
 @xref{absolute}.
b77676
 
b77676
+@opsummary{acls}
b77676
+@item --acls
b77676
+Causes @command{tar} to store/restore/list POSIX ACL's.  @xref{Attributes}.
b77676
+
b77676
 @opsummary{after-date}
b77676
 @item --after-date
b77676
 
b77676
@@ -2919,6 +3036,11 @@ contents have changed (as opposed to just @option{--newer}, which will
b77676
 also back up files for which any status information has
b77676
 changed).  @xref{after}.
b77676
 
b77676
+@opsummary{no-acls}
b77676
+@item --no-acls
b77676
+Causes @command{tar} not to store, extract or list POSIX ACL's.
b77676
+@xref{Attributes}.
b77676
+
b77676
 @opsummary{no-anchored}
b77676
 @item --no-anchored
b77676
 An exclude pattern can match any subsequence of the name's components.
b77676
@@ -3002,11 +3124,20 @@ locations.  Usually @command{tar} determines automatically whether
b77676
 the archive can be seeked or not.  Use this option to disable this
b77676
 mechanism.
b77676
 
b77676
+@opsummary{no-selinux}
b77676
+@item --no-selinux
b77676
+Causes @command{tar} not to store, extract or list SELinux security context.
b77676
+@xref{Attributes}.
b77676
+
b77676
 @opsummary{no-unquote}
b77676
 @item --no-unquote
b77676
 Treat all input file or member names literally, do not interpret
b77676
 escape sequences.  @xref{input name quoting}.
b77676
 
b77676
+@opsummary{no-xattrs}
b77676
+@item --no-xattrs
b77676
+Causes @command{tar} not to store, extract or list xattrs.  @xref{Attributes}.
b77676
+
b77676
 @opsummary{no-wildcards}
b77676
 @item --no-wildcards
b77676
 Do not use wildcards.
b77676
@@ -3239,6 +3370,11 @@ in cases when such recognition fails.  It takes effect only if the
b77676
 archive is open for reading (e.g. with @option{--list} or
b77676
 @option{--extract} options).
b77676
 
b77676
+@opsummary{selinux}
b77676
+@item --selinux
b77676
+Causes @command{tar} to store, extract or list SELinux security context.
b77676
+@xref{Attributes}.
b77676
+
b77676
 @opsummary{show-defaults}
b77676
 @item --show-defaults
b77676
 
b77676
@@ -3466,6 +3602,11 @@ Enable or disable warning messages identified by @var{keyword}.  The
b77676
 messages are suppressed if @var{keyword} is prefixed with @samp{no-}.
b77676
 @xref{warnings}.
b77676
 
b77676
+@opsummary{xattrs}
b77676
+@item --xattrs
b77676
+Causes @command{tar} to store, restore or list extended file attributes.  For
b77676
+more info see @xref{Attributes}.
b77676
+
b77676
 @opsummary{wildcards}
b77676
 @item --wildcards
b77676
 Use wildcards when matching member names with patterns.
b77676
@@ -4218,6 +4359,11 @@ tar (child): trying gzip
b77676
 This means that @command{tar} first tried to decompress
b77676
 @file{archive.Z} using @command{compress}, and, when that
b77676
 failed, switched to @command{gzip}.
b77676
+@kwindex xattr-write
b77676
+@item xattr-write
b77676
+@samp{%s: Cannot set '%s' extended attribute for file '%s'}
b77676
+@*@samp{%s: Cannot set POSIX ACLs for file '%s'}
b77676
+@*@samp{%s: Cannot set SELinux context for file '%s'}
b77676
 @end table
b77676
 
b77676
 @subheading Keywords controlling incremental extraction:
b77676
@@ -8770,6 +8916,8 @@ implementation able to read @samp{ustar} archives will be able to read
b77676
 most @samp{posix} archives as well, with the only exception that any
b77676
 additional information (such as long file names etc.) will in such
b77676
 case be extracted as plain text files along with the files it refers to.
b77676
+This is the only format that can store ACLs, SELinux context and extended
b77676
+attributes.
b77676
 
b77676
 This archive format will be the default format for future versions
b77676
 of @GNUTAR{}.
b77676
@@ -9412,6 +9560,135 @@ Same as both @option{--same-permissions} and @option{--same-order}.
b77676
 
b77676
 This option is deprecated, and will be removed in @GNUTAR{} version 1.23.
b77676
 
b77676
+@opindex xattrs
b77676
+@item --xattrs
b77676
+This option causes @command{tar} to store, restore or list the extended file
b77676
+attributes (for information about extended attributes see @command{man(5)
b77676
+attr}).
b77676
+
b77676
+Note that all extended attributes are stored "as-is" (in file system binary
b77676
+format) and the resulting archive may be not fully portable.  See the
b77676
+@option{--selinux} and @option{--acls} options when you want to deal with these
b77676
+types of extended attributes in a better way.
b77676
+
b77676
+The @option{--xattrs} option implies the option @option{--format=posix} when
b77676
+tar is in @option{--create} operation mode.  It is the only one format which
b77676
+hase usable headers for storing additional file information like extended
b77676
+attributes are.
b77676
+
b77676
+By default, all extended attributes are stored into the archive.  The reason is
b77676
+that we want to make the backup process as complete as possible by default.  On
b77676
+the other hand, during extracting only the 'user.*' domain is extracted by
b77676
+default.  Anyway, this default behaviour may be easily modified by the
b77676
+@option{--xattrs-include} and @option{--xattrs-exclude} options.
b77676
+
b77676
+When you list an archive in verbose mode
b77676
+(@command{tar --xattrs --verbose -tf archive.tar}), tar shows the '*' character
b77676
+after the permissions string of concrete file ringht to tell you that at least
b77676
+one extended attribute is stored with corresponding file.
b77676
+
b77676
+Double verbose mode (@command{tar --xattrs -tvvf archive.tar}) prints the
b77676
+extended attribute length (in bytes) and its ASCII key (for printed examples
b77676
+@pxref{List Extended Attributes}).
b77676
+
b77676
+@option{--xattrs} option has no equivalent short option.
b77676
+
b77676
+Warnings which occur during impossible writing of extended attributes to
b77676
+a file system may be suppressed using the @option{--warning=no-xattr-write}
b77676
+option.
b77676
+
b77676
+@opindex no-xattrs
b77676
+@item --no-xattrs
b77676
+This option causes @command{tar} not to store/extract or list the current
b77676
+extended attributes.  This option does not affect options @option{--no-selinux}
b77676
+or @option{--no-acls}.
b77676
+
b77676
+The @option{--no-xattrs} option has no equivalent short option name.
b77676
+
b77676
+@opindex xattrs-include
b77676
+@opindex xattrs-exclude
b77676
+@item --xattrs-include=MASK
b77676
+@itemx --xattrs-exclude=MASK
b77676
+
b77676
+These options allows the xattr store/restore/list process to be more fine
b77676
+grained.  The default configuration is that @option{--create} mode handles all
b77676
+available extended attributes and the @option{--extract}/@option{--list} mode
b77676
+handles only 'user.*' domain.  These options may be used for editing of this
b77676
+default behaviour.
b77676
+
b77676
+@itemize @bullet
b77676
+@item
b77676
+Lets say we want to store all attributes except some "public restricted" domain
b77676
+(e.g.  'user.restricted.*' domain.  The correct way how to do it is:
b77676
+
b77676
+@command{tar --xattrs --xattrs-include='*' --xattrs-exclude='user.restricted.*'
b77676
+-cf archive.tar FILES}
b77676
+@item
b77676
+And, when we want to extract only some specific domain from an archive - we can
b77676
+use:
b77676
+
b77676
+@command{tar --xattrs --xattrs-include='security.capability' -xf archive.tar
b77676
+FILES}
b77676
+@end itemize
b77676
+
b77676
+Multiple passed include/exclude patterns are combined together.  The attribute
b77676
+is covered then only if (1) at least one of all include patterns matches its
b77676
+keyword and (2) no exclude pattern matches its keyword.
b77676
+
b77676
+When only include pattern is set - exclude pattern is left in default mode (and
b77676
+vice versa).
b77676
+
b77676
+@opindex selinux
b77676
+@item --selinux
b77676
+This option causes @command{tar} to store/extract/list the SELinux context
b77676
+information into/from an archive.  Command @command{tar} is able to show info
b77676
+whether the SELinux context is present in archived file using the verbose
b77676
+listing mode (@command{tar --selinux -tvf archive.tar}).  It shows the '.'
b77676
+character after permission string in that case.  Double-verbose listing mode
b77676
+(@command{tar -tvvf archive.tar}) then prints the full SELinux context to
b77676
+standard output, @pxref{List Extended Attributes} for printed example.
b77676
+
b77676
+This option implies the @option{--format=posix} when @command{tar} works in
b77676
+@option{--create} operation mode.
b77676
+
b77676
+Warnings complaining that SELinux context may not be written to a file system
b77676
+may be suppressed by the @option{--warning=no-xattr-write} option.
b77676
+
b77676
+The @option{--selinux} option has no equivalent short option name.
b77676
+
b77676
+@opindex no-selinux
b77676
+@item --no-selinux
b77676
+This option causes @command{tar} not to store the current SELinux security
b77676
+context information in the archive and not to extract any SELinux information in
b77676
+an archive.
b77676
+
b77676
+The @option{--no-selinux} option has no equivalent short option name.
b77676
+
b77676
+@opindex acls
b77676
+@item --acls
b77676
+This option causes @command{tar} to store the current POSIX access control lists
b77676
+into the archive or restore POSIX ACLs from an archive.  It also allows
b77676
+@command{tar} to show whether archived file contains ACLs when the verbose mode
b77676
+is active (@option{tar --acls -tvf} shows the symbol '+' after the permission
b77676
+characters in that case).  Double-verbose mode allows @command{tar} to list
b77676
+contained POSIX ACLs (@command{tar --acls -tvvf archive.tar}), for printed
b77676
+examples @pxref{List Extended Attributes}.
b77676
+
b77676
+This option implies the @option{--format=posix} when @command{tar} works in
b77676
+@option{--create} operation mode.
b77676
+
b77676
+Warnings complaining that POSIX ACLs may not be written to a file system may be
b77676
+suppressed by the @option{--warning=no-xattr-write} option.
b77676
+
b77676
+The @option{--acls} option has no equivalent short form.
b77676
+
b77676
+@opindex no-acls
b77676
+@item --no-acls
b77676
+This option causes @command{tar} not to store the current POSIX ACL into the
b77676
+archive and not to extract any POSIX ACL information from an archive.
b77676
+
b77676
+The @option{--no-acls} option has no equivalent short option name.
b77676
+
b77676
 @end table
b77676
 
b77676
 @node Portability