diff --git a/tar-1.19-xattrs-conf.patch b/tar-1.19-xattrs-conf.patch index b66682d..ada7917 100644 --- a/tar-1.19-xattrs-conf.patch +++ b/tar-1.19-xattrs-conf.patch @@ -1,7 +1,7 @@ -diff -up tar-1.19/config.hin.xattrs-conf tar-1.19/config.hin ---- tar-1.19/config.hin.xattrs-conf 2007-10-10 13:01:17.000000000 +0200 -+++ tar-1.19/config.hin 2007-12-17 11:47:38.000000000 +0100 -@@ -121,6 +121,9 @@ +diff -urNp tar-1.22-orig/config.hin tar-1.22/config.hin +--- tar-1.22-orig/config.hin 2009-03-05 08:08:07.000000000 +0100 ++++ tar-1.22/config.hin 2009-03-05 09:57:06.000000000 +0100 +@@ -131,6 +131,9 @@ */ #undef HAVE_ALLOCA_H @@ -11,7 +11,7 @@ diff -up tar-1.19/config.hin.xattrs-conf tar-1.19/config.hin /* Define to 1 if you have the `btowc' function. */ #undef HAVE_BTOWC -@@ -354,12 +357,21 @@ +@@ -372,12 +375,21 @@ /* Define to 1 if you have the header file. */ #undef HAVE_FEATURES_H @@ -33,7 +33,7 @@ diff -up tar-1.19/config.hin.xattrs-conf tar-1.19/config.hin /* Define to 1 if fseeko (and presumably ftello) exists and is declared. */ #undef HAVE_FSEEKO -@@ -399,6 +411,9 @@ +@@ -423,6 +435,9 @@ /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY @@ -43,7 +43,7 @@ diff -up tar-1.19/config.hin.xattrs-conf tar-1.19/config.hin /* Define to 1 if you have the header file. */ #undef HAVE_GRP_H -@@ -444,15 +459,30 @@ +@@ -468,15 +483,30 @@ /* Define to 1 if you have the `lchown' function. */ #undef HAVE_LCHOWN @@ -55,10 +55,10 @@ diff -up tar-1.19/config.hin.xattrs-conf tar-1.19/config.hin + /* Define to 1 if you have the header file. */ #undef HAVE_LIBINTL_H -+ + +/* Define to 1 if you have the `selinux' library (-lselinux). */ +#undef HAVE_LIBSELINUX - ++ /* Define to 1 if you have the header file. */ #undef HAVE_LINEWRAP_H @@ -74,7 +74,7 @@ diff -up tar-1.19/config.hin.xattrs-conf tar-1.19/config.hin /* Define to 1 if you have the header file. */ #undef HAVE_LOCALE_H -@@ -462,6 +492,9 @@ +@@ -486,6 +516,9 @@ /* Define to 1 if the system has the type `long long int'. */ #undef HAVE_LONG_LONG_INT @@ -84,7 +84,7 @@ diff -up tar-1.19/config.hin.xattrs-conf tar-1.19/config.hin /* Define to 1 if you have the `lstat' function. */ #undef HAVE_LSTAT -@@ -568,12 +601,18 @@ +@@ -589,12 +622,18 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SEARCH_H @@ -103,7 +103,7 @@ diff -up tar-1.19/config.hin.xattrs-conf tar-1.19/config.hin /* Define to 1 if you have the header file. */ #undef HAVE_SGTTY_H -@@ -713,6 +752,9 @@ +@@ -734,6 +773,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_SYSEXITS_H @@ -113,7 +113,7 @@ diff -up tar-1.19/config.hin.xattrs-conf tar-1.19/config.hin /* Define to 1 if you have the header file. */ #undef HAVE_SYS_BITYPES_H -@@ -861,6 +903,9 @@ +@@ -891,6 +933,9 @@ /* Define if utimes works properly. */ #undef HAVE_WORKING_UTIMES @@ -123,10 +123,10 @@ diff -up tar-1.19/config.hin.xattrs-conf tar-1.19/config.hin /* Define to 1 if the system has the type `_Bool'. */ #undef HAVE__BOOL -diff -up tar-1.19/configure.xattrs-conf tar-1.19/configure ---- tar-1.19/configure.xattrs-conf 2007-10-10 13:00:16.000000000 +0200 -+++ tar-1.19/configure 2007-12-17 11:47:14.000000000 +0100 -@@ -1963,6 +1964,9 @@ ac_header_list="$ac_header_list sys/tpri +diff -urNp tar-1.22-orig/configure tar-1.22/configure +--- tar-1.22-orig/configure 2009-03-05 08:05:20.000000000 +0100 ++++ tar-1.22/configure 2009-03-05 09:57:06.000000000 +0100 +@@ -2127,6 +2127,9 @@ ac_header_list="$ac_header_list sys/tpri ac_header_list="$ac_header_list sys/tape.h" ac_header_list="$ac_header_list unistd.h" ac_header_list="$ac_header_list locale.h" @@ -136,7 +136,7 @@ diff -up tar-1.19/configure.xattrs-conf tar-1.19/configure ac_func_list="$ac_func_list flockfile" ac_func_list="$ac_func_list funlockfile" ac_header_list="$ac_header_list features.h" -@@ -5614,7 +5633,14 @@ return strerror (); +@@ -6022,7 +6025,14 @@ return strerror (); return 0; } _ACEOF @@ -152,7 +152,7 @@ diff -up tar-1.19/configure.xattrs-conf tar-1.19/configure if { (ac_try="$ac_link" case "(($ac_try" in *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; -@@ -5632,25 +5658,35 @@ eval "echo \"\$as_me:$LINENO: $ac_try_ec +@@ -6040,25 +6050,35 @@ eval "echo \"\$as_me:$LINENO: $ac_try_ec test ! -s conftest.err } && test -s conftest$ac_exeext && $as_test_x conftest$ac_exeext; then @@ -197,7 +197,7 @@ diff -up tar-1.19/configure.xattrs-conf tar-1.19/configure { echo "$as_me:$LINENO: checking for inline" >&5 echo $ECHO_N "checking for inline... $ECHO_C" >&6; } -@@ -32646,6 +32690,257 @@ _ACEOF +@@ -38773,6 +38793,257 @@ _ACEOF fi done @@ -455,7 +455,7 @@ diff -up tar-1.19/configure.xattrs-conf tar-1.19/configure { echo "$as_me:$LINENO: checking whether getgrgid is declared" >&5 echo $ECHO_N "checking whether getgrgid is declared... $ECHO_C" >&6; } if test "${ac_cv_have_decl_getgrgid+set}" = set; then -@@ -34374,6 +34669,296 @@ fi +@@ -40571,6 +40842,296 @@ fi done @@ -752,10 +752,10 @@ diff -up tar-1.19/configure.xattrs-conf tar-1.19/configure { echo "$as_me:$LINENO: checking for iconv_t" >&5 echo $ECHO_N "checking for iconv_t... $ECHO_C" >&6; } if test "${ac_cv_type_iconv_t+set}" = set; then -diff -urNp tar-1.20-orig/src/Makefile.in tar-1.20/src/Makefile.in ---- tar-1.20-orig/src/Makefile.in 2008-04-14 14:04:00.000000000 +0200 -+++ tar-1.20/src/Makefile.in 2008-05-26 18:18:42.000000000 +0200 -@@ -137,7 +137,8 @@ am_tar_OBJECTS = buffer.$(OBJEXT) checkp +diff -urNp tar-1.22-orig/src/Makefile.in tar-1.22/src/Makefile.in +--- tar-1.22-orig/src/Makefile.in 2009-03-05 08:05:26.000000000 +0100 ++++ tar-1.22/src/Makefile.in 2009-03-05 09:57:06.000000000 +0100 +@@ -143,7 +143,8 @@ am_tar_OBJECTS = buffer.$(OBJEXT) checkp extract.$(OBJEXT) xheader.$(OBJEXT) incremen.$(OBJEXT) \ list.$(OBJEXT) misc.$(OBJEXT) names.$(OBJEXT) sparse.$(OBJEXT) \ suffix.$(OBJEXT) system.$(OBJEXT) tar.$(OBJEXT) \ @@ -765,7 +765,7 @@ diff -urNp tar-1.20-orig/src/Makefile.in tar-1.20/src/Makefile.in tar_OBJECTS = $(am_tar_OBJECTS) am__DEPENDENCIES_1 = am__DEPENDENCIES_2 = ../lib/libtar.a $(am__DEPENDENCIES_1) \ -@@ -526,7 +527,7 @@ sysconfdir = @sysconfdir@ +@@ -653,7 +654,7 @@ sysconfdir = @sysconfdir@ target_alias = @target_alias@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ @@ -774,7 +774,7 @@ diff -urNp tar-1.20-orig/src/Makefile.in tar-1.20/src/Makefile.in tar_SOURCES = \ buffer.c\ checkpoint.c\ -@@ -545,11 +546,12 @@ tar_SOURCES = \ +@@ -672,11 +673,12 @@ tar_SOURCES = \ tar.c\ transform.c\ update.c\ @@ -789,7 +789,7 @@ diff -urNp tar-1.20-orig/src/Makefile.in tar-1.20/src/Makefile.in all: all-am .SUFFIXES: -@@ -649,6 +651,7 @@ distclean-compile: +@@ -776,6 +778,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/transform.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/update.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/utf8.Po@am__quote@ diff --git a/tar-1.19-xattrs.patch b/tar-1.19-xattrs.patch index 0c3dc43..49ba87e 100644 --- a/tar-1.19-xattrs.patch +++ b/tar-1.19-xattrs.patch @@ -1,6 +1,6 @@ -diff -up tar-1.17/configure.ac.xattrs tar-1.17/configure.ac ---- tar-1.17/configure.ac.xattrs 2007-06-08 10:28:04.000000000 +0200 -+++ tar-1.17/configure.ac 2007-12-10 15:31:54.000000000 +0100 +diff -urp tar-1.22-orig/configure.ac tar-1.22/configure.ac +--- tar-1.22-orig/configure.ac 2009-03-05 08:01:58.000000000 +0100 ++++ tar-1.22/configure.ac 2009-03-05 09:45:42.000000000 +0100 @@ -40,7 +40,7 @@ AC_CHECK_HEADERS_ONCE(fcntl.h linux/fd.h sys/param.h sys/device.h sys/filio.h sys/gentape.h \ sys/inet.h sys/io/trioctl.h \ @@ -33,9 +33,9 @@ diff -up tar-1.17/configure.ac.xattrs tar-1.17/configure.ac AC_CHECK_TYPE(iconv_t,:, AC_DEFINE(iconv_t, int, [Conversion descriptor type]), -diff -up tar-1.17/doc/tar.texi.xattrs tar-1.17/doc/tar.texi ---- tar-1.17/doc/tar.texi.xattrs 2007-06-08 10:25:19.000000000 +0200 -+++ tar-1.17/doc/tar.texi 2007-12-10 15:31:54.000000000 +0100 +diff -urp tar-1.22-orig/doc/tar.texi tar-1.22/doc/tar.texi +--- tar-1.22-orig/doc/tar.texi 2009-03-05 08:04:13.000000000 +0100 ++++ tar-1.22/doc/tar.texi 2009-03-05 09:45:42.000000000 +0100 @@ -2345,6 +2345,10 @@ Normally when creating an archive, @comm @samp{/} from member names. This option disables that behavior. @xref{absolute}. @@ -47,7 +47,7 @@ diff -up tar-1.17/doc/tar.texi.xattrs tar-1.17/doc/tar.texi @opsummary{after-date} @item --after-date -@@ -2838,6 +2842,10 @@ contents have changed (as opposed to jus +@@ -2844,6 +2848,10 @@ contents have changed (as opposed to jus also back up files for which any status information has changed). @xref{after}. @@ -58,7 +58,7 @@ diff -up tar-1.17/doc/tar.texi.xattrs tar-1.17/doc/tar.texi @opsummary{no-anchored} @item --no-anchored An exclude pattern can match any subsequence of the name's components. -@@ -2900,11 +2908,21 @@ When extracting an archive, subtract the +@@ -2919,11 +2927,21 @@ When extracting an archive, subtract the the permissions specified in the archive. This is the default behavior for ordinary users. @@ -80,7 +80,7 @@ diff -up tar-1.17/doc/tar.texi.xattrs tar-1.17/doc/tar.texi @opsummary{no-wildcards} @item --no-wildcards Do not use wildcards. -@@ -3132,6 +3150,11 @@ locations. Usually @command{tar} determ +@@ -3151,6 +3169,11 @@ locations. Usually @command{tar} determ the archive can be seeked or not. This option is intended for use in cases when such recognition fails. @@ -92,7 +92,7 @@ diff -up tar-1.17/doc/tar.texi.xattrs tar-1.17/doc/tar.texi @opsummary{show-defaults} @item --show-defaults -@@ -3328,6 +3351,11 @@ Used in conjunction with @option{--multi +@@ -3349,6 +3372,11 @@ Used in conjunction with @option{--multi keep track of which volume of a multi-volume archive it is working in @var{file}. @xref{volno-file}. @@ -104,7 +104,7 @@ diff -up tar-1.17/doc/tar.texi.xattrs tar-1.17/doc/tar.texi @opsummary{wildcards} @item --wildcards Use wildcards when matching member names with patterns. -@@ -7845,6 +7845,8 @@ implementation able to read @samp{ustar} +@@ -8350,6 +8378,8 @@ implementation able to read @samp{ustar} most @samp{posix} archives as well, with the only exception that any additional information (such as long file names etc.) will in such case be extracted as plain text files along with the files it refers to. @@ -113,9 +113,9 @@ diff -up tar-1.17/doc/tar.texi.xattrs tar-1.17/doc/tar.texi This archive format will be the default format for future versions of @GNUTAR{}. -@@ -8333,6 +8335,51 @@ It is equivalent to @option{--same-permi - @FIXME{I do not see the purpose of such an option. (Neither I. FP.) - Neither do I. --Sergey} +@@ -8902,6 +8932,51 @@ Same as both @option{--same-permissions} + + This option is deprecated, and will be removed in @GNUTAR{} version 1.23. +@opindex acls +@item --acls @@ -165,10 +165,10 @@ diff -up tar-1.17/doc/tar.texi.xattrs tar-1.17/doc/tar.texi @end table @node Portability -diff -up tar-1.17/src/common.h.xattrs tar-1.17/src/common.h ---- tar-1.17/src/common.h.xattrs 2007-06-08 10:14:42.000000000 +0200 -+++ tar-1.17/src/common.h 2007-12-10 15:31:54.000000000 +0100 -@@ -255,6 +255,15 @@ GLOBAL int same_owner_option; +diff -urp tar-1.22-orig/src/common.h tar-1.22/src/common.h +--- tar-1.22-orig/src/common.h 2008-11-30 13:30:29.000000000 +0100 ++++ tar-1.22/src/common.h 2009-03-05 09:45:42.000000000 +0100 +@@ -248,6 +248,15 @@ GLOBAL int same_owner_option; /* If positive, preserve permissions when extracting. */ GLOBAL int same_permissions_option; @@ -184,7 +184,7 @@ diff -up tar-1.17/src/common.h.xattrs tar-1.17/src/common.h /* When set, strip the given number of file name components from the file name before extracting */ GLOBAL size_t strip_name_components; -@@ -666,6 +675,9 @@ extern char *output_start; +@@ -673,6 +682,9 @@ extern char *output_start; void update_archive (void); @@ -194,7 +194,7 @@ diff -up tar-1.17/src/common.h.xattrs tar-1.17/src/common.h /* Module xheader.c. */ void xheader_init (struct xheader *xhdr); -@@ -687,6 +699,12 @@ bool xheader_string_end (struct xheader +@@ -694,6 +706,12 @@ bool xheader_string_end (struct xheader bool xheader_keyword_deleted_p (const char *kw); char *xheader_format_name (struct tar_stat_info *st, const char *fmt, size_t n); @@ -207,6 +207,737 @@ diff -up tar-1.17/src/common.h.xattrs tar-1.17/src/common.h /* Module system.c */ +diff -urp tar-1.22-orig/src/create.c tar-1.22/src/create.c +--- tar-1.22-orig/src/create.c 2008-10-30 11:58:04.000000000 +0100 ++++ tar-1.22/src/create.c 2009-03-05 09:45:42.000000000 +0100 +@@ -24,6 +24,7 @@ + #include + + #include "common.h" ++ + #include + + struct link +@@ -944,6 +945,30 @@ start_header (struct tar_stat_info *st) + GNAME_TO_CHARS (st->gname, header->header.gname); + } + ++ if (archive_format == POSIX_FORMAT) ++ { ++ if (acls_option > 0) ++ { ++ if (st->acls_a_ptr) ++ xheader_store ("SCHILY.acl.access", st, NULL); ++ if (st->acls_d_ptr) ++ xheader_store ("SCHILY.acl.default", st, NULL); ++ } ++ if ((selinux_context_option > 0) && st->cntx_name) ++ xheader_store ("RHT.security.selinux", st, NULL); ++ if (xattrs_option > 0) ++ { ++ size_t scan_xattr = 0; ++ struct xattr_array *xattr_map = st->xattr_map; ++ ++ while (scan_xattr < st->xattr_map_size) ++ { ++ xheader_store (xattr_map[scan_xattr].xkey, st, &scan_xattr); ++ ++scan_xattr; ++ } ++ } ++ } ++ + return header; + } + +@@ -1578,6 +1603,10 @@ dump_file0 (struct tar_stat_info *st, co + } + } + ++ xattrs_acls_get(st, p, fd, !is_dir); ++ xattrs_selinux_get(st, p, fd); ++ xattrs_xattrs_get(st, p, fd); ++ + if (is_dir) + { + const char *tag_file_name; +diff -urp tar-1.22-orig/src/extract.c tar-1.22/src/extract.c +--- tar-1.22-orig/src/extract.c 2008-10-30 15:10:28.000000000 +0100 ++++ tar-1.22/src/extract.c 2009-03-05 09:45:42.000000000 +0100 +@@ -69,6 +69,13 @@ struct delayed_set_stat + mode_t invert_permissions; + enum permstatus permstatus; + bool after_links; ++ char *cntx_name; ++ char *acls_a_ptr; ++ size_t acls_a_len; ++ char *acls_d_ptr; ++ size_t acls_d_len; ++ size_t xattr_map_size; /* Size of the xattr map */ ++ struct xattr_array *xattr_map; + char file_name[1]; + }; + +@@ -96,6 +103,18 @@ struct delayed_link + hard-linked together. */ + struct string_list *sources; + ++ /* SELinux context */ ++ char *cntx_name; ++ ++ /* ACLs */ ++ char *acls_a_ptr; ++ size_t acls_a_len; ++ char *acls_d_ptr; ++ size_t acls_d_len; ++ ++ size_t xattr_map_size; /* Size of the xattr map */ ++ struct xattr_array *xattr_map; ++ + /* The desired target of the desired link. */ + char target[1]; + }; +@@ -276,6 +295,10 @@ set_stat (char const *file_name, + give files away. */ + } + ++ xattrs_acls_set(st, file_name, typeflag); ++ xattrs_selinux_set(st, file_name, typeflag); ++ xattrs_xattrs_set(st, file_name, typeflag); ++ + if (0 < same_owner_option && permstatus != INTERDIR_PERMSTATUS) + { + /* When lchown exists, it should be used to change the attributes of +@@ -352,6 +375,29 @@ delay_set_stat (char const *file_name, s + data->invert_permissions = invert_permissions; + data->permstatus = permstatus; + data->after_links = 0; ++ data->cntx_name = NULL; ++ assign_string (&data->cntx_name, st->cntx_name); ++ if (st->acls_a_ptr) ++ { ++ data->acls_a_ptr = xmemdup(st->acls_a_ptr, st->acls_a_len + 1); ++ data->acls_a_len = st->acls_a_len; ++ } ++ else ++ { ++ data->acls_a_ptr = NULL; ++ data->acls_a_len = 0; ++ } ++ if (st->acls_d_ptr) ++ { ++ data->acls_d_ptr = xmemdup(st->acls_d_ptr, st->acls_d_len + 1); ++ data->acls_d_len = st->acls_d_len; ++ } ++ else ++ { ++ data->acls_d_ptr = NULL; ++ data->acls_d_len = 0; ++ } ++ xheader_xattr_copy (st, &data->xattr_map, &data->xattr_map_size); + strcpy (data->file_name, file_name); + delayed_set_stat_head = data; + } +@@ -599,11 +645,22 @@ apply_nonancestor_delayed_set_stat (char + sb.stat.st_gid = data->gid; + sb.atime = data->atime; + sb.mtime = data->mtime; ++ sb.cntx_name = data->cntx_name; ++ sb.acls_a_ptr = data->acls_a_ptr; ++ sb.acls_a_len = data->acls_a_len; ++ sb.acls_d_ptr = data->acls_d_ptr; ++ sb.acls_d_len = data->acls_d_len; ++ sb.xattr_map = data->xattr_map; ++ sb.xattr_map_size = data->xattr_map_size; + set_stat (data->file_name, &sb, cur_info, + data->invert_permissions, data->permstatus, DIRTYPE); + } + + delayed_set_stat_head = data->next; ++ xheader_xattr_free (data->xattr_map, data->xattr_map_size); ++ free (data->cntx_name); ++ free (data->acls_a_ptr); ++ free (data->acls_d_ptr); + free (data); + } + } +@@ -882,6 +939,13 @@ create_placeholder_file (char *file_name + + strlen (file_name) + 1); + p->sources->next = 0; + strcpy (p->sources->string, file_name); ++ p->cntx_name = NULL; ++ p->acls_a_ptr = NULL; ++ p->acls_a_len = 0; ++ p->acls_d_ptr = NULL; ++ p->acls_d_len = 0; ++ p->xattr_map = NULL; ++ p->xattr_map_size = 0; + strcpy (p->target, current_stat_info.link_name); + + h = delayed_set_stat_head; +@@ -1288,6 +1352,13 @@ apply_delayed_links (void) + struct tar_stat_info st1; + st1.stat.st_uid = ds->uid; + st1.stat.st_gid = ds->gid; ++ st1.cntx_name = ds->cntx_name; ++ st1.acls_a_ptr = ds->acls_a_ptr; ++ st1.acls_a_len = ds->acls_a_len; ++ st1.acls_d_ptr = ds->acls_d_ptr; ++ st1.acls_d_len = ds->acls_d_len; ++ st1.xattr_map = ds->xattr_map; ++ st1.xattr_map_size = ds->xattr_map_size; + set_stat (source, &st1, NULL, 0, 0, SYMTYPE); + valid_source = source; + } +diff -urp tar-1.22-orig/src/list.c tar-1.22/src/list.c +--- tar-1.22-orig/src/list.c 2009-03-05 09:45:15.000000000 +0100 ++++ tar-1.22/src/list.c 2009-03-05 09:45:42.000000000 +0100 +@@ -567,6 +567,13 @@ decode_header (union block *header, stru + assign_string (&stat_info->gname, + header->header.gname[0] ? header->header.gname : NULL); + ++ stat_info->acls_a_ptr = NULL; ++ stat_info->acls_a_len = 0; ++ stat_info->acls_d_ptr = NULL; ++ stat_info->acls_d_len = 0; ++ stat_info->cntx_name = NULL; ++ xheader_xattr_init(stat_info); ++ + if (format == OLDGNU_FORMAT && incremental_option) + { + stat_info->atime.tv_sec = TIME_FROM_HEADER (header->oldgnu_header.atime); +diff -urp tar-1.22-orig/src/Makefile.am tar-1.22/src/Makefile.am +--- tar-1.22-orig/src/Makefile.am 2007-10-29 18:53:06.000000000 +0100 ++++ tar-1.22/src/Makefile.am 2009-03-05 09:45:42.000000000 +0100 +@@ -20,7 +20,7 @@ + + bin_PROGRAMS = tar + +-noinst_HEADERS = arith.h common.h tar.h ++noinst_HEADERS = arith.h common.h tar.h xattrs.h + tar_SOURCES = \ + buffer.c\ + checkpoint.c\ +@@ -39,10 +39,11 @@ tar_SOURCES = \ + tar.c\ + transform.c\ + update.c\ +- utf8.c ++ utf8.c\ ++ xattrs.c + + INCLUDES = -I$(top_srcdir)/lib -I../ -I../lib + + LDADD = ../lib/libtar.a $(LIBINTL) $(LIBICONV) + +-tar_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) ++tar_LDADD = $(LIBS) $(LDADD) $(LIB_CLOCK_GETTIME) +diff -urp tar-1.22-orig/src/tar.c tar-1.22/src/tar.c +--- tar-1.22-orig/src/tar.c 2009-03-05 08:04:13.000000000 +0100 ++++ tar-1.22/src/tar.c 2009-03-05 09:45:42.000000000 +0100 +@@ -246,7 +246,8 @@ tar_set_quoting_style (char *arg) + + enum + { +- ANCHORED_OPTION = CHAR_MAX + 1, ++ ACLS_OPTION = CHAR_MAX + 1, ++ ANCHORED_OPTION, + ATIME_PRESERVE_OPTION, + BACKUP_OPTION, + CHECK_DEVICE_OPTION, +@@ -276,6 +277,7 @@ enum + MODE_OPTION, + MTIME_OPTION, + NEWER_MTIME_OPTION, ++ NO_ACLS_OPTION, + NO_ANCHORED_OPTION, + NO_AUTO_COMPRESS_OPTION, + NO_CHECK_DEVICE_OPTION, +@@ -288,9 +290,11 @@ enum + NO_RECURSION_OPTION, + NO_SAME_OWNER_OPTION, + NO_SAME_PERMISSIONS_OPTION, ++ NO_SELINUX_CONTEXT_OPTION, + NO_UNQUOTE_OPTION, + NO_WILDCARDS_MATCH_SLASH_OPTION, + NO_WILDCARDS_OPTION, ++ NO_XATTR_OPTION, + NULL_OPTION, + NUMERIC_OWNER_OPTION, + OCCURRENCE_OPTION, +@@ -312,6 +316,7 @@ enum + RMT_COMMAND_OPTION, + RSH_COMMAND_OPTION, + SAME_OWNER_OPTION, ++ SELINUX_CONTEXT_OPTION, + SHOW_DEFAULTS_OPTION, + SHOW_OMITTED_DIRS_OPTION, + SHOW_TRANSFORMED_NAMES_OPTION, +@@ -328,7 +333,8 @@ enum + VERSION_OPTION, + VOLNO_FILE_OPTION, + WILDCARDS_MATCH_SLASH_OPTION, +- WILDCARDS_OPTION ++ WILDCARDS_OPTION, ++ XATTR_OPTION + }; + + const char *argp_program_version = "tar (" PACKAGE_NAME ") " VERSION; +@@ -465,6 +471,10 @@ static struct argp_option options[] = { + {NULL, 0, NULL, 0, + N_("Handling of file attributes:"), GRID }, + ++ {"acls", ACLS_OPTION, 0, 0, ++ N_("Save the ACLs to the archive"), GRID+1 }, ++ {"no-acls", NO_ACLS_OPTION, 0, 0, ++ N_("Don't extract the ACLs from the archive"), GRID+1 }, + {"owner", OWNER_OPTION, N_("NAME"), 0, + N_("force NAME as owner for added files"), GRID+1 }, + {"group", GROUP_OPTION, N_("NAME"), 0, +@@ -495,6 +505,14 @@ static struct argp_option options[] = { + {"preserve-order", 's', 0, 0, + N_("sort names to extract to match archive"), GRID+1 }, + {"same-order", 0, 0, OPTION_ALIAS, NULL, GRID+1 }, ++ {"selinux", SELINUX_CONTEXT_OPTION, 0, 0, ++ N_("Save the SELinux context to the archive"), GRID+1 }, ++ {"no-selinux", NO_SELINUX_CONTEXT_OPTION, 0, 0, ++ N_("Don't extract the SELinux context from the archive"), GRID+1 }, ++ {"xattrs", XATTR_OPTION, 0, 0, ++ N_("Save the user/root xattrs to the archive"), GRID+1 }, ++ {"no-xattrs", NO_XATTR_OPTION, 0, 0, ++ N_("Don't extract the user/root xattrs from the archive"), GRID+1 }, + {"preserve", PRESERVE_OPTION, 0, 0, + N_("same as both -p and -s"), GRID+1 }, + {"delay-directory-restore", DELAY_DIRECTORY_RESTORE_OPTION, 0, 0, +@@ -1932,6 +1950,37 @@ parse_opt (int key, char *arg, struct ar + same_permissions_option = -1; + break; + ++ case ACLS_OPTION: ++ set_archive_format ("posix"); ++ acls_option = 1; ++ break; ++ ++ case NO_ACLS_OPTION: ++ acls_option = -1; ++ break; ++ ++ case SELINUX_CONTEXT_OPTION: ++ set_archive_format ("posix"); ++ selinux_context_option = 1; ++ break; ++ ++ case NO_SELINUX_CONTEXT_OPTION: ++ selinux_context_option = -1; ++ break; ++ ++ case XATTR_OPTION: ++ set_archive_format ("posix"); ++ if (!acls_option) acls_option = 1; ++ if (!selinux_context_option) selinux_context_option = 1; ++ xattrs_option = 1; ++ break; ++ ++ case NO_XATTR_OPTION: ++ if (!acls_option) acls_option = -1; ++ if (!selinux_context_option) selinux_context_option = -1; ++ xattrs_option = -1; ++ break; ++ + case RECURSION_OPTION: + recursion_option = FNM_LEADING_DIR; + break; +@@ -2330,6 +2379,29 @@ decode_options (int argc, char **argv) + || subcommand_option != LIST_SUBCOMMAND)) + USAGE_ERROR ((0, 0, _("--pax-option can be used only on POSIX archives"))); + ++ /* star create's non-POSIX typed archives with xattr support, so allow the ++ extra headers */ ++ if ((acls_option > 0) ++ && archive_format != POSIX_FORMAT ++ && (subcommand_option != EXTRACT_SUBCOMMAND ++ || subcommand_option != DIFF_SUBCOMMAND ++ || subcommand_option != LIST_SUBCOMMAND)) ++ USAGE_ERROR ((0, 0, _("--acls can be used only on POSIX archives"))); ++ ++ if ((selinux_context_option > 0) ++ && archive_format != POSIX_FORMAT ++ && (subcommand_option != EXTRACT_SUBCOMMAND ++ || subcommand_option != DIFF_SUBCOMMAND ++ || subcommand_option != LIST_SUBCOMMAND)) ++ USAGE_ERROR ((0, 0, _("--selinux can be used only on POSIX archives"))); ++ ++ if ((xattrs_option > 0) ++ && archive_format != POSIX_FORMAT ++ && (subcommand_option != EXTRACT_SUBCOMMAND ++ || subcommand_option != DIFF_SUBCOMMAND ++ || subcommand_option != LIST_SUBCOMMAND)) ++ USAGE_ERROR ((0, 0, _("--xattrs can be used only on POSIX archives"))); ++ + /* If ready to unlink hierarchies, so we are for simpler files. */ + if (recursive_unlink_option) + old_files_option = UNLINK_FIRST_OLD_FILES; +@@ -2544,11 +2616,15 @@ tar_stat_init (struct tar_stat_info *st) + void + tar_stat_destroy (struct tar_stat_info *st) + { ++ xheader_xattr_free (st->xattr_map, st->xattr_map_size); + free (st->orig_file_name); + free (st->file_name); + free (st->link_name); + free (st->uname); + free (st->gname); ++ free (st->cntx_name); ++ free (st->acls_a_ptr); ++ free (st->acls_d_ptr); + free (st->sparse_map); + free (st->dumpdir); + xheader_destroy (&st->xhdr); +diff -urp tar-1.22-orig/src/tar.h tar-1.22/src/tar.h +--- tar-1.22-orig/src/tar.h 2007-06-27 15:30:32.000000000 +0200 ++++ tar-1.22/src/tar.h 2009-03-05 09:45:42.000000000 +0100 +@@ -276,6 +276,14 @@ struct xheader + uintmax_t string_length; + }; + ++/* Information about xattrs for a file. */ ++struct xattr_array ++ { ++ char *xkey; ++ char *xval_ptr; ++ size_t xval_len; ++ }; ++ + struct tar_stat_info + { + char *orig_file_name; /* name of file read from the archive header */ +@@ -287,6 +295,15 @@ struct tar_stat_info + + char *uname; /* user name of owner */ + char *gname; /* group name of owner */ ++ ++ char *cntx_name; /* SELinux context for the current archive entry. */ ++ ++ char *acls_a_ptr; /* Access ACLs for the current archive entry. */ ++ size_t acls_a_len; /* Access ACLs for the current archive entry. */ ++ ++ char *acls_d_ptr; /* Default ACLs for the current archive entry. */ ++ size_t acls_d_len; /* Default ACLs for the current archive entry. */ ++ + struct stat stat; /* regular filesystem stat */ + + /* STAT doesn't always have access, data modification, and status +@@ -309,6 +326,9 @@ struct tar_stat_info + size_t sparse_map_size; /* Size of the sparse map */ + struct sp_array *sparse_map; + ++ size_t xattr_map_size; /* Size of the xattr map */ ++ struct xattr_array *xattr_map; ++ + /* Extended headers */ + struct xheader xhdr; + +diff -urp tar-1.22-orig/src/xheader.c tar-1.22/src/xheader.c +--- tar-1.22-orig/src/xheader.c 2008-11-30 13:30:54.000000000 +0100 ++++ tar-1.22/src/xheader.c 2009-03-05 09:45:42.000000000 +0100 +@@ -417,6 +417,74 @@ xheader_write_global (struct xheader *xh + free (name); + } + ++void xheader_xattr_init(struct tar_stat_info *st) ++{ ++ st->xattr_map = NULL; ++ st->xattr_map_size = 0; ++} ++ ++void xheader_xattr_free(struct xattr_array *xattr_map, size_t xattr_map_size) ++{ ++ size_t scan = 0; ++ ++ while (scan < xattr_map_size) ++ { ++ free (xattr_map[scan].xkey); ++ free (xattr_map[scan].xval_ptr); ++ ++ ++scan; ++ } ++ free (xattr_map); ++} ++ ++static void xheader_xattr__add(struct xattr_array **xattr_map, ++ size_t *xattr_map_size, ++ const char *key, const char *val, size_t len) ++{ ++ size_t pos = (*xattr_map_size)++; ++ ++ *xattr_map = xrealloc (*xattr_map, ++ *xattr_map_size * sizeof(struct xattr_array)); ++ (*xattr_map)[pos].xkey = xstrdup (key); ++ (*xattr_map)[pos].xval_ptr = xmemdup (val, len + 1); ++ (*xattr_map)[pos].xval_len = len; ++} ++ ++void xheader_xattr_add(struct tar_stat_info *st, ++ const char *key, const char *val, size_t len) ++{ ++ size_t klen = strlen (key); ++ char *xkey = xmalloc (strlen("SCHILY.xattr.") + klen + 1); ++ char *tmp = xkey; ++ ++ tmp = stpcpy (tmp, "SCHILY.xattr."); ++ tmp = stpcpy (tmp, key); ++ ++ xheader_xattr__add (&st->xattr_map, &st->xattr_map_size, xkey, val, len); ++ ++ free (xkey); ++} ++ ++void xheader_xattr_copy(const struct tar_stat_info *st, ++ struct xattr_array **xattr_map, size_t *xattr_map_size) ++{ ++ size_t scan = 0; ++ ++ *xattr_map = NULL; ++ *xattr_map_size = 0; ++ ++ while (scan < st->xattr_map_size) ++ { ++ char *key = st->xattr_map[scan].xkey; ++ char *val = st->xattr_map[scan].xval_ptr; ++ size_t len = st->xattr_map[scan].xval_len; ++ ++ xheader_xattr__add(xattr_map, xattr_map_size, key, val, len); ++ ++ ++scan; ++ } ++} ++ + + /* General Interface */ + +@@ -427,6 +495,7 @@ struct xhdr_tab + struct xheader *, void const *data); + void (*decoder) (struct tar_stat_info *, char const *, char const *, size_t); + bool protect; ++ bool prefix; + }; + + /* This declaration must be extern, because ISO C99 section 6.9.2 +@@ -443,8 +512,17 @@ locate_handler (char const *keyword) + struct xhdr_tab const *p; + + for (p = xhdr_tab; p->keyword; p++) +- if (strcmp (p->keyword, keyword) == 0) +- return p; ++ if (p->prefix) ++ { ++ if (strncmp (p->keyword, keyword, strlen(p->keyword)) == 0) ++ return p; ++ } ++ else ++ { ++ if (strcmp (p->keyword, keyword) == 0) ++ return p; ++ } ++ + return NULL; + } + +@@ -454,7 +532,7 @@ xheader_protected_pattern_p (const char + struct xhdr_tab const *p; + + for (p = xhdr_tab; p->keyword; p++) +- if (p->protect && fnmatch (pattern, p->keyword, 0) == 0) ++ if (!p->prefix && p->protect && fnmatch (pattern, p->keyword, 0) == 0) + return true; + return false; + } +@@ -465,7 +543,7 @@ xheader_protected_keyword_p (const char + struct xhdr_tab const *p; + + for (p = xhdr_tab; p->keyword; p++) +- if (p->protect && strcmp (p->keyword, keyword) == 0) ++ if (!p->prefix && p->protect && strcmp (p->keyword, keyword) == 0) + return true; + return false; + } +@@ -1417,6 +1495,71 @@ volume_filename_decoder (struct tar_stat + } + + static void ++xattr_selinux_coder (struct tar_stat_info const *st, char const *keyword, ++ struct xheader *xhdr, void const *data) ++{ ++ code_string (st->cntx_name, keyword, xhdr); ++} ++ ++static void ++xattr_selinux_decoder (struct tar_stat_info *st, ++ char const *keyword, char const *arg, size_t size) ++{ ++ decode_string (&st->cntx_name, arg); ++} ++ ++static void ++xattr_acls_a_coder (struct tar_stat_info const *st , char const *keyword, ++ struct xheader *xhdr, void const *data) ++{ ++ xheader_print_n (xhdr, keyword, st->acls_a_ptr, st->acls_a_len); ++} ++ ++static void ++xattr_acls_a_decoder (struct tar_stat_info *st, ++ char const *keyword, char const *arg, size_t size) ++{ ++ st->acls_a_ptr = xmemdup (arg, size + 1); ++ st->acls_a_len = size; ++} ++ ++static void ++xattr_acls_d_coder (struct tar_stat_info const *st , char const *keyword, ++ struct xheader *xhdr, void const *data) ++{ ++ xheader_print_n (xhdr, keyword, st->acls_d_ptr, st->acls_d_len); ++} ++ ++static void ++xattr_acls_d_decoder (struct tar_stat_info *st, ++ char const *keyword, char const *arg, size_t size) ++{ ++ st->acls_d_ptr = xmemdup (arg, size + 1); ++ st->acls_d_len = size; ++} ++ ++static void ++xattr_coder (struct tar_stat_info const *st , char const *keyword, ++ struct xheader *xhdr, void const *data) ++{ ++ struct xattr_array *xattr_map = st->xattr_map; ++ const size_t *off = data; ++ xheader_print_n (xhdr, keyword, ++ xattr_map[*off].xval_ptr, xattr_map[*off].xval_len); ++} ++ ++static void ++xattr_decoder (struct tar_stat_info *st, ++ char const *keyword, char const *arg, size_t size) ++{ ++ char *xstr = NULL; ++ ++ xstr = xmemdup(arg, size + 1); ++ xheader_xattr_add(st, keyword + strlen("SCHILY.xattr."), xstr, size); ++ free(xstr); ++} ++ ++static void + sparse_major_coder (struct tar_stat_info const *st, char const *keyword, + struct xheader *xhdr, void const *data) + { +@@ -1453,18 +1596,18 @@ sparse_minor_decoder (struct tar_stat_in + } + + struct xhdr_tab const xhdr_tab[] = { +- { "atime", atime_coder, atime_decoder, false }, +- { "comment", dummy_coder, dummy_decoder, false }, +- { "charset", dummy_coder, dummy_decoder, false }, +- { "ctime", ctime_coder, ctime_decoder, false }, +- { "gid", gid_coder, gid_decoder, false }, +- { "gname", gname_coder, gname_decoder, false }, +- { "linkpath", linkpath_coder, linkpath_decoder, false }, +- { "mtime", mtime_coder, mtime_decoder, false }, +- { "path", path_coder, path_decoder, false }, +- { "size", size_coder, size_decoder, false }, +- { "uid", uid_coder, uid_decoder, false }, +- { "uname", uname_coder, uname_decoder, false }, ++ { "atime", atime_coder, atime_decoder, false, false }, ++ { "comment", dummy_coder, dummy_decoder, false, false }, ++ { "charset", dummy_coder, dummy_decoder, false, false }, ++ { "ctime", ctime_coder, ctime_decoder, false, false }, ++ { "gid", gid_coder, gid_decoder, false, false }, ++ { "gname", gname_coder, gname_decoder, false, false }, ++ { "linkpath", linkpath_coder, linkpath_decoder, false, false }, ++ { "mtime", mtime_coder, mtime_decoder, false, false }, ++ { "path", path_coder, path_decoder, false, false }, ++ { "size", size_coder, size_decoder, false, false }, ++ { "uid", uid_coder, uid_decoder, false, false }, ++ { "uname", uname_coder, uname_decoder, false, false }, + + /* Sparse file handling */ + { "GNU.sparse.name", path_coder, path_decoder, +@@ -1479,25 +1622,25 @@ struct xhdr_tab const xhdr_tab[] = { + true }, + + /* tar 1.14 - 1.15.90 keywords. */ +- { "GNU.sparse.size", sparse_size_coder, sparse_size_decoder, true }, ++ { "GNU.sparse.size", sparse_size_coder, sparse_size_decoder, true, false }, + /* tar 1.14 - 1.15.1 keywords. Multiple instances of these appeared in 'x' + headers, and each of them was meaningful. It confilcted with POSIX specs, + which requires that "when extended header records conflict, the last one + given in the header shall take precedence." */ + { "GNU.sparse.offset", sparse_offset_coder, sparse_offset_decoder, +- true }, ++ true, false }, + { "GNU.sparse.numbytes", sparse_numbytes_coder, sparse_numbytes_decoder, +- true }, ++ true, false }, + /* tar 1.15.90 keyword, introduced to remove the above-mentioned conflict. */ + { "GNU.sparse.map", NULL /* Unused, see pax_dump_header() */, +- sparse_map_decoder, false }, ++ sparse_map_decoder, false, false }, + + { "GNU.dumpdir", dumpdir_coder, dumpdir_decoder, +- true }, ++ true, false }, + + /* Keeps the tape/volume label. May be present only in the global headers. + Equivalent to GNUTYPE_VOLHDR. */ +- { "GNU.volume.label", volume_label_coder, volume_label_decoder, true }, ++ { "GNU.volume.label", volume_label_coder, volume_label_decoder, true, false }, + + /* These may be present in a first global header of the archive. + They provide the same functionality as GNUTYPE_MULTIVOL header. +@@ -1506,9 +1649,38 @@ struct xhdr_tab const xhdr_tab[] = { + GNU.volume.offset keeps the offset of the start of this volume, + otherwise kept in oldgnu_header.offset. */ + { "GNU.volume.filename", volume_label_coder, volume_filename_decoder, +- true }, +- { "GNU.volume.size", volume_size_coder, volume_size_decoder, true }, +- { "GNU.volume.offset", volume_offset_coder, volume_offset_decoder, true }, +- ++ true, false }, ++ { "GNU.volume.size", volume_size_coder, volume_size_decoder, true, false }, ++ { "GNU.volume.offset", volume_offset_coder, volume_offset_decoder, ++ true, false }, ++ ++ /* We get the SELinux value from filecon, so add a namespace for SELinux ++ instead of storing it in SCHILY.xattr.* (which would be RAW). */ ++ { "RHT.security.selinux", ++ xattr_selinux_coder, xattr_selinux_decoder, false, false }, ++ ++ /* ACLs, use the star format... */ ++ { "SCHILY.acl.access", ++ xattr_acls_a_coder, xattr_acls_a_decoder, false, false }, ++ ++ { "SCHILY.acl.default", ++ xattr_acls_d_coder, xattr_acls_d_decoder, false, false }, ++ ++ /* FIXME: These are compat. for FC-6 ... we shipped a tar using the generic ++ header names by accident. */ ++ { "SCHILY.xattr.security.selinux", ++ xattr_selinux_coder, xattr_selinux_decoder, false, false }, ++ { "SCHILY.xattr.system.posix_acl_access", ++ xattr_acls_a_coder, xattr_acls_a_decoder, false, false }, ++ { "SCHILY.xattr.system.posix_acl_default", ++ xattr_acls_d_coder, xattr_acls_d_decoder, false, false }, ++ ++ /* xattr's, use the star format note we only save the user/trusted varients... */ ++ { "SCHILY.xattr.user", xattr_coder, xattr_decoder, false, true }, ++ { "SCHILY.xattr.trusted", xattr_coder, xattr_decoder, false, true }, ++ ++ /* ignore everything else in the xattr namespaces... */ ++ { "SCHILY.xattr", dummy_coder, dummy_decoder, false, true }, ++ + { NULL, NULL, NULL, false } + }; diff -up /dev/null tar-1.17/src/xattrs.c --- /dev/null 2007-12-10 11:30:31.504001819 +0100 +++ tar-1.17/src/xattrs.c 2007-12-10 15:31:54.000000000 +0100 @@ -703,565 +1434,6 @@ diff -up /dev/null tar-1.17/src/xattrs.c + } +} + -diff -up tar-1.17/src/tar.c.xattrs tar-1.17/src/tar.c ---- tar-1.17/src/tar.c.xattrs 2007-06-01 12:17:10.000000000 +0200 -+++ tar-1.17/src/tar.c 2007-12-10 15:31:54.000000000 +0100 -@@ -247,7 +247,8 @@ tar_set_quoting_style (char *arg) - - enum - { -- ANCHORED_OPTION = CHAR_MAX + 1, -+ ACLS_OPTION = CHAR_MAX + 1, -+ ANCHORED_OPTION, - ATIME_PRESERVE_OPTION, - BACKUP_OPTION, - CHECK_DEVICE_OPTION, -@@ -271,6 +272,7 @@ enum - MODE_OPTION, - MTIME_OPTION, - NEWER_MTIME_OPTION, -+ NO_ACLS_OPTION, - NO_ANCHORED_OPTION, - NO_AUTO_COMPRESS_OPTION, - NO_CHECK_DEVICE_OPTION, -@@ -280,9 +282,11 @@ enum - NO_RECURSION_OPTION, - NO_SAME_OWNER_OPTION, - NO_SAME_PERMISSIONS_OPTION, -+ NO_SELINUX_CONTEXT_OPTION, - NO_UNQUOTE_OPTION, - NO_WILDCARDS_MATCH_SLASH_OPTION, - NO_WILDCARDS_OPTION, -+ NO_XATTR_OPTION, - NULL_OPTION, - NUMERIC_OWNER_OPTION, - OCCURRENCE_OPTION, -@@ -304,6 +308,7 @@ enum - RMT_COMMAND_OPTION, - RSH_COMMAND_OPTION, - SAME_OWNER_OPTION, -+ SELINUX_CONTEXT_OPTION, - SHOW_DEFAULTS_OPTION, - SHOW_OMITTED_DIRS_OPTION, - SHOW_TRANSFORMED_NAMES_OPTION, -@@ -321,7 +326,8 @@ enum - VERSION_OPTION, - VOLNO_FILE_OPTION, - WILDCARDS_MATCH_SLASH_OPTION, -- WILDCARDS_OPTION -+ WILDCARDS_OPTION, -+ XATTR_OPTION - }; - - const char *argp_program_version = "tar (" PACKAGE_NAME ") " VERSION; -@@ -453,6 +459,10 @@ static struct argp_option options[] = { - {NULL, 0, NULL, 0, - N_("Handling of file attributes:"), GRID }, - -+ {"acls", ACLS_OPTION, 0, 0, -+ N_("Save the ACLs to the archive"), GRID+1 }, -+ {"no-acls", NO_ACLS_OPTION, 0, 0, -+ N_("Don't extract the ACLs from the archive"), GRID+1 }, - {"owner", OWNER_OPTION, N_("NAME"), 0, - N_("force NAME as owner for added files"), GRID+1 }, - {"group", GROUP_OPTION, N_("NAME"), 0, -@@ -483,6 +493,14 @@ static struct argp_option options[] = { - {"preserve-order", 's', 0, 0, - N_("sort names to extract to match archive"), GRID+1 }, - {"same-order", 0, 0, OPTION_ALIAS, NULL, GRID+1 }, -+ {"selinux", SELINUX_CONTEXT_OPTION, 0, 0, -+ N_("Save the SELinux context to the archive"), GRID+1 }, -+ {"no-selinux", NO_SELINUX_CONTEXT_OPTION, 0, 0, -+ N_("Don't extract the SELinux context from the archive"), GRID+1 }, -+ {"xattrs", XATTR_OPTION, 0, 0, -+ N_("Save the user/root xattrs to the archive"), GRID+1 }, -+ {"no-xattrs", NO_XATTR_OPTION, 0, 0, -+ N_("Don't extract the user/root xattrs from the archive"), GRID+1 }, - {"preserve", PRESERVE_OPTION, 0, 0, - N_("same as both -p and -s"), GRID+1 }, - {"delay-directory-restore", DELAY_DIRECTORY_RESTORE_OPTION, 0, 0, -@@ -1805,6 +1823,37 @@ parse_opt (int key, char *arg, struct ar - same_permissions_option = -1; - break; - -+ case ACLS_OPTION: -+ set_archive_format ("posix"); -+ acls_option = 1; -+ break; -+ -+ case NO_ACLS_OPTION: -+ acls_option = -1; -+ break; -+ -+ case SELINUX_CONTEXT_OPTION: -+ set_archive_format ("posix"); -+ selinux_context_option = 1; -+ break; -+ -+ case NO_SELINUX_CONTEXT_OPTION: -+ selinux_context_option = -1; -+ break; -+ -+ case XATTR_OPTION: -+ set_archive_format ("posix"); -+ if (!acls_option) acls_option = 1; -+ if (!selinux_context_option) selinux_context_option = 1; -+ xattrs_option = 1; -+ break; -+ -+ case NO_XATTR_OPTION: -+ if (!acls_option) acls_option = -1; -+ if (!selinux_context_option) selinux_context_option = -1; -+ xattrs_option = -1; -+ break; -+ - case RECURSION_OPTION: - recursion_option = FNM_LEADING_DIR; - break; -@@ -2200,6 +2249,29 @@ decode_options (int argc, char **argv) - || subcommand_option != LIST_SUBCOMMAND)) - USAGE_ERROR ((0, 0, _("--pax-option can be used only on POSIX archives"))); - -+ /* star create's non-POSIX typed archives with xattr support, so allow the -+ extra headers */ -+ if ((acls_option > 0) -+ && archive_format != POSIX_FORMAT -+ && (subcommand_option != EXTRACT_SUBCOMMAND -+ || subcommand_option != DIFF_SUBCOMMAND -+ || subcommand_option != LIST_SUBCOMMAND)) -+ USAGE_ERROR ((0, 0, _("--acls can be used only on POSIX archives"))); -+ -+ if ((selinux_context_option > 0) -+ && archive_format != POSIX_FORMAT -+ && (subcommand_option != EXTRACT_SUBCOMMAND -+ || subcommand_option != DIFF_SUBCOMMAND -+ || subcommand_option != LIST_SUBCOMMAND)) -+ USAGE_ERROR ((0, 0, _("--selinux can be used only on POSIX archives"))); -+ -+ if ((xattrs_option > 0) -+ && archive_format != POSIX_FORMAT -+ && (subcommand_option != EXTRACT_SUBCOMMAND -+ || subcommand_option != DIFF_SUBCOMMAND -+ || subcommand_option != LIST_SUBCOMMAND)) -+ USAGE_ERROR ((0, 0, _("--xattrs can be used only on POSIX archives"))); -+ - /* If ready to unlink hierarchies, so we are for simpler files. */ - if (recursive_unlink_option) - old_files_option = UNLINK_FIRST_OLD_FILES; -@@ -2401,11 +2473,15 @@ tar_stat_init (struct tar_stat_info *st) - void - tar_stat_destroy (struct tar_stat_info *st) - { -+ xheader_xattr_free (st->xattr_map, st->xattr_map_size); - free (st->orig_file_name); - free (st->file_name); - free (st->link_name); - free (st->uname); - free (st->gname); -+ free (st->cntx_name); -+ free (st->acls_a_ptr); -+ free (st->acls_d_ptr); - free (st->sparse_map); - free (st->dumpdir); - xheader_destroy (&st->xhdr); -diff -up tar-1.17/src/xheader.c.xattrs tar-1.17/src/xheader.c ---- tar-1.17/src/xheader.c.xattrs 2007-06-01 12:17:10.000000000 +0200 -+++ tar-1.17/src/xheader.c 2007-12-10 15:31:54.000000000 +0100 -@@ -419,6 +419,74 @@ xheader_write_global (struct xheader *xh - free (name); - } - -+void xheader_xattr_init(struct tar_stat_info *st) -+{ -+ st->xattr_map = NULL; -+ st->xattr_map_size = 0; -+} -+ -+void xheader_xattr_free(struct xattr_array *xattr_map, size_t xattr_map_size) -+{ -+ size_t scan = 0; -+ -+ while (scan < xattr_map_size) -+ { -+ free (xattr_map[scan].xkey); -+ free (xattr_map[scan].xval_ptr); -+ -+ ++scan; -+ } -+ free (xattr_map); -+} -+ -+static void xheader_xattr__add(struct xattr_array **xattr_map, -+ size_t *xattr_map_size, -+ const char *key, const char *val, size_t len) -+{ -+ size_t pos = (*xattr_map_size)++; -+ -+ *xattr_map = xrealloc (*xattr_map, -+ *xattr_map_size * sizeof(struct xattr_array)); -+ (*xattr_map)[pos].xkey = xstrdup (key); -+ (*xattr_map)[pos].xval_ptr = xmemdup (val, len + 1); -+ (*xattr_map)[pos].xval_len = len; -+} -+ -+void xheader_xattr_add(struct tar_stat_info *st, -+ const char *key, const char *val, size_t len) -+{ -+ size_t klen = strlen (key); -+ char *xkey = xmalloc (strlen("SCHILY.xattr.") + klen + 1); -+ char *tmp = xkey; -+ -+ tmp = stpcpy (tmp, "SCHILY.xattr."); -+ tmp = stpcpy (tmp, key); -+ -+ xheader_xattr__add (&st->xattr_map, &st->xattr_map_size, xkey, val, len); -+ -+ free (xkey); -+} -+ -+void xheader_xattr_copy(const struct tar_stat_info *st, -+ struct xattr_array **xattr_map, size_t *xattr_map_size) -+{ -+ size_t scan = 0; -+ -+ *xattr_map = NULL; -+ *xattr_map_size = 0; -+ -+ while (scan < st->xattr_map_size) -+ { -+ char *key = st->xattr_map[scan].xkey; -+ char *val = st->xattr_map[scan].xval_ptr; -+ size_t len = st->xattr_map[scan].xval_len; -+ -+ xheader_xattr__add(xattr_map, xattr_map_size, key, val, len); -+ -+ ++scan; -+ } -+} -+ - - /* General Interface */ - -@@ -429,6 +497,7 @@ struct xhdr_tab - struct xheader *, void const *data); - void (*decoder) (struct tar_stat_info *, char const *, char const *, size_t); - bool protect; -+ bool prefix; - }; - - /* This declaration must be extern, because ISO C99 section 6.9.2 -@@ -445,8 +514,17 @@ locate_handler (char const *keyword) - struct xhdr_tab const *p; - - for (p = xhdr_tab; p->keyword; p++) -- if (strcmp (p->keyword, keyword) == 0) -- return p; -+ if (p->prefix) -+ { -+ if (strncmp (p->keyword, keyword, strlen(p->keyword)) == 0) -+ return p; -+ } -+ else -+ { -+ if (strcmp (p->keyword, keyword) == 0) -+ return p; -+ } -+ - return NULL; - } - -@@ -456,7 +534,7 @@ xheader_protected_pattern_p (const char - struct xhdr_tab const *p; - - for (p = xhdr_tab; p->keyword; p++) -- if (p->protect && fnmatch (pattern, p->keyword, 0) == 0) -+ if (!p->prefix && p->protect && fnmatch (pattern, p->keyword, 0) == 0) - return true; - return false; - } -@@ -467,7 +545,7 @@ xheader_protected_keyword_p (const char - struct xhdr_tab const *p; - - for (p = xhdr_tab; p->keyword; p++) -- if (p->protect && strcmp (p->keyword, keyword) == 0) -+ if (!p->prefix && p->protect && strcmp (p->keyword, keyword) == 0) - return true; - return false; - } -@@ -1419,6 +1497,71 @@ volume_filename_decoder (struct tar_stat - } - - static void -+xattr_selinux_coder (struct tar_stat_info const *st, char const *keyword, -+ struct xheader *xhdr, void const *data) -+{ -+ code_string (st->cntx_name, keyword, xhdr); -+} -+ -+static void -+xattr_selinux_decoder (struct tar_stat_info *st, -+ char const *keyword, char const *arg, size_t size) -+{ -+ decode_string (&st->cntx_name, arg); -+} -+ -+static void -+xattr_acls_a_coder (struct tar_stat_info const *st , char const *keyword, -+ struct xheader *xhdr, void const *data) -+{ -+ xheader_print_n (xhdr, keyword, st->acls_a_ptr, st->acls_a_len); -+} -+ -+static void -+xattr_acls_a_decoder (struct tar_stat_info *st, -+ char const *keyword, char const *arg, size_t size) -+{ -+ st->acls_a_ptr = xmemdup (arg, size + 1); -+ st->acls_a_len = size; -+} -+ -+static void -+xattr_acls_d_coder (struct tar_stat_info const *st , char const *keyword, -+ struct xheader *xhdr, void const *data) -+{ -+ xheader_print_n (xhdr, keyword, st->acls_d_ptr, st->acls_d_len); -+} -+ -+static void -+xattr_acls_d_decoder (struct tar_stat_info *st, -+ char const *keyword, char const *arg, size_t size) -+{ -+ st->acls_d_ptr = xmemdup (arg, size + 1); -+ st->acls_d_len = size; -+} -+ -+static void -+xattr_coder (struct tar_stat_info const *st , char const *keyword, -+ struct xheader *xhdr, void const *data) -+{ -+ struct xattr_array *xattr_map = st->xattr_map; -+ const size_t *off = data; -+ xheader_print_n (xhdr, keyword, -+ xattr_map[*off].xval_ptr, xattr_map[*off].xval_len); -+} -+ -+static void -+xattr_decoder (struct tar_stat_info *st, -+ char const *keyword, char const *arg, size_t size) -+{ -+ char *xstr = NULL; -+ -+ xstr = xmemdup(arg, size + 1); -+ xheader_xattr_add(st, keyword + strlen("SCHILY.xattr."), xstr, size); -+ free(xstr); -+} -+ -+static void - sparse_major_coder (struct tar_stat_info const *st, char const *keyword, - struct xheader *xhdr, void const *data) - { -@@ -1455,18 +1598,18 @@ sparse_minor_decoder (struct tar_stat_in - } - - struct xhdr_tab const xhdr_tab[] = { -- { "atime", atime_coder, atime_decoder, false }, -- { "comment", dummy_coder, dummy_decoder, false }, -- { "charset", dummy_coder, dummy_decoder, false }, -- { "ctime", ctime_coder, ctime_decoder, false }, -- { "gid", gid_coder, gid_decoder, false }, -- { "gname", gname_coder, gname_decoder, false }, -- { "linkpath", linkpath_coder, linkpath_decoder, false }, -- { "mtime", mtime_coder, mtime_decoder, false }, -- { "path", path_coder, path_decoder, false }, -- { "size", size_coder, size_decoder, false }, -- { "uid", uid_coder, uid_decoder, false }, -- { "uname", uname_coder, uname_decoder, false }, -+ { "atime", atime_coder, atime_decoder, false, false }, -+ { "comment", dummy_coder, dummy_decoder, false, false }, -+ { "charset", dummy_coder, dummy_decoder, false, false }, -+ { "ctime", ctime_coder, ctime_decoder, false, false }, -+ { "gid", gid_coder, gid_decoder, false, false }, -+ { "gname", gname_coder, gname_decoder, false, false }, -+ { "linkpath", linkpath_coder, linkpath_decoder, false, false }, -+ { "mtime", mtime_coder, mtime_decoder, false, false }, -+ { "path", path_coder, path_decoder, false, false }, -+ { "size", size_coder, size_decoder, false, false }, -+ { "uid", uid_coder, uid_decoder, false, false }, -+ { "uname", uname_coder, uname_decoder, false, false }, - - /* Sparse file handling */ - { "GNU.sparse.name", path_coder, path_decoder, -@@ -1481,25 +1624,25 @@ struct xhdr_tab const xhdr_tab[] = { - true }, - - /* tar 1.14 - 1.15.90 keywords. */ -- { "GNU.sparse.size", sparse_size_coder, sparse_size_decoder, true }, -+ { "GNU.sparse.size", sparse_size_coder, sparse_size_decoder, true, false }, - /* tar 1.14 - 1.15.1 keywords. Multiple instances of these appeared in 'x' - headers, and each of them was meaningful. It confilcted with POSIX specs, - which requires that "when extended header records conflict, the last one - given in the header shall take precedence." */ - { "GNU.sparse.offset", sparse_offset_coder, sparse_offset_decoder, -- true }, -+ true, false }, - { "GNU.sparse.numbytes", sparse_numbytes_coder, sparse_numbytes_decoder, -- true }, -+ true, false }, - /* tar 1.15.90 keyword, introduced to remove the above-mentioned conflict. */ - { "GNU.sparse.map", NULL /* Unused, see pax_dump_header() */, -- sparse_map_decoder, false }, -+ sparse_map_decoder, false, false }, - - { "GNU.dumpdir", dumpdir_coder, dumpdir_decoder, -- true }, -+ true, false }, - - /* Keeps the tape/volume label. May be present only in the global headers. - Equivalent to GNUTYPE_VOLHDR. */ -- { "GNU.volume.label", volume_label_coder, volume_label_decoder, true }, -+ { "GNU.volume.label", volume_label_coder, volume_label_decoder, true, false }, - - /* These may be present in a first global header of the archive. - They provide the same functionality as GNUTYPE_MULTIVOL header. -@@ -1508,9 +1651,38 @@ struct xhdr_tab const xhdr_tab[] = { - GNU.volume.offset keeps the offset of the start of this volume, - otherwise kept in oldgnu_header.offset. */ - { "GNU.volume.filename", volume_label_coder, volume_filename_decoder, -- true }, -- { "GNU.volume.size", volume_size_coder, volume_size_decoder, true }, -- { "GNU.volume.offset", volume_offset_coder, volume_offset_decoder, true }, -- -+ true, false }, -+ { "GNU.volume.size", volume_size_coder, volume_size_decoder, true, false }, -+ { "GNU.volume.offset", volume_offset_coder, volume_offset_decoder, -+ true, false }, -+ -+ /* We get the SELinux value from filecon, so add a namespace for SELinux -+ instead of storing it in SCHILY.xattr.* (which would be RAW). */ -+ { "RHT.security.selinux", -+ xattr_selinux_coder, xattr_selinux_decoder, false, false }, -+ -+ /* ACLs, use the star format... */ -+ { "SCHILY.acl.access", -+ xattr_acls_a_coder, xattr_acls_a_decoder, false, false }, -+ -+ { "SCHILY.acl.default", -+ xattr_acls_d_coder, xattr_acls_d_decoder, false, false }, -+ -+ /* FIXME: These are compat. for FC-6 ... we shipped a tar using the generic -+ header names by accident. */ -+ { "SCHILY.xattr.security.selinux", -+ xattr_selinux_coder, xattr_selinux_decoder, false, false }, -+ { "SCHILY.xattr.system.posix_acl_access", -+ xattr_acls_a_coder, xattr_acls_a_decoder, false, false }, -+ { "SCHILY.xattr.system.posix_acl_default", -+ xattr_acls_d_coder, xattr_acls_d_decoder, false, false }, -+ -+ /* xattr's, use the star format note we only save the user/trusted varients... */ -+ { "SCHILY.xattr.user", xattr_coder, xattr_decoder, false, true }, -+ { "SCHILY.xattr.trusted", xattr_coder, xattr_decoder, false, true }, -+ -+ /* ignore everything else in the xattr namespaces... */ -+ { "SCHILY.xattr", dummy_coder, dummy_decoder, false, true }, -+ - { NULL, NULL, NULL, false } - }; -diff -up tar-1.17/src/list.c.xattrs tar-1.17/src/list.c ---- tar-1.17/src/list.c.xattrs 2007-12-10 15:31:54.000000000 +0100 -+++ tar-1.17/src/list.c 2007-12-10 15:31:54.000000000 +0100 -@@ -567,6 +567,13 @@ decode_header (union block *header, stru - assign_string (&stat_info->gname, - header->header.gname[0] ? header->header.gname : NULL); - -+ stat_info->acls_a_ptr = NULL; -+ stat_info->acls_a_len = 0; -+ stat_info->acls_d_ptr = NULL; -+ stat_info->acls_d_len = 0; -+ stat_info->cntx_name = NULL; -+ xheader_xattr_init(stat_info); -+ - if (format == OLDGNU_FORMAT && incremental_option) - { - stat_info->atime.tv_sec = TIME_FROM_HEADER (header->oldgnu_header.atime); -diff -up tar-1.17/src/Makefile.am.xattrs tar-1.17/src/Makefile.am ---- tar-1.17/src/Makefile.am.xattrs 2006-12-05 08:37:59.000000000 +0100 -+++ tar-1.17/src/Makefile.am 2007-12-10 15:31:54.000000000 +0100 -@@ -20,7 +20,7 @@ - - bin_PROGRAMS = tar - --noinst_HEADERS = arith.h common.h tar.h -+noinst_HEADERS = arith.h common.h tar.h xattrs.h - tar_SOURCES = \ - buffer.c\ - checkpoint.c\ -@@ -37,10 +37,11 @@ tar_SOURCES = \ - tar.c\ - transform.c\ - update.c\ -- utf8.c -+ utf8.c\ -+ xattrs.c - - INCLUDES = -I$(top_srcdir)/lib -I../ -I../lib - - LDADD = ../lib/libtar.a $(LIBINTL) $(LIBICONV) - --tar_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) -+tar_LDADD = $(LIBS) $(LDADD) $(LIB_CLOCK_GETTIME) -diff -up tar-1.17/src/create.c.xattrs tar-1.17/src/create.c ---- tar-1.17/src/create.c.xattrs 2007-06-01 12:17:10.000000000 +0200 -+++ tar-1.17/src/create.c 2007-12-10 15:31:54.000000000 +0100 -@@ -24,6 +24,7 @@ - #include - - #include "common.h" -+ - #include - - struct link -@@ -942,6 +943,30 @@ start_header (struct tar_stat_info *st) - GNAME_TO_CHARS (st->gname, header->header.gname); - } - -+ if (archive_format == POSIX_FORMAT) -+ { -+ if (acls_option > 0) -+ { -+ if (st->acls_a_ptr) -+ xheader_store ("SCHILY.acl.access", st, NULL); -+ if (st->acls_d_ptr) -+ xheader_store ("SCHILY.acl.default", st, NULL); -+ } -+ if ((selinux_context_option > 0) && st->cntx_name) -+ xheader_store ("RHT.security.selinux", st, NULL); -+ if (xattrs_option > 0) -+ { -+ size_t scan_xattr = 0; -+ struct xattr_array *xattr_map = st->xattr_map; -+ -+ while (scan_xattr < st->xattr_map_size) -+ { -+ xheader_store (xattr_map[scan_xattr].xkey, st, &scan_xattr); -+ ++scan_xattr; -+ } -+ } -+ } -+ - return header; - } - -@@ -1572,6 +1597,10 @@ dump_file0 (struct tar_stat_info *st, co - } - } - -+ xattrs_acls_get(st, p, fd, !is_dir); -+ xattrs_selinux_get(st, p, fd); -+ xattrs_xattrs_get(st, p, fd); -+ - if (is_dir) - { - const char *tag_file_name; diff -up /dev/null tar-1.17/src/xattrs.h --- /dev/null 2007-12-10 11:30:31.504001819 +0100 +++ tar-1.17/src/xattrs.h 2007-12-10 15:31:54.000000000 +0100 @@ -1280,174 +1452,3 @@ diff -up /dev/null tar-1.17/src/xattrs.h + char const *file_name, char typeflag); +extern void xattrs_xattrs_set(struct tar_stat_info const *st, + char const *file_name, char typeflag); -diff -up tar-1.17/src/tar.h.xattrs tar-1.17/src/tar.h ---- tar-1.17/src/tar.h.xattrs 2007-06-01 12:17:10.000000000 +0200 -+++ tar-1.17/src/tar.h 2007-12-10 15:31:54.000000000 +0100 -@@ -276,6 +276,14 @@ struct xheader - uintmax_t string_length; - }; - -+/* Information about xattrs for a file. */ -+struct xattr_array -+ { -+ char *xkey; -+ char *xval_ptr; -+ size_t xval_len; -+ }; -+ - struct tar_stat_info - { - char *orig_file_name; /* name of file read from the archive header */ -@@ -287,6 +295,15 @@ struct tar_stat_info - - char *uname; /* user name of owner */ - char *gname; /* group name of owner */ -+ -+ char *cntx_name; /* SELinux context for the current archive entry. */ -+ -+ char *acls_a_ptr; /* Access ACLs for the current archive entry. */ -+ size_t acls_a_len; /* Access ACLs for the current archive entry. */ -+ -+ char *acls_d_ptr; /* Default ACLs for the current archive entry. */ -+ size_t acls_d_len; /* Default ACLs for the current archive entry. */ -+ - struct stat stat; /* regular filesystem stat */ - - /* STAT doesn't always have access, data modification, and status -@@ -309,6 +326,9 @@ struct tar_stat_info - size_t sparse_map_size; /* Size of the sparse map */ - struct sp_array *sparse_map; - -+ size_t xattr_map_size; /* Size of the xattr map */ -+ struct xattr_array *xattr_map; -+ - /* Extended headers */ - struct xheader xhdr; - ---- tar-1.19/src/extract.c.xattrs 2007-08-26 10:56:55.000000000 +0200 -+++ tar-1.19/src/extract.c 2007-12-17 10:32:56.000000000 +0100 -@@ -69,6 +69,13 @@ struct delayed_set_stat - mode_t invert_permissions; - enum permstatus permstatus; - bool after_links; -+ char *cntx_name; -+ char *acls_a_ptr; -+ size_t acls_a_len; -+ char *acls_d_ptr; -+ size_t acls_d_len; -+ size_t xattr_map_size; /* Size of the xattr map */ -+ struct xattr_array *xattr_map; - char file_name[1]; - }; - -@@ -96,6 +103,18 @@ struct delayed_link - hard-linked together. */ - struct string_list *sources; - -+ /* SELinux context */ -+ char *cntx_name; -+ -+ /* ACLs */ -+ char *acls_a_ptr; -+ size_t acls_a_len; -+ char *acls_d_ptr; -+ size_t acls_d_len; -+ -+ size_t xattr_map_size; /* Size of the xattr map */ -+ struct xattr_array *xattr_map; -+ - /* The desired target of the desired link. */ - char target[1]; - }; -@@ -276,6 +295,10 @@ set_stat (char const *file_name, - give files away. */ - } - -+ xattrs_acls_set(st, file_name, typeflag); -+ xattrs_selinux_set(st, file_name, typeflag); -+ xattrs_xattrs_set(st, file_name, typeflag); -+ - if (0 < same_owner_option && permstatus != INTERDIR_PERMSTATUS) - { - /* When lchown exists, it should be used to change the attributes of -@@ -352,6 +375,29 @@ delay_set_stat (char const *file_name, s - data->invert_permissions = invert_permissions; - data->permstatus = permstatus; - data->after_links = 0; -+ data->cntx_name = NULL; -+ assign_string (&data->cntx_name, st->cntx_name); -+ if (st->acls_a_ptr) -+ { -+ data->acls_a_ptr = xmemdup(st->acls_a_ptr, st->acls_a_len + 1); -+ data->acls_a_len = st->acls_a_len; -+ } -+ else -+ { -+ data->acls_a_ptr = NULL; -+ data->acls_a_len = 0; -+ } -+ if (st->acls_d_ptr) -+ { -+ data->acls_d_ptr = xmemdup(st->acls_d_ptr, st->acls_d_len + 1); -+ data->acls_d_len = st->acls_d_len; -+ } -+ else -+ { -+ data->acls_d_ptr = NULL; -+ data->acls_d_len = 0; -+ } -+ xheader_xattr_copy (st, &data->xattr_map, &data->xattr_map_size); - strcpy (data->file_name, file_name); - delayed_set_stat_head = data; - } -@@ -599,11 +639,22 @@ apply_nonancestor_delayed_set_stat (char - sb.stat.st_gid = data->gid; - sb.atime = data->atime; - sb.mtime = data->mtime; -+ sb.cntx_name = data->cntx_name; -+ sb.acls_a_ptr = data->acls_a_ptr; -+ sb.acls_a_len = data->acls_a_len; -+ sb.acls_d_ptr = data->acls_d_ptr; -+ sb.acls_d_len = data->acls_d_len; -+ sb.xattr_map = data->xattr_map; -+ sb.xattr_map_size = data->xattr_map_size; - set_stat (data->file_name, &sb, cur_info, - data->invert_permissions, data->permstatus, DIRTYPE); - } - - delayed_set_stat_head = data->next; -+ xheader_xattr_free (data->xattr_map, data->xattr_map_size); -+ free (data->cntx_name); -+ free (data->acls_a_ptr); -+ free (data->acls_d_ptr); - free (data); - } - } -@@ -882,6 +933,13 @@ create_placeholder_file (char *file_name - + strlen (file_name) + 1); - p->sources->next = 0; - strcpy (p->sources->string, file_name); -+ p->cntx_name = NULL; -+ p->acls_a_ptr = NULL; -+ p->acls_a_len = 0; -+ p->acls_d_ptr = NULL; -+ p->acls_d_len = 0; -+ p->xattr_map = NULL; -+ p->xattr_map_size = 0; - strcpy (p->target, current_stat_info.link_name); - - h = delayed_set_stat_head; -@@ -1291,6 +1349,13 @@ apply_delayed_links (void) - struct tar_stat_info st1; - st1.stat.st_uid = ds->uid; - st1.stat.st_gid = ds->gid; -+ st1.cntx_name = ds->cntx_name; -+ st1.acls_a_ptr = ds->acls_a_ptr; -+ st1.acls_a_len = ds->acls_a_len; -+ st1.acls_d_ptr = ds->acls_d_ptr; -+ st1.acls_d_len = ds->acls_d_len; -+ st1.xattr_map = ds->xattr_map; -+ st1.xattr_map_size = ds->xattr_map_size; - set_stat (source, &st1, NULL, 0, 0, SYMTYPE); - valid_source = source; - } diff --git a/tar-1.21-testsuite.patch b/tar-1.21-testsuite.patch deleted file mode 100644 index 9f4a83b..0000000 --- a/tar-1.21-testsuite.patch +++ /dev/null @@ -1,246 +0,0 @@ -From: Sergey Poznyakoff -Date: Mon, 29 Dec 2008 09:27:00 +0000 (+0000) -Subject: Fix testsuite and bootstrap. Implement -I. -X-Git-Url: http://git.savannah.gnu.org/gitweb/?p=tar.git;a=commitdiff_plain;h=7b68ef3d918603f3afb03e939ba72f5cad10edf4;hp=970f999818a52a107a89697666c54397403c09be - -Fix testsuite. Implement -I. - -* src/tar.c: Implement -I as a shorthand for --use-compress-program. -* doc/tar.texi: Document -I. -* tests/pipe.at, tests/shortrec.at: Account for eventual 'Record -size' output. -* tests/testsuite.at (AT_TAR_CHECK_HOOK): New define -(AT_TAR_WITH_HOOK, TAR_IGNREC_HOOK): New macros. ---- - -diff --git a/ChangeLog b/ChangeLog -index 7dd05f8..68fe50a 100644 ---- a/ChangeLog -+++ b/ChangeLog -@@ -1,3 +1,12 @@ -+2008-12-29 Sergey Poznyakoff -+ -+ * src/tar.c: Implement -I as a shorthand for --use-compress-program. -+ * doc/tar.texi: Document -I. -+ * tests/pipe.at, tests/shortrec.at: Account for eventual 'Record -+ size' output. -+ * tests/testsuite.at (AT_TAR_CHECK_HOOK): New define -+ (AT_TAR_WITH_HOOK, TAR_IGNREC_HOOK): New macros. -+ - 2008-11-30 Sergey Poznyakoff - - * src/xheader.c: Remove duplicate inclusion of fnmatch.h. Reported -diff --git a/doc/tar.texi b/doc/tar.texi -index cb8bd19..210639e 100644 ---- a/doc/tar.texi -+++ b/doc/tar.texi -@@ -3309,6 +3309,7 @@ name quoting}. - - @opsummary{use-compress-program} - @item --use-compress-program=@var{prog} -+@itemx -I=@var{prog} - - Instructs @command{tar} to access the archive through @var{prog}, which is - presumed to be a compression program of some sort. @xref{gzip}. -@@ -8570,6 +8571,7 @@ Filter the archive through @command{compress}. Otherwise like @option{--gzip}. - - @opindex use-compress-program - @item --use-compress-program=@var{prog} -+@itemx -I=@var{prog} - Use external compression program @var{prog}. Use this option if you - have a compression program that @GNUTAR{} does not support. There - are two requirements to which @var{prog} should comply: -@@ -8608,14 +8610,14 @@ Suppose you name it @file{gpgz} and save it somewhere in your - archive signed with your private key: - - @smallexample --$ @kbd{tar -cf foo.tar.gpgz --use-compress=gpgz .} -+$ @kbd{tar -cf foo.tar.gpgz -Igpgz .} - @end smallexample - - @noindent --Likewise, the following command will list its contents: -+Likewise, the command below will list its contents: - - @smallexample --$ @kbd{tar -tf foo.tar.gpgz --use-compress=gpgz .} -+$ @kbd{tar -tf foo.tar.gpgz -Igpgz .} - @end smallexample - - @ignore -diff --git a/src/tar.c b/src/tar.c -index ae0c739..8396ad5 100644 ---- a/src/tar.c -+++ b/src/tar.c -@@ -323,7 +323,6 @@ enum - TRANSFORM_OPTION, - UNQUOTE_OPTION, - USAGE_OPTION, -- USE_COMPRESS_PROGRAM_OPTION, - UTC_OPTION, - VERSION_OPTION, - VOLNO_FILE_OPTION, -@@ -352,7 +351,7 @@ The version control may be set with --backup or VERSION_CONTROL, values are:\n\n - - /* NOTE: - -- Available option letters are DEIQY and eqy. Consider the following -+ Available option letters are DEQY and eqy. Consider the following - assignments: - - [For Solaris tar compatibility =/= Is it important at all?] -@@ -360,7 +359,6 @@ The version control may be set with --backup or VERSION_CONTROL, values are:\n\n - E use extended headers (--format=posix) - - [q alias for --occurrence=1 =/= this would better be used for quiet?] -- [I same as T =/= will harm star compatibility] - - y per-file gzip compression - Y per-block gzip compression */ -@@ -610,7 +608,7 @@ static struct argp_option options[] = { - N_("filter the archive through lzma"), GRID+1 }, - {"lzop", LZOP_OPTION, 0, 0, - N_("filter the archive through lzop"), GRID+8 }, -- {"use-compress-program", USE_COMPRESS_PROGRAM_OPTION, N_("PROG"), 0, -+ {"use-compress-program", 'I', N_("PROG"), 0, - N_("filter through PROG (must accept -d)"), GRID+1 }, - #undef GRID - -@@ -1364,12 +1362,6 @@ parse_opt (int key, char *arg, struct argp_state *state) - ignore_zeros_option = true; - break; - -- case 'I': -- USAGE_ERROR ((0, 0, -- _("Warning: the -I option is not supported;" -- " perhaps you meant -j or -T?"))); -- break; -- - case 'j': - set_use_compress_program_option ("bzip2"); - break; -@@ -1905,7 +1897,7 @@ parse_opt (int key, char *arg, struct argp_state *state) - set_transform_expr (arg); - break; - -- case USE_COMPRESS_PROGRAM_OPTION: -+ case 'I': - set_use_compress_program_option (arg); - break; - -diff --git a/tests/pipe.at b/tests/pipe.at -index efca65b..be99212 100644 ---- a/tests/pipe.at -+++ b/tests/pipe.at -@@ -1,7 +1,7 @@ - # Process this file with autom4te to create testsuite. -*- Autotest -*- - - # Test suite for GNU tar. --# Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc. -+# Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. - - # This program is free software; you can redistribute it and/or modify - # it under the terms of the GNU General Public License as published by -@@ -30,7 +30,8 @@ AT_SETUP([decompressing from stdin]) - - AT_KEYWORDS([pipe]) - --AT_TAR_CHECK([ -+AT_TAR_WITH_HOOK([TAR_IGNREC_HOOK], -+[AT_TAR_CHECK([ - AT_SORT_PREREQ - - mkdir directory -@@ -49,6 +50,7 @@ directory/file1 - directory/file2 - separator - separator --]) -+], -+[stderr])]) - - AT_CLEANUP -diff --git a/tests/shortrec.at b/tests/shortrec.at -index 3e009fd..179f365 100644 ---- a/tests/shortrec.at -+++ b/tests/shortrec.at -@@ -1,7 +1,7 @@ - # Process this file with autom4te to create testsuite. -*- Autotest -*- - - # Test suite for GNU tar. --# Copyright (C) 2005, 2007 Free Software Foundation, Inc. -+# Copyright (C) 2005, 2007, 2008 Free Software Foundation, Inc. - - # This program is free software; you can redistribute it and/or modify - # it under the terms of the GNU General Public License as published by -@@ -23,17 +23,22 @@ - # used to create the archive. - - AT_SETUP([short records]) --AT_KEYWORDS([shortrec.at]) -+AT_KEYWORDS([shortrec]) - --AT_TAR_CHECK([ -+AT_TAR_WITH_HOOK([TAR_IGNREC_HOOK], -+[AT_TAR_CHECK([ - mkdir directory - (cd directory && touch a b c d e f g h i j k l m n o p q r) --tar -c -b 1 -f - directory | tar -t -f - >/dev/null -+tar -c -b 1 -f - directory | tar -t -f - - tar -c -b 1 -f archive directory --tar -t -f archive >/dev/null --tar -t -f - < archive >/dev/null -+tar -t -f archive -+tar -t -f - < archive - - rm -r directory -+], -+[0], -+[ignore], -+[stderr]) - ]) - - AT_CLEANUP -diff --git a/tests/testsuite.at b/tests/testsuite.at -index 2fa5392..a12477d 100644 ---- a/tests/testsuite.at -+++ b/tests/testsuite.at -@@ -1,7 +1,7 @@ - # Process this file with autom4te to create testsuite. -*- Autotest -*- - - # Test suite for GNU tar. --# Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc. -+# Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. - - # This program is free software; you can redistribute it and/or modify - # it under the terms of the GNU General Public License as published by -@@ -21,6 +21,7 @@ - # We need a recent Autotest. - m4_version_prereq([2.52g]) - -+m4_define([AT_TAR_CHECK_HOOK]) - m4_define([AT_TAR_CHECK],[ - AT_XFAIL_IF(test -f $[]XFAILFILE) - m4_foreach([FMT], -@@ -33,9 +34,20 @@ export TEST_TAR_FORMAT - TAR_OPTIONS="-H FMT" - export TAR_OPTIONS - rm -rf * --$1)],$2,$3,$4,$5,$6)]) -+$1)],$2,$3,$4,$5,$6) -+ AT_TAR_CHECK_HOOK]) - ]) - -+m4_define([AT_TAR_WITH_HOOK],[ -+ m4_pushdef([AT_TAR_CHECK_HOOK],[$1]) -+ $2 -+ -+ m4_popdef([AT_TAR_CHECK_HOOK])]) -+ -+m4_define([TAR_IGNREC_HOOK],[ -+ AT_CHECK([grep -v '^.*tar: Record size = ' stderr; exit 0]) -+]) -+ - m4_define([RE_CHECK],[ - AT_DATA([$1.re],[$2]) - awk '{print NR " " $[]0}' $1 > $[]$.1