@ -1,8 +1,7 @@
diff --git a/configure.ac b/configure.ac
index 762f8e4..c442489 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,7 +40,7 @@ AC_CHECK_HEADERS_ONCE(fcntl.h linux/fd.h memory.h net/errno.h \
diff -urNp tar-1.23-orig/configure.ac tar-1.23/configure.ac
--- tar-1.23-orig/configure.ac 2010-03-10 11:47:54.000000000 +0100
+++ tar-1.23/configure.ac 2010-03-12 13:48:43.000000000 +0100
@@ -44,7 +44,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 \
sys/mtio.h sys/time.h sys/tprintf.h sys/tape.h \
@ -11,7 +10,7 @@ index 762f8e4..c442489 100644
AC_CHECK_HEADERS([sys/buf.h], [], [],
[#if HAVE_SYS_PARAM_H
@@ - 88,6 +88 ,12 @@ gl_INIT
@@ - 91,6 +91 ,12 @@ gl_INIT
tar_PAXUTILS
AC_CHECK_FUNCS(fsync getdtablesize lstat mkfifo readlink symlink setlocale utimes)
@ -24,7 +23,7 @@ index 762f8e4..c442489 100644
AC_CHECK_DECLS([getgrgid],,, [#include <grp.h>])
AC_CHECK_DECLS([getpwuid],,, [#include <pwd.h>])
AC_CHECK_DECLS([time],,, [#include <time.h>])
@@ -2 03,6 +209,7 @@ AC_DEFINE_UNQUOTED(DEFAULT_QUOTING_STYLE, $DEFAULT_QUOTING_STYLE,
@@ -2 14,6 +220,7 @@ AC_DEFINE_UNQUOTED(DEFAULT_QUOTING_STYLE
# Iconv
AM_ICONV
AC_CHECK_HEADERS(iconv.h)
@ -32,7 +31,7 @@ index 762f8e4..c442489 100644
AC_CHECK_TYPE(iconv_t,:,
AC_DEFINE(iconv_t, int,
[Conversion descriptor type]),
@@ -2 12,6 +219 ,17 @@ AC_CHECK_TYPE(iconv_t,:,
@@ -2 23,6 +230 ,17 @@ AC_CHECK_TYPE(iconv_t,:,
#endif
])
@ -50,11 +49,10 @@ index 762f8e4..c442489 100644
# Gettext.
AM_GNU_GETTEXT([external], [need-formatstring-macros])
AM_GNU_GETTEXT_VERSION([0.16])
diff --git a/doc/tar.texi b/doc/tar.texi
index 7d8952b..e9c5693 100644
--- a/doc/tar.texi
+++ b/doc/tar.texi
@@ -2345,6 +2345,10 @@ Normally when creating an archive, @command{tar} strips an initial
diff -urNp tar-1.23-orig/doc/tar.texi tar-1.23/doc/tar.texi
--- tar-1.23-orig/doc/tar.texi 2010-03-09 15:24:24.000000000 +0100
+++ tar-1.23/doc/tar.texi 2010-03-12 13:48:43.000000000 +0100
@@ -2364,6 +2364,10 @@ Normally when creating an archive, @comm
@samp{/} from member names. This option disables that behavior.
@xref{absolute}.
@ -65,7 +63,7 @@ index 7d8952b..e9c5693 100644
@opsummary{after-date}
@item --after-date
@@ -28 44,6 +2848,10 @@ contents have changed (as opposed to just @option{--newer}, which will
@@ -28 85,6 +2889,10 @@ contents have changed (as opposed to jus
also back up files for which any status information has
changed). @xref{after}.
@ -76,9 +74,9 @@ index 7d8952b..e9c5693 100644
@opsummary{no-anchored}
@item --no-anchored
An exclude pattern can match any subsequence of the name's components.
@@ -29 19,11 +2927,21 @@ When extracting an archive, subtract the user's umask from files fro m
the permissions specified in the archive. This is the default behavior
for ordinary users .
@@ -29 68,11 +2976,21 @@ locations. Usually @command{tar} deter m
the archive can be seeked or not. Use this option to disable this
mechanism .
+@opsummary{no-selinux}
+@item --no-selinux
@ -98,9 +96,9 @@ index 7d8952b..e9c5693 100644
@opsummary{no-wildcards}
@item --no-wildcards
Do not use wildcards.
@@ -3 151,6 +3169,11 @@ locations. Usually @command{tar} determines automatically whether
the archive can be seeked or not. This option is intended for use
in cases when such recognition fails .
@@ -3 202,6 +3220,11 @@ in cases when such recognition fails. I
archive is open for reading (e.g. with @option{--list} or
@option{--extract} options) .
+@opsummary{selinux}
+@item --selinux
@ -110,9 +108,9 @@ index 7d8952b..e9c5693 100644
@opsummary{show-defaults}
@item --show-defaults
@@ -3 349,6 +3372,11 @@ Used in conjunction with @option{--multi-volume}. @command{tar} will
keep track of which volume of a multi-volume archive it is working in
@var{file}. @xref{volno-file }.
@@ -3 411,6 +3434,11 @@ Enable or disable warning messages ident
messages are suppressed if @var{keyword} is prefixed with @samp{no-}.
@xref{warnings }.
+@opsummary{xattrs}
+@item --xattrs
@ -122,7 +120,7 @@ index 7d8952b..e9c5693 100644
@opsummary{wildcards}
@item --wildcards
Use wildcards when matching member names with patterns.
@@ -8 350,6 +8378,8 @@ implementation able to read @samp{ustar} archives will be able to read
@@ -8 599,6 +8627,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.
@ -131,7 +129,7 @@ index 7d8952b..e9c5693 100644
This archive format will be the default format for future versions
of @GNUTAR{}.
@@ - 8902,6 +8932,51 @@ Same as both @option{--same-permissions} and @option{--same-order}.
@@ - 9160,6 +9190,51 @@ Same as both @option{--same-permissions}
This option is deprecated, and will be removed in @GNUTAR{} version 1.23.
@ -183,38 +181,10 @@ index 7d8952b..e9c5693 100644
@end table
@node Portability
diff --git a/src/Makefile.am b/src/Makefile.am
index c22a568..8755333 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -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 --git a/src/common.h b/src/common.h
index 9897b46..5318279 100644
--- a/src/common.h
+++ b/src/common.h
@@ -248,6 +248,15 @@ GLOBAL int same_owner_option;
diff -urNp tar-1.23-orig/src/common.h tar-1.23/src/common.h
--- tar-1.23-orig/src/common.h 2010-01-26 13:21:18.000000000 +0100
+++ tar-1.23/src/common.h 2010-03-12 13:48:43.000000000 +0100
@@ -251,6 +251,15 @@ GLOBAL int same_owner_option;
/* If positive, preserve permissions when extracting. */
GLOBAL int same_permissions_option;
@ -230,7 +200,7 @@ index 9897b46..5318279 100644
/* When set, strip the given number of file name components from the file name
before extracting */
GLOBAL size_t strip_name_components;
@@ - 673,6 +682 ,9 @@ extern char *output_start;
@@ - 732,6 +741 ,9 @@ extern char *output_start;
void update_archive (void);
@ -240,7 +210,7 @@ index 9897b46..5318279 100644
/* Module xheader.c. */
void xheader_init (struct xheader *xhdr);
@@ - 694,6 +706,12 @@ bool xheader_string_end (struct xheader *xhdr, char const *keyword);
@@ - 753,6 +765,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);
@ -253,10 +223,9 @@ index 9897b46..5318279 100644
/* Module system.c */
diff --git a/src/create.c b/src/create.c
index a925160..29a6fd8 100644
--- a/src/create.c
+++ b/src/create.c
diff -urNp tar-1.23-orig/src/create.c tar-1.23/src/create.c
--- tar-1.23-orig/src/create.c 2010-03-09 13:52:41.000000000 +0100
+++ tar-1.23/src/create.c 2010-03-12 13:48:43.000000000 +0100
@@ -24,6 +24,7 @@
#include <quotearg.h>
@ -265,7 +234,7 @@ index a925160..29a6fd8 100644
#include <hash.h>
struct link
@@ -94 4,6 +945 ,30 @@ start_header (struct tar_stat_info *st)
@@ -94 7,6 +948 ,30 @@ start_header (struct tar_stat_info *st)
GNAME_TO_CHARS (st->gname, header->header.gname);
}
@ -296,7 +265,7 @@ index a925160..29a6fd8 100644
return header;
}
@@ -15 78,6 +1603,10 @@ dump_file0 (struct tar_stat_info *st, const char *p,
@@ -15 80,6 +1605,10 @@ dump_file0 (struct tar_stat_info *st, co
}
}
@ -307,7 +276,7 @@ index a925160..29a6fd8 100644
if (is_dir)
{
const char *tag_file_name;
@@ -170 9,6 +1738,9 @@ dump_file0 (struct tar_stat_info *st, const char *p,
@@ -170 2,6 +1731,9 @@ dump_file0 (struct tar_stat_info *st, co
if (NAME_FIELD_SIZE - (archive_format == OLDGNU_FORMAT) < size)
write_long_link (st);
@ -317,11 +286,10 @@ index a925160..29a6fd8 100644
block_ordinal = current_block_ordinal ();
st->stat.st_size = 0; /* force 0 size on symlink */
header = start_header (st);
diff --git a/src/extract.c b/src/extract.c
index 6d70398..ac33df2 100644
--- a/src/extract.c
+++ b/src/extract.c
@@ -69,6 +69,13 @@ struct delayed_set_stat
diff -urNp tar-1.23-orig/src/extract.c tar-1.23/src/extract.c
--- tar-1.23-orig/src/extract.c 2010-01-26 12:28:09.000000000 +0100
+++ tar-1.23/src/extract.c 2010-03-12 13:48:43.000000000 +0100
@@ -70,6 +70,13 @@ struct delayed_set_stat
mode_t invert_permissions;
enum permstatus permstatus;
bool after_links;
@ -335,7 +303,7 @@ index 6d70398..ac33df2 100644
char file_name[1];
};
@@ -9 6,6 +103 ,18 @@ struct delayed_link
@@ -9 7,6 +104 ,18 @@ struct delayed_link
hard-linked together. */
struct string_list *sources;
@ -354,7 +322,7 @@ index 6d70398..ac33df2 100644
/* The desired target of the desired link. */
char target[1];
};
@@ -2 76,6 +295 ,10 @@ set_stat (char const *file_name,
@@ -2 90,6 +309 ,10 @@ set_stat (char const *file_name,
give files away. */
}
@ -365,7 +333,7 @@ index 6d70398..ac33df2 100644
if (0 < same_owner_option && permstatus != INTERDIR_PERMSTATUS)
{
/* When lchown exists, it should be used to change the attributes of
@@ -3 52,6 +375,29 @@ delay_set_stat (char const *file_name, struct tar_stat_info const *st,
@@ -3 66,6 +389,29 @@ delay_set_stat (char const *file_name, s
data->invert_permissions = invert_permissions;
data->permstatus = permstatus;
data->after_links = 0;
@ -395,7 +363,7 @@ index 6d70398..ac33df2 100644
strcpy (data->file_name, file_name);
delayed_set_stat_head = data;
}
@@ -5 46,6 +592,31 @@ maybe_recoverable (char *file_name, int *interdir_made)
@@ -5 71,6 +617,31 @@ maybe_recoverable (char *file_name, int
}
}
@ -427,7 +395,7 @@ index 6d70398..ac33df2 100644
/* Fix the statuses of all directories whose statuses need fixing, and
which are not ancestors of FILE_NAME. If AFTER_LINKS is
nonzero, do this for all such directories; otherwise, stop at the
@@ - 599,11 +670,22 @@ apply_nonancestor_delayed_set_stat (char const *file_name, bool after_links)
@@ - 624,11 +695,22 @@ apply_nonancestor_delayed_set_stat (char
sb.stat.st_gid = data->gid;
sb.atime = data->atime;
sb.mtime = data->mtime;
@ -450,7 +418,7 @@ index 6d70398..ac33df2 100644
free (data);
}
}
@@ - 696,7 +778,7 @@ extract_dir (char *file_name, int typeflag)
@@ - 730,7 +812,7 @@ extract_dir (char *file_name, int typefl
static int
@ -459,7 +427,7 @@ index 6d70398..ac33df2 100644
{
int fd;
int openflag = (O_WRONLY | O_BINARY | O_CREAT
@@ -7 04,6 +786,10 @@ open_output_file (char *file_name, int typeflag, mode_t mode)
@@ -7 38,6 +820,10 @@ open_output_file (char *file_name, int t
? O_TRUNC
: O_EXCL));
@ -470,10 +438,10 @@ index 6d70398..ac33df2 100644
#if O_CTG
/* Contiguous files (on the Masscomp) have to specify the size in
the open call that creates them. */
@@ -760,8 +846,18 @@ extract_file (char *file_name, int typeflag)
}
@@ -796,8 +882,18 @@ extract_file (char *file_name, int typef
else
{
int recover = RECOVER_NO;
+ int file_created = 0;
+ if (set_xattr (file_name, ¤t_stat_info, invert_permissions,
+ typeflag, &file_created))
@ -487,10 +455,10 @@ index 6d70398..ac33df2 100644
- fd = open_output_file (file_name, typeflag, mode ^ invert_permissions);
+ fd = open_output_file (file_name, typeflag, mode ^ invert_permissions,
+ file_created);
while (fd < 0 && maybe_recoverable (file_name, &interdir_made));
if (fd < 0)
@@ - 882,6 +978,13 @@ create_placeholder_file (char *file_name, bool is_symlink, int *interdir_made)
while (fd < 0
&& (recover = maybe_recoverable (file_name, &interdir_made))
== RECOVER_OK);
@@ - 922,6 +1018,13 @@ create_placeholder_file (char *file_name
+ strlen (file_name) + 1);
p->sources->next = 0;
strcpy (p->sources->string, file_name);
@ -504,7 +472,7 @@ index 6d70398..ac33df2 100644
strcpy (p->target, current_stat_info.link_name);
h = delayed_set_stat_head;
@@ -1 288,6 +1391 ,13 @@ apply_delayed_links (void)
@@ -1 335,6 +1438 ,13 @@ apply_delayed_links (void)
struct tar_stat_info st1;
st1.stat.st_uid = ds->uid;
st1.stat.st_gid = ds->gid;
@ -518,7 +486,7 @@ index 6d70398..ac33df2 100644
set_stat (source, &st1, NULL, 0, 0, SYMTYPE);
valid_source = source;
}
@@ -13 01,6 +1411 ,9 @@ apply_delayed_links (void)
@@ -13 48,6 +1458 ,9 @@ apply_delayed_links (void)
sources = next;
}
@ -528,11 +496,10 @@ index 6d70398..ac33df2 100644
{
struct delayed_link *next = ds->next;
free (ds);
diff --git a/src/list.c b/src/list.c
index c060701..abb94bf 100644
--- a/src/list.c
+++ b/src/list.c
@@ -568,6 +568,13 @@ decode_header (union block *header, struct tar_stat_info *stat_info,
diff -urNp tar-1.23-orig/src/list.c tar-1.23/src/list.c
--- tar-1.23-orig/src/list.c 2010-03-12 13:40:53.000000000 +0100
+++ tar-1.23/src/list.c 2010-03-12 13:48:43.000000000 +0100
@@ -585,6 +585,13 @@ decode_header (union block *header, stru
assign_string (&stat_info->gname,
header->header.gname[0] ? header->header.gname : NULL);
@ -546,11 +513,36 @@ index c060701..abb94bf 100644
if (format == OLDGNU_FORMAT && incremental_option)
{
stat_info->atime.tv_sec = TIME_FROM_HEADER (header->oldgnu_header.atime);
diff --git a/src/tar.c b/src/tar.c
index dbffc2a..510350b 100644
--- a/src/tar.c
+++ b/src/tar.c
@@ -246,7 +246,8 @@ tar_set_quoting_style (char *arg)
diff -urNp tar-1.23-orig/src/Makefile.am tar-1.23/src/Makefile.am
--- tar-1.23-orig/src/Makefile.am 2010-01-26 12:30:20.000000000 +0100
+++ tar-1.23/src/Makefile.am 2010-03-12 13:48:43.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\
@@ -42,10 +42,11 @@ tar_SOURCES = \
unlink.c\
update.c\
utf8.c\
- warning.c
+ warning.c\
+ xattrs.c
INCLUDES = -I$(top_srcdir)/gnu -I../ -I../gnu -I$(top_srcdir)/lib -I../lib
LDADD = ../lib/libtar.a ../gnu/libgnu.a $(LIBINTL) $(LIBICONV)
-tar_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
+tar_LDADD = $(LIBS) $(LDADD) $(LIB_CLOCK_GETTIME)
diff -urNp tar-1.23-orig/src/tar.c tar-1.23/src/tar.c
--- tar-1.23-orig/src/tar.c 2010-03-09 13:52:41.000000000 +0100
+++ tar-1.23/src/tar.c 2010-03-12 13:48:43.000000000 +0100
@@ -255,7 +255,8 @@ tar_set_quoting_style (char *arg)
enum
{
@ -560,7 +552,7 @@ index dbffc2a..510350b 100644
ATIME_PRESERVE_OPTION,
BACKUP_OPTION,
CHECK_DEVICE_OPTION,
@@ -2 76,6 +277 ,7 @@ enum
@@ -2 87,6 +288 ,7 @@ enum
MODE_OPTION,
MTIME_OPTION,
NEWER_MTIME_OPTION,
@ -568,10 +560,10 @@ index dbffc2a..510350b 100644
NO_ANCHORED_OPTION,
NO_AUTO_COMPRESS_OPTION,
NO_CHECK_DEVICE_OPTION,
@@ -288,9 +290,11 @@ enum
NO_RECURSION_OPTION,
@@ -300,9 +302,11 @@ enum
NO_SAME_OWNER_OPTION,
NO_SAME_PERMISSIONS_OPTION,
NO_SEEK_OPTION,
+ NO_SELINUX_CONTEXT_OPTION,
NO_UNQUOTE_OPTION,
NO_WILDCARDS_MATCH_SLASH_OPTION,
@ -580,7 +572,7 @@ index dbffc2a..510350b 100644
NULL_OPTION,
NUMERIC_OWNER_OPTION,
OCCURRENCE_OPTION,
@@ -3 12,6 +316 ,7 @@ enum
@@ -3 24,6 +328 ,7 @@ enum
RMT_COMMAND_OPTION,
RSH_COMMAND_OPTION,
SAME_OWNER_OPTION,
@ -588,9 +580,9 @@ index dbffc2a..510350b 100644
SHOW_DEFAULTS_OPTION,
SHOW_OMITTED_DIRS_OPTION,
SHOW_TRANSFORMED_NAMES_OPTION,
@@ -328,7 +333,8 @@ enum
VERSION_OPTION,
@@ -339,7 +344,8 @@ enum
VOLNO_FILE_OPTION,
WARNING_OPTION,
WILDCARDS_MATCH_SLASH_OPTION,
- WILDCARDS_OPTION
+ WILDCARDS_OPTION,
@ -598,7 +590,7 @@ index dbffc2a..510350b 100644
};
const char *argp_program_version = "tar (" PACKAGE_NAME ") " VERSION;
@@ -4 65,6 +47 1,10 @@ static struct argp_option options[] = {
@@ -4 85,6 +49 1,10 @@ static struct argp_option options[] = {
{NULL, 0, NULL, 0,
N_("Handling of file attributes:"), GRID },
@ -609,7 +601,7 @@ index dbffc2a..510350b 100644
{"owner", OWNER_OPTION, N_("NAME"), 0,
N_("force NAME as owner for added files"), GRID+1 },
{"group", GROUP_OPTION, N_("NAME"), 0,
@@ - 495,6 +50 5,14 @@ static struct argp_option options[] = {
@@ - 515,6 +52 5,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 },
@ -624,7 +616,7 @@ index dbffc2a..510350b 100644
{"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 argp_state *state)
@@ - 2060,6 +2078,37 @@ parse_opt (int key, char *arg, struct ar
same_permissions_option = -1;
break;
@ -662,7 +654,7 @@ index dbffc2a..510350b 100644
case RECURSION_OPTION:
recursion_option = FNM_LEADING_DIR;
break;
@@ -2 330,6 +2379 ,29 @@ decode_options (int argc, char **argv)
@@ -2 442,6 +2491 ,29 @@ decode_options (int argc, char **argv)
|| subcommand_option != LIST_SUBCOMMAND))
USAGE_ERROR ((0, 0, _("--pax-option can be used only on POSIX archives")));
@ -692,7 +684,7 @@ index dbffc2a..510350b 100644
/* If ready to unlink hierarchies, so we are for simpler files. */
if (recursive_unlink_option)
old_files_option = UNLINK_FIRST_OLD_FILES;
@@ -2 544,11 +2616 ,15 @@ tar_stat_init (struct tar_stat_info *st)
@@ -2 662,11 +2734 ,15 @@ tar_stat_init (struct tar_stat_info *st)
void
tar_stat_destroy (struct tar_stat_info *st)
{
@ -708,10 +700,9 @@ index dbffc2a..510350b 100644
free (st->sparse_map);
free (st->dumpdir);
xheader_destroy (&st->xhdr);
diff --git a/src/tar.h b/src/tar.h
index 7f72f3e..49ee1ee 100644
--- a/src/tar.h
+++ b/src/tar.h
diff -urNp tar-1.23-orig/src/tar.h tar-1.23/src/tar.h
--- tar-1.23-orig/src/tar.h 2010-01-26 12:30:20.000000000 +0100
+++ tar-1.23/src/tar.h 2010-03-12 13:48:43.000000000 +0100
@@ -276,6 +276,14 @@ struct xheader
uintmax_t string_length;
};
@ -753,11 +744,9 @@ index 7f72f3e..49ee1ee 100644
/* Extended headers */
struct xheader xhdr;
diff --git a/src/xattrs.c b/src/xattrs.c
new file mode 100644
index 0000000..fea18c3
--- /dev/null
+++ b/src/xattrs.c
diff -urNp tar-1.23-orig/src/xattrs.c tar-1.23/src/xattrs.c
--- tar-1.23-orig/src/xattrs.c 1970-01-01 01:00:00.000000000 +0100
+++ tar-1.23/src/xattrs.c 2010-03-12 13:48:43.000000000 +0100
@@ -0,0 +1,488 @@
+/* Create a tar archive.
+
@ -1247,11 +1236,9 @@ index 0000000..fea18c3
+#endif
+ }
+}
diff --git a/src/xattrs.h b/src/xattrs.h
new file mode 100644
index 0000000..ebbd5c6
--- /dev/null
+++ b/src/xattrs.h
diff -urNp tar-1.23-orig/src/xattrs.h tar-1.23/src/xattrs.h
--- tar-1.23-orig/src/xattrs.h 1970-01-01 01:00:00.000000000 +0100
+++ tar-1.23/src/xattrs.h 2010-03-12 13:48:43.000000000 +0100
@@ -0,0 +1,14 @@
+
+extern void xattrs_acls_get(struct tar_stat_info *st,
@ -1267,12 +1254,11 @@ index 0000000..ebbd5c6
+ char const *file_name, char typeflag);
+extern void xattrs_xattrs_set(struct tar_stat_info const *st,
+ char const *file_name, char typeflag);
diff --git a/src/xheader.c b/src/xheader.c
index 919ecd3..8e18421 100644
--- a/src/xheader.c
+++ b/src/xheader.c
@@ -417,6 +417,74 @@ xheader_write_global (struct xheader *xhdr)
free (name);
diff -urNp tar-1.23-orig/src/xheader.c tar-1.23/src/xheader.c
--- tar-1.23-orig/src/xheader.c 2010-02-12 11:03:09.000000000 +0100
+++ tar-1.23/src/xheader.c 2010-03-12 13:50:44.000000000 +0100
@@ -459,6 +459,74 @@ xheader_write_global (struct xheader *xh
}
}
+void xheader_xattr_init(struct tar_stat_info *st)
@ -1346,15 +1332,15 @@ index 919ecd3..8e18421 100644
/* General Interface */
@@ -4 2 7,6 +49 5,7 @@ struct xhdr_tab
@@ -4 72 ,6 +540 ,7 @@ struct xhdr_tab
struct xheader *, void const *data);
void (*decoder) (struct tar_stat_info *, char const *, char const *, size_t);
bool protect ;
int flags ;
+ bool prefix;
};
/* This declaration must be extern, because ISO C99 section 6.9.2
@@ -4 43,8 +512 ,17 @@ locate_handler (char const *keyword)
@@ -4 88,8 +557 ,17 @@ locate_handler (char const *keyword)
struct xhdr_tab const *p;
for (p = xhdr_tab; p->keyword; p++)
@ -1374,25 +1360,25 @@ index 919ecd3..8e18421 100644
return NULL;
}
@@ -4 54,7 +532,7 @@ xheader_protected_pattern_p (const char *pattern)
@@ -4 99,7 +577,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)
- if ( (p->flags & XHDR_PROTECTED) && fnmatch (pattern, p->keyword, 0) == 0)
+ if (!p->prefix && (p->flags & XHDR_PROTECTED) && fnmatch (pattern, p->keyword, 0) == 0)
return true;
return false;
}
@@ - 465,7 +543,7 @@ xheader_protected_keyword_p (const char *keyword)
@@ - 510,7 +588,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)
- if ( (p->flags & XHDR_PROTECTED) && strcmp (p->keyword, keyword) == 0)
+ if (!p->prefix && (p->flags & XHDR_PROTECTED) && strcmp (p->keyword, keyword) == 0)
return true;
return false;
}
@@ -14 17,6 +1495,71 @@ volume_filename_decoder (struct tar_stat_info *st,
@@ -14 69,6 +1547,71 @@ volume_filename_decoder (struct tar_stat
}
static void
@ -1464,109 +1450,125 @@ index 919ecd3..8e18421 100644
sparse_major_coder (struct tar_stat_info const *st, char const *keyword,
struct xheader *xhdr, void const *data)
{
@@ -1 453,18 +1596,18 @@ sparse_minor_decoder (struct tar_stat_info *st,
@@ -1 505,53 +1648,53 @@ 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 },
- { "atime", atime_coder, atime_decoder, 0 },
- { "comment", dummy_coder, dummy_decoder, 0 },
- { "charset", dummy_coder, dummy_decoder, 0 },
- { "ctime", ctime_coder, ctime_decoder, 0 },
- { "gid", gid_coder, gid_decoder, 0 },
- { "gname", gname_coder, gname_decoder, 0 },
- { "linkpath", linkpath_coder, linkpath_decoder, 0 },
- { "mtime", mtime_coder, mtime_decoder, 0 },
- { "path", path_coder, path_decoder, 0 },
- { "size", size_coder, size_decoder, 0 },
- { "uid", uid_coder, uid_decoder, 0 },
- { "uname", uname_coder, uname_decoder, 0 },
+ { "atime", atime_coder, atime_decoder, 0 , false },
+ { "comment", dummy_coder, dummy_decoder, 0 , false },
+ { "charset", dummy_coder, dummy_decoder, 0 , false },
+ { "ctime", ctime_coder, ctime_decoder, 0 , false },
+ { "gid", gid_coder, gid_decoder, 0 , false },
+ { "gname", gname_coder, gname_decoder, 0 , false },
+ { "linkpath", linkpath_coder, linkpath_decoder, 0 , false },
+ { "mtime", mtime_coder, mtime_decoder, 0 , false },
+ { "path", path_coder, path_decoder, 0 , false },
+ { "size", size_coder, size_decoder, 0 , false },
+ { "uid", uid_coder, uid_decoder, 0 , false },
+ { "uname", uname_coder, uname_decoder, 0 , false },
/* Sparse file handling */
{ "GNU.sparse.name", path_coder, path_decoder,
@@ -1479,25 +1622,25 @@ struct xhdr_tab const xhdr_tab[] = {
true },
- XHDR_PROTECTED },
+ XHDR_PROTECTED, false },
{ "GNU.sparse.major", sparse_major_coder, sparse_major_decoder,
- XHDR_PROTECTED },
+ XHDR_PROTECTED, false },
{ "GNU.sparse.minor", sparse_minor_coder, sparse_minor_decoder,
- XHDR_PROTECTED },
+ XHDR_PROTECTED, false },
{ "GNU.sparse.realsize", sparse_size_coder, sparse_size_decoder,
- XHDR_PROTECTED },
+ XHDR_PROTECTED, false },
{ "GNU.sparse.numblocks", sparse_numblocks_coder, sparse_numblocks_decoder,
- XHDR_PROTECTED },
+ XHDR_PROTECTED, false },
/* 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 },
{ "GNU.sparse.size", sparse_size_coder, sparse_size_decoder,
- XHDR_PROTECTED },
+ XHDR_PROTECTED, 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 },
- XHDR_PROTECTED },
+ XHDR_PROTECTED , false },
{ "GNU.sparse.numbytes", sparse_numbytes_coder, sparse_numbytes_decoder,
- true },
+ true , false },
- XHDR_PROTECTED },
+ XHDR_PROTECTED , 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 },
- sparse_map_decoder, 0 },
+ sparse_map_decoder, 0 , false },
{ "GNU.dumpdir", dumpdir_coder, dumpdir_decoder,
- true },
+ true , false },
- XHDR_PROTECTED },
+ XHDR_PROTECTED , 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 },
{ "GNU.volume.label", volume_label_coder, volume_label_decoder,
- XHDR_PROTECTED | XHDR_GLOBAL },
+ XHDR_PROTECTED | XHDR_GLOBAL, false },
/* These may be present in a first global header of the archive.
They provide the same functionality as GNUTYPE_MULTIVOL header.
@@ -15 06,9 +1649,39 @@ struct xhdr_tab const xhdr_tab[] = {
@@ -15 60,11 +1703,40 @@ 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 },
- XHDR_PROTECTED | XHDR_GLOBAL },
+ XHDR_PROTECTED | XHDR_GLOBAL, false },
{ "GNU.volume.size", volume_size_coder, volume_size_decoder,
- XHDR_PROTECTED | XHDR_GLOBAL },
+ XHDR_PROTECTED | XHDR_GLOBAL, false },
{ "GNU.volume.offset", volume_offset_coder, volume_offset_decoder,
- XHDR_PROTECTED | XHDR_GLOBAL },
+ XHDR_PROTECTED | XHDR_GLOBAL, 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 },
+ xattr_selinux_coder, xattr_selinux_decoder, 0 , false },
+
+ /* ACLs, use the star format... */
+ { "SCHILY.acl.access",
+ xattr_acls_a_coder, xattr_acls_a_decoder, false , false },
+ xattr_acls_a_coder, xattr_acls_a_decoder, 0 , false },
+
+ { "SCHILY.acl.default",
+ xattr_acls_d_coder, xattr_acls_d_decoder, false , false },
+ xattr_acls_d_coder, xattr_acls_d_decoder, 0 , 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 },
+ xattr_selinux_coder, xattr_selinux_decoder, 0 , false },
+ { "SCHILY.xattr.system.posix_acl_access",
+ xattr_acls_a_coder, xattr_acls_a_decoder, false , false },
+ xattr_acls_a_coder, xattr_acls_a_decoder, 0 , false },
+ { "SCHILY.xattr.system.posix_acl_default",
+ xattr_acls_d_coder, xattr_acls_d_decoder, false , false },
+ xattr_acls_d_coder, xattr_acls_d_decoder, 0 , false },
+
+ /* xattrs use the star format. note we only save some variants... */
+ { "SCHILY.xattr.user", xattr_coder, xattr_decoder, false , true },
+ { "SCHILY.xattr.trusted", xattr_coder, xattr_decoder, false , true },
+ { "SCHILY.xattr.lustre", xattr_coder, xattr_decoder, false , true },
+ { "SCHILY.xattr.user", xattr_coder, xattr_decoder, 0 , true },
+ { "SCHILY.xattr.trusted", xattr_coder, xattr_decoder, 0 , true },
+ { "SCHILY.xattr.lustre", xattr_coder, xattr_decoder, 0 , true },
+
+ /* ignore everything else in the xattr namespaces... */
+ { "SCHILY.xattr", dummy_coder, dummy_decoder, false , true },
+ { "SCHILY.xattr", dummy_coder, dummy_decoder, 0 , true },
{ NULL, NULL, NULL, false }
- { NULL, NULL, NULL, 0 }
+ { NULL, NULL, NULL, 0, false }
};