From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RSqHn-0003LM-CN for garchives@archives.gentoo.org; Tue, 22 Nov 2011 13:21:19 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id D69E521C042; Tue, 22 Nov 2011 13:21:02 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 4025B21C042 for ; Tue, 22 Nov 2011 13:21:02 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id E4F5464ACA for ; Tue, 22 Nov 2011 13:20:57 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id 36B9580042 for ; Tue, 22 Nov 2011 13:20:57 +0000 (UTC) From: "Anthony G. Basile" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Anthony G. Basile" Message-ID: Subject: [gentoo-commits] proj/hardened-dev:XT_PAX commit in: app-arch/tar/files/, app-arch/tar/ X-VCS-Repository: proj/hardened-dev X-VCS-Files: app-arch/tar/ChangeLog app-arch/tar/files/rmt app-arch/tar/files/tar-1.26-full-xattr.patch app-arch/tar/files/tar.1 app-arch/tar/metadata.xml app-arch/tar/tar-1.26-r3.ebuild X-VCS-Directories: app-arch/tar/files/ app-arch/tar/ X-VCS-Committer: blueness X-VCS-Committer-Name: Anthony G. Basile X-VCS-Revision: b639501a7d8b787fa8aded342101f259bcbb3a25 Date: Tue, 22 Nov 2011 13:20:57 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 17ca8020-510d-4774-b079-6d845c2504b4 X-Archives-Hash: bf7f535fa27c3e6816d9ff25af53666f commit: b639501a7d8b787fa8aded342101f259bcbb3a25 Author: Anthony G. Basile gentoo org> AuthorDate: Tue Nov 22 13:20:48 2011 +0000 Commit: Anthony G. Basile gentoo org> CommitDate: Tue Nov 22 13:20:48 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/hardened-dev.= git;a=3Dcommit;h=3Db639501a app-arch/tar: added xattr aware tar (Portage version: 2.1.10.11/git/Linux x86_64, signed Manifest commit with= key 0xD0455535) --- app-arch/tar/ChangeLog | 24 + app-arch/tar/files/rmt | 8 + app-arch/tar/files/tar-1.26-full-xattr.patch | 953 ++++++++++++++++++++= ++++++ app-arch/tar/files/tar.1 | 816 ++++++++++++++++++++= ++ app-arch/tar/metadata.xml | 5 + app-arch/tar/tar-1.26-r3.ebuild | 78 +++ 6 files changed, 1884 insertions(+), 0 deletions(-) diff --git a/app-arch/tar/ChangeLog b/app-arch/tar/ChangeLog new file mode 100644 index 0000000..1106a6b --- /dev/null +++ b/app-arch/tar/ChangeLog @@ -0,0 +1,24 @@ + + +*tar-1.26-r3 (24 Sep 2011) + + 24 Sep 2011; Anthony G. Basile -tar-1.26-r2.ebui= ld, + +tar-1.26-r3.ebuild, +files/tar-1.26-full-xattr.patch, + -files/tar-1.26-xattr.patch: + Added USE=3D"acl caps selinux xattr" flags which --enable-xattr + +*tar-1.26-r2 (24 Sep 2011) + + 24 Sep 2011; Anthony G. Basile -tar-1.26-r1.ebui= ld, + +tar-1.26-r2.ebuild, files/tar-1.26-xattr.patch: + Switching to USE=3D"xattr" for xattr only patch - bug #382067 + + 10 Sep 2011; Anthony G. Basile tar-1.26-r1.ebuil= d: + Switching to USE=3D"selinux" + +*tar-1.26 (10 Sep 2011) + + 10 Sep 2011; Anthony G. Basile +tar-1.26-r1.ebui= ld, + +files/tar-1.26-xattrs.patch, +files/rmt, +files/tar.1: + Testing for bug #382067 + diff --git a/app-arch/tar/files/rmt b/app-arch/tar/files/rmt new file mode 100644 index 0000000..15ed6aa --- /dev/null +++ b/app-arch/tar/files/rmt @@ -0,0 +1,8 @@ +#!/bin/sh +# +# This is not a mistake. This shell script (/etc/rmt) has been provided +# for compatibility with other Unix-like systems, some of which have +# utilities that expect to find (and execute) rmt in the /etc directory +# on remote systems. +# +exec rmt "$@" diff --git a/app-arch/tar/files/tar-1.26-full-xattr.patch b/app-arch/tar/= files/tar-1.26-full-xattr.patch new file mode 100644 index 0000000..7a5c7f8 --- /dev/null +++ b/app-arch/tar/files/tar-1.26-full-xattr.patch @@ -0,0 +1,953 @@ +diff --git a/configure.ac b/configure.ac +index db69cb8..2afa463 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -223,6 +223,20 @@ AC_CHECK_TYPE(iconv_t,:, + #endif + ]) +=20 ++AC_ARG_ENABLE(xattr, ++ AC_HELP_STRING([--enable-xattr], ++ [enable Extended Attribute support (disabled by default)]), ++ [xattr_enabled=3D$enableval], ++ [xattr_enabled=3Dno]) ++ ++if test "x$xattr_enabled" =3D xyes; then ++ AC_CHECK_HEADERS(attr/xattr.h) ++ AC_CHECK_FUNCS(getxattr fgetxattr lgetxattr \ ++ setxattr fsetxattr lsetxattr \ ++ listxattr flistxattr llistxattr, ++ AC_DEFINE(HAVE_XATTRS,1,[Define if we have a working e= xtended attributes]),) ++fi ++ + # 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 db8f986..d861d12 100644 +--- a/doc/tar.texi ++++ b/doc/tar.texi +@@ -3002,6 +3002,10 @@ mechanism. + Treat all input file or member names literally, do not interpret + escape sequences. @xref{input name quoting}. +=20 ++@opsummary{no-xattrs} ++@item --no-xattrs ++Causes @command{tar} not to store and not to extract xattrs. @xref{Att= ributes}. ++ + @opsummary{no-wildcards} + @item --no-wildcards + Do not use wildcards. +@@ -3447,6 +3451,10 @@ Enable or disable warning messages identified by = @var{keyword}. The + messages are suppressed if @var{keyword} is prefixed with @samp{no-}. + @xref{warnings}. +=20 ++@opsummary{xattrs} ++@item --xattrs ++Causes @command{tar} to store xattrs. @xref{Attributes}. ++ + @opsummary{wildcards} + @item --wildcards + Use wildcards when matching member names with patterns. +@@ -8659,6 +8667,8 @@ implementation able to read @samp{ustar} archives = will be able to read + 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= . ++This is the only format that can store ACLs, SELinux context and extend= ed ++attributes. +=20 + This archive format will be the default format for future versions + of @GNUTAR{}. +@@ -9293,6 +9303,20 @@ Same as both @option{--same-permissions} and @opt= ion{--same-order}. +=20 + This option is deprecated, and will be removed in @GNUTAR{} version 1.2= 3. +=20 ++@opindex xattrs ++@item --xattrs ++This option causes @command{tar} to store the current extended attribut= es in ++the archive. ++ ++The @option{--xattrs} option has no equivalent short option name. ++ ++@opindex no-xattrs ++@item --no-xattrs ++This option causes @command{tar} not to store the current extended attr= ibutes in ++the archive and not to extract any extended attributes in an archive. ++ ++The @option{--no-xattrs} option has no equivalent short option name. ++ + @end table +=20 + @node Portability +diff --git a/src/Makefile.am b/src/Makefile.am +index de310f4..27c28be 100644 +--- a/src/Makefile.am ++++ b/src/Makefile.am +@@ -20,7 +20,7 @@ +=20 + bin_PROGRAMS =3D tar +=20 +-noinst_HEADERS =3D arith.h common.h tar.h ++noinst_HEADERS =3D arith.h common.h tar.h xattrs.h + tar_SOURCES =3D \ + buffer.c\ + checkpoint.c\ +@@ -42,10 +42,11 @@ tar_SOURCES =3D \ + unlink.c\ + update.c\ + utf8.c\ +- warning.c ++ warning.c\ ++ xattrs.c +=20 + INCLUDES =3D -I$(top_srcdir)/gnu -I../ -I../gnu -I$(top_srcdir)/lib -I.= ./lib +=20 + LDADD =3D ../lib/libtar.a ../gnu/libgnu.a $(LIBINTL) $(LIBICONV) +=20 +-tar_LDADD =3D $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_EACCESS) ++tar_LDADD =3D $(LIBS) $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_EACCESS) +diff --git a/src/common.h b/src/common.h +index 0b9bd7a..e4ee345 100644 +--- a/src/common.h ++++ b/src/common.h +@@ -253,6 +253,9 @@ GLOBAL int same_owner_option; + /* If positive, preserve permissions when extracting. */ + GLOBAL int same_permissions_option; +=20 ++/* If positive, save the user and root xattrs. */ ++GLOBAL int xattrs_option; ++ + /* When set, strip the given number of file name components from the fi= le name + before extracting */ + GLOBAL size_t strip_name_components; +@@ -707,6 +710,9 @@ extern char *output_start; +=20 + void update_archive (void); +=20 ++/* Module attrs.c. */ ++#include "xattrs.h" ++ + /* Module xheader.c. */ +=20 + void xheader_decode (struct tar_stat_info *stat); +@@ -727,6 +733,12 @@ bool xheader_string_end (struct xheader *xhdr, char= const *keyword); + bool xheader_keyword_deleted_p (const char *kw); + char *xheader_format_name (struct tar_stat_info *st, const char *fmt, + size_t n); ++void xheader_xattr_init(struct tar_stat_info *st); ++void xheader_xattr_free(struct xattr_array *vals, size_t sz); ++void xheader_xattr_copy(const struct tar_stat_info *st, ++ struct xattr_array **vals, size_t *sz); ++void xheader_xattr_add(struct tar_stat_info *st, ++ const char *key, const char *val, size_t len); +=20 + /* Module system.c */ +=20 +diff --git a/src/create.c b/src/create.c +index 43b5a4c..7ed5d10 100644 +--- a/src/create.c ++++ b/src/create.c +@@ -936,6 +936,21 @@ start_header (struct tar_stat_info *st) + GNAME_TO_CHARS (st->gname, header->header.gname); + } +=20 ++ if (archive_format =3D=3D POSIX_FORMAT) ++ { ++ if (xattrs_option > 0) ++ { ++ size_t scan_xattr =3D 0; ++ struct xattr_array *xattr_map =3D st->xattr_map; ++ ++ while (scan_xattr < st->xattr_map_size) ++ { ++ xheader_store (xattr_map[scan_xattr].xkey, st, &scan_xatt= r); ++ ++scan_xattr; ++ } ++ } ++ } ++ + return header; + } +=20 +@@ -1711,6 +1726,11 @@ dump_file0 (struct tar_stat_info *st, char const = *name, char const *p) + bool ok; + struct stat final_stat; +=20 ++ if (fd =3D=3D 0) ++ xattrs_xattrs_get(st, p, -1); ++ else ++ xattrs_xattrs_get(st, p, fd); ++ + if (is_dir) + { + const char *tag_file_name; +@@ -1829,6 +1849,8 @@ dump_file0 (struct tar_stat_info *st, char const *= name, char const *p) + if (NAME_FIELD_SIZE - (archive_format =3D=3D OLDGNU_FORMAT) < siz= e) + write_long_link (st); +=20 ++ xattrs_xattrs_get(st, p, -1); ++ + block_ordinal =3D current_block_ordinal (); + st->stat.st_size =3D 0; /* force 0 size on symlink */ + header =3D start_header (st); +@@ -1847,11 +1869,20 @@ dump_file0 (struct tar_stat_info *st, char const= *name, char const *p) + } + #endif + else if (S_ISCHR (st->stat.st_mode)) +- type =3D CHRTYPE; ++ { ++ type =3D CHRTYPE; ++ xattrs_xattrs_get(st, p, -1); ++ } + else if (S_ISBLK (st->stat.st_mode)) +- type =3D BLKTYPE; ++ { ++ type =3D BLKTYPE; ++ xattrs_xattrs_get(st, p, -1); ++ } + else if (S_ISFIFO (st->stat.st_mode)) +- type =3D FIFOTYPE; ++ { ++ type =3D FIFOTYPE; ++ xattrs_xattrs_get(st, p, -1); ++ } + else if (S_ISSOCK (st->stat.st_mode)) + { + WARNOPT (WARN_FILE_IGNORED, +diff --git a/src/extract.c b/src/extract.c +index aaea56e..5c0a9c9 100644 +--- a/src/extract.c ++++ b/src/extract.c +@@ -97,6 +97,9 @@ struct delayed_set_stat + /* Directory that the name is relative to. */ + int change_dir; +=20 ++ /* extended attributes*/ ++ size_t xattr_map_size; /* Size of the xattr map */ ++ struct xattr_array *xattr_map; + /* Length and contents of name. */ + size_t file_name_len; + char file_name[1]; +@@ -134,6 +137,9 @@ struct delayed_link + hard-linked together. */ + struct string_list *sources; +=20 ++ 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]; + }; +@@ -335,6 +341,8 @@ set_stat (char const *file_name, + utime_error (file_name); + } +=20 ++ xattrs_xattrs_set(st, file_name, typeflag); ++ + if (0 < same_owner_option && ! interdir) + { + /* Some systems allow non-root users to give files away. Once th= is +@@ -431,6 +439,13 @@ delay_set_stat (char const *file_name, struct tar_s= tat_info const *st, + data->atflag =3D atflag; + data->after_links =3D 0; + data->change_dir =3D chdir_current; ++ if (st) ++ xheader_xattr_copy (st, &data->xattr_map, &data->xattr_map_size); ++ else ++ { ++ data->xattr_map =3D NULL; ++ data->xattr_map_size =3D 0; ++ } + strcpy (data->file_name, file_name); + delayed_set_stat_head =3D data; + if (must_be_dot_or_slash (file_name)) +@@ -673,6 +688,31 @@ maybe_recoverable (char *file_name, bool regular, b= ool *interdir_made) + return RECOVER_NO; + } +=20 ++/* Restore stat extended attributes (xattr) for FILE_NAME, using inform= ation ++ given in *ST. Restore before extraction because they may affect lay= out. ++ If not restoring permissions, invert the ++ INVERT_PERMISSIONS bits from the file's current permissions. ++ TYPEFLAG specifies the type of the file. ++ FILE_CREATED indicates set_xattr has created the file */ ++static int ++set_xattr (char const *file_name, struct tar_stat_info const *st, ++ mode_t invert_permissions, char typeflag, int *file_created) ++{ ++ int status =3D 0; ++ bool interdir_made =3D false; ++ ++ if ((xattrs_option >=3D 0) && st->xattr_map_size) { ++ mode_t mode =3D current_stat_info.stat.st_mode & MODE_RWX & ~ curre= nt_umask; ++ ++ do ++ status =3D mknod (file_name, mode ^ invert_permissions, 0); ++ while (status && maybe_recoverable ((char *)file_name, false, &inte= rdir_made)); ++ xattrs_xattrs_set(st, file_name, typeflag); ++ *file_created =3D 1; ++ } ++ return(status); ++} ++ + /* 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 +@@ -733,12 +773,15 @@ apply_nonancestor_delayed_set_stat (char const *fi= le_name, bool after_links) + sb.stat.st_gid =3D data->gid; + sb.atime =3D data->atime; + sb.mtime =3D data->mtime; ++ sb.xattr_map =3D data->xattr_map; ++ sb.xattr_map_size =3D data->xattr_map_size; + set_stat (data->file_name, &sb, + -1, current_mode, current_mode_mask, + DIRTYPE, data->interdir, data->atflag); + } +=20 + delayed_set_stat_head =3D data->next; ++ xheader_xattr_free (data->xattr_map, data->xattr_map_size); + free (data); + } + } +@@ -854,6 +897,7 @@ extract_dir (char *file_name, int typeflag) +=20 + static int + open_output_file (char const *file_name, int typeflag, mode_t mode, ++ int file_created, + mode_t *current_mode, mode_t *current_mode_mask) + { + int fd; +@@ -864,6 +908,10 @@ open_output_file (char const *file_name, int typefl= ag, mode_t mode, + ? O_TRUNC | (dereference_option ? 0 : O_NOFOLLOW) + : O_EXCL)); +=20 ++ /* File might be created in set_xattr. So clear O_EXCL to avoid open(= ) failure */ ++ if (file_created) ++ openflag =3D openflag & ~O_EXCL; ++ + if (typeflag =3D=3D CONTTYPE) + { + static int conttype_diagnosed; +@@ -934,6 +982,7 @@ extract_file (char *file_name, int typeflag) + bool interdir_made =3D false; + mode_t mode =3D (current_stat_info.stat.st_mode & MODE_RWX + & ~ (0 < same_owner_option ? S_IRWXG | S_IRWXO : 0)); ++ mode_t invert_permissions =3D 0 < same_owner_option ? mode & (S_IRWXG= | S_IRWXO) : 0; + mode_t current_mode =3D 0; + mode_t current_mode_mask =3D 0; +=20 +@@ -950,7 +999,17 @@ extract_file (char *file_name, int typeflag) + } + else + { ++ int file_created =3D 0; ++ if (set_xattr (file_name, ¤t_stat_info, invert_permissions, ++ typeflag, &file_created)) ++ { ++ skip_member (); ++ open_error (file_name); ++ return 1; ++ } ++ + while ((fd =3D open_output_file (file_name, typeflag, mode, ++ file_created, + ¤t_mode, ¤t_mode_mask)) + < 0) + { +@@ -1091,6 +1150,7 @@ create_placeholder_file (char *file_name, bool is_= symlink, bool *interdir_made) + + strlen (file_name) + 1); + p->sources->next =3D 0; + strcpy (p->sources->string, file_name); ++ xheader_xattr_copy (¤t_stat_info, &p->xattr_map, &p->xattr_= map_size); + strcpy (p->target, current_stat_info.link_name); +=20 + h =3D delayed_set_stat_head; +@@ -1525,6 +1585,8 @@ apply_delayed_links (void) + st1.stat.st_gid =3D ds->gid; + st1.atime =3D ds->atime; + st1.mtime =3D ds->mtime; ++ st1.xattr_map =3D ds->xattr_map; ++ st1.xattr_map_size =3D ds->xattr_map_size; + set_stat (source, &st1, -1, 0, 0, SYMTYPE, + false, AT_SYMLINK_NOFOLLOW); + valid_source =3D source; +@@ -1539,6 +1601,8 @@ apply_delayed_links (void) + sources =3D next; + } +=20 ++ xheader_xattr_free (ds->xattr_map, ds->xattr_map_size); ++ + { + struct delayed_link *next =3D ds->next; + free (ds); +diff --git a/src/list.c b/src/list.c +index cf2de09..6f52579 100644 +--- a/src/list.c ++++ b/src/list.c +@@ -604,6 +604,8 @@ decode_header (union block *header, struct tar_stat_= info *stat_info, + assign_string (&stat_info->gname, + header->header.gname[0] ? header->header.gname : NULL); +=20 ++ xheader_xattr_init(stat_info); ++ + if (format =3D=3D OLDGNU_FORMAT && incremental_option) + { + stat_info->atime.tv_sec =3D TIME_FROM_HEADER (header->oldgnu_head= er.atime); +diff --git a/src/tar.c b/src/tar.c +index 928cfdd..75510d8 100644 +--- a/src/tar.c ++++ b/src/tar.c +@@ -304,6 +304,7 @@ enum + NO_UNQUOTE_OPTION, + NO_WILDCARDS_MATCH_SLASH_OPTION, + NO_WILDCARDS_OPTION, ++ NO_XATTR_OPTION, + NULL_OPTION, + NUMERIC_OWNER_OPTION, + OCCURRENCE_OPTION, +@@ -340,7 +341,8 @@ enum + VOLNO_FILE_OPTION, + WARNING_OPTION, + WILDCARDS_MATCH_SLASH_OPTION, +- WILDCARDS_OPTION ++ WILDCARDS_OPTION, ++ XATTR_OPTION + }; +=20 + const char *argp_program_version =3D "tar (" PACKAGE_NAME ") " VERSION; +@@ -516,6 +518,10 @@ static struct argp_option options[] =3D { + {"preserve-order", 's', 0, 0, + N_("sort names to extract to match archive"), GRID+1 }, + {"same-order", 0, 0, OPTION_ALIAS, NULL, 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, +@@ -2079,6 +2085,15 @@ parse_opt (int key, char *arg, struct argp_state = *state) + same_permissions_option =3D -1; + break; +=20 ++ case XATTR_OPTION: ++ set_archive_format ("posix"); ++ xattrs_option =3D 1; ++ break; ++ ++ case NO_XATTR_OPTION: ++ xattrs_option =3D -1; ++ break; ++ + case RECURSION_OPTION: + recursion_option =3D FNM_LEADING_DIR; + break; +@@ -2461,6 +2476,15 @@ decode_options (int argc, char **argv) + || subcommand_option !=3D LIST_SUBCOMMAND)) + USAGE_ERROR ((0, 0, _("--pax-option can be used only on POSIX archi= ves"))); +=20 ++ /* star create's non-POSIX typed archives with xattr support, so allo= w the ++ extra headers */ ++ if ((xattrs_option > 0) ++ && archive_format !=3D POSIX_FORMAT ++ && (subcommand_option !=3D EXTRACT_SUBCOMMAND ++ || subcommand_option !=3D DIFF_SUBCOMMAND ++ || subcommand_option !=3D 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 =3D UNLINK_FIRST_OLD_FILES; +@@ -2713,6 +2737,7 @@ void + tar_stat_destroy (struct tar_stat_info *st) + { + tar_stat_close (st); ++ xheader_xattr_free (st->xattr_map, st->xattr_map_size); + free (st->orig_file_name); + free (st->file_name); + free (st->link_name); +diff --git a/src/tar.h b/src/tar.h +index ce9850c..955b18e 100644 +--- a/src/tar.h ++++ b/src/tar.h +@@ -276,6 +276,14 @@ struct xheader + uintmax_t string_length; + }; +=20 ++/* 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 heade= r */ +@@ -287,6 +295,7 @@ struct tar_stat_info +=20 + char *uname; /* user name of owner */ + char *gname; /* group name of owner */ ++ + struct stat stat; /* regular filesystem stat */ +=20 + /* STAT doesn't always have access, data modification, and status +@@ -309,6 +318,9 @@ struct tar_stat_info + size_t sparse_map_size; /* Size of the sparse map */ + struct sp_array *sparse_map; +=20 ++ size_t xattr_map_size; /* Size of the xattr map */ ++ struct xattr_array *xattr_map; ++ + /* Extended headers */ + struct xheader xhdr; +=20 +diff --git a/src/xattrs.c b/src/xattrs.c +new file mode 100644 +index 0000000..6a9950e +--- /dev/null ++++ b/src/xattrs.c +@@ -0,0 +1,181 @@ ++/* Create a tar archive. ++ ++ Copyright (C) 2006 Free Software Foundation, Inc. ++ ++ Written by James Antill, on 2006-07-27. ++ ++ 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 th= e ++ Free Software Foundation; either version 2, or (at your option) any = later ++ version. ++ ++ This program is distributed in the hope that it will be useful, but ++ WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Ge= neral ++ Public License for more details. ++ ++ You should have received a copy of the GNU General Public License al= ong ++ with this program; if not, write to the Free Software Foundation, In= c., ++ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ ++ ++#include ++ ++#include ++ ++#include "common.h" ++ ++ ++#ifndef HAVE_ATTR_XATTR_H ++# undef HAVE_XATTRS ++#endif ++ ++#ifdef HAVE_ATTR_XATTR_H ++# include ++#endif ++ ++ ++void xattrs_xattrs_get(struct tar_stat_info *st, char const *file_name,= int fd) ++{ ++ if (xattrs_option > 0) ++ { /* get all xattrs ... this include security.* and system.* if ++ available. We filter them here, but we have to filter them ++ in xattrs_xattrs_set() anyway. ++ */ ++ static ssize_t xsz =3D 1024; ++ static char *xatrs =3D NULL; ++ ssize_t xret =3D -1; ++ ++#ifndef HAVE_XATTRS ++ static int done =3D 0; ++ if ((xattrs_option > 0) && !done) ++ WARN ((0, 0, _("Xattr support requested, but not available"))= ); ++ done =3D 1; ++#else ++ ++ if (!xatrs) xatrs =3D xmalloc (xsz); ++ ++ while (((fd =3D=3D -1) ? ++ ((xret =3D llistxattr (file_name, xatrs, xsz)) =3D=3D -1)= : ++ ((xret =3D flistxattr (fd, xatrs, xsz)) =3D=3D -1)) && ++ (errno =3D=3D ERANGE)) ++ { ++ xsz <<=3D 1; ++ xatrs =3D xrealloc (xatrs, xsz); ++ } ++ ++ if (xret =3D=3D -1) ++ call_arg_warn ((fd =3D=3D -1) ? "llistxattrs" : "flistxattrs", = file_name); ++ else ++ { ++ const char *attr =3D xatrs; ++ static ssize_t asz =3D 1024; ++ static char *val =3D NULL; ++ ++ if (!val) val =3D xmalloc (asz); ++ ++ while (xret > 0) ++ { ++ size_t len =3D strlen (attr); ++ ssize_t aret =3D 0; ++ ++ /* Archive all xattrs during creation, decide at extracti= on time ++ * which ones are of interest/use for the target filesyst= em. */ ++ while (((fd =3D=3D -1) ? ++ ((aret =3D lgetxattr (file_name, attr, val, asz))= =3D=3D -1) : ++ ((aret =3D fgetxattr (fd, attr, val, asz)) =3D=3D= -1)) && ++ (errno =3D=3D ERANGE)) ++ { ++ asz <<=3D 1; ++ val =3D xrealloc (val, asz); ++ } ++ ++ if (aret !=3D -1) ++ xheader_xattr_add (st, attr, val, aret); ++ else if (errno !=3D ENOATTR) ++ call_arg_warn ((fd=3D=3D-1) ? "lgetxattr" : "fgetxattr"= , file_name); ++ ++ attr +=3D len + 1; ++ xret -=3D len + 1; ++ } ++ } ++#endif ++ } ++} ++ ++static void xattrs__fd_set(struct tar_stat_info const *st, ++ char const *file_name, char typeflag, ++ const char *attr, ++ const char *ptr, size_t len) ++{ ++#ifdef HAVE_XATTRS ++ if (ptr) ++ { ++ const char *sysname =3D "setxattr"; ++ int ret =3D -1; ++ ++ if (typeflag !=3D SYMTYPE) ++ ret =3D setxattr (file_name, attr, ptr, len, 0); ++ else ++ { ++ sysname =3D "lsetxattr"; ++ ret =3D lsetxattr (file_name, attr, ptr, len, 0); ++ } ++ ++ /* do not print warnings when SELinux is disabled */ ++ if ((ret =3D=3D -1) && (errno !=3D EPERM) && (errno !=3D ENOTSUP)= ) ++ call_arg_error(sysname, file_name); ++ } ++#endif ++} ++ ++static char *skip_to_ext_fields(char *ptr) ++{ ++ ptr +=3D strcspn(ptr, ":,\n"); /* skip tag name. Ie. user/group/defau= lt/mask */ ++ ++ if (*ptr !=3D ':') ++ return (ptr); /* error? no user/group field */ ++ ++ptr; ++ ++ ptr +=3D strcspn(ptr, ":,\n"); /* skip user/group name */ ++ ++ if (*ptr !=3D ':') ++ return (ptr); /* error? no perms field */ ++ ++ptr; ++ ++ ptr +=3D strcspn(ptr, ":,\n"); /* skip perms */ ++ ++ if (*ptr !=3D ':') ++ return (ptr); /* no extra fields */ ++ ++ return (ptr); ++} ++ ++void xattrs_xattrs_set(struct tar_stat_info const *st, ++ char const *file_name, char typeflag) ++{ ++ if ((xattrs_option >=3D 0) && st->xattr_map_size) ++ { ++ size_t scan =3D 0; ++ ++#ifndef HAVE_XATTRS ++ static int done =3D 0; ++ if (!done) ++ WARN ((0, 0, _("Xattr support requested, but not available"))= ); ++ done =3D 1; ++#else ++ while (scan < st->xattr_map_size) ++ { ++ char *keyword =3D st->xattr_map[scan].xkey; ++ ++ /* assert (!memcpy (keyword, "SCHILY.xattr.", strlen("SCHILY.= xattr."))); */ ++ keyword +=3D strlen("SCHILY.xattr."); ++ ++ xattrs__fd_set (st, file_name, typeflag, keyword, ++ st->xattr_map[scan].xval_ptr, ++ st->xattr_map[scan].xval_len); ++ ++ ++scan; ++ } ++#endif ++ } ++} +diff --git a/src/xattrs.h b/src/xattrs.h +new file mode 100644 +index 0000000..7ffdce1 +--- /dev/null ++++ b/src/xattrs.h +@@ -0,0 +1,6 @@ ++ ++extern void xattrs_xattrs_get(struct tar_stat_info *st, ++ char const *file_name, int fd); ++ ++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 2284e97..557b3e5 100644 +--- a/src/xheader.c ++++ b/src/xheader.c +@@ -460,6 +460,74 @@ xheader_write_global (struct xheader *xhdr) + } + } +=20 ++void xheader_xattr_init(struct tar_stat_info *st) ++{ ++ st->xattr_map =3D NULL; ++ st->xattr_map_size =3D 0; ++} ++ ++void xheader_xattr_free(struct xattr_array *xattr_map, size_t xattr_map= _size) ++{ ++ size_t scan =3D 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 =3D (*xattr_map_size)++; ++ ++ *xattr_map =3D xrealloc (*xattr_map, ++ *xattr_map_size * sizeof(struct xattr_array)); ++ (*xattr_map)[pos].xkey =3D xstrdup (key); ++ (*xattr_map)[pos].xval_ptr =3D xmemdup (val, len + 1); ++ (*xattr_map)[pos].xval_len =3D len; ++} ++ ++void xheader_xattr_add(struct tar_stat_info *st, ++ const char *key, const char *val, size_t len) ++{ ++ size_t klen =3D strlen (key); ++ char *xkey =3D xmalloc (strlen("SCHILY.xattr.") + klen + 1); ++ char *tmp =3D xkey; ++ ++ tmp =3D stpcpy (tmp, "SCHILY.xattr."); ++ tmp =3D stpcpy (tmp, key); ++ ++ xheader_xattr__add (&st->xattr_map, &st->xattr_map_size, xkey, val, l= en); ++ ++ free (xkey); ++} ++ ++void xheader_xattr_copy(const struct tar_stat_info *st, ++ struct xattr_array **xattr_map, size_t *xattr_m= ap_size) ++{ ++ size_t scan =3D 0; ++ ++ *xattr_map =3D NULL; ++ *xattr_map_size =3D 0; ++ ++ while (scan < st->xattr_map_size) ++ { ++ char *key =3D st->xattr_map[scan].xkey; ++ char *val =3D st->xattr_map[scan].xval_ptr; ++ size_t len =3D st->xattr_map[scan].xval_len; ++ ++ xheader_xattr__add(xattr_map, xattr_map_size, key, val, len); ++ ++ ++scan; ++ } ++} ++ + =0C + /* General Interface */ +=20 +@@ -473,6 +541,7 @@ struct xhdr_tab + struct xheader *, void const *data); + void (*decoder) (struct tar_stat_info *, char const *, char const *, = size_t); + int flags; ++ bool prefix; + }; +=20 + /* This declaration must be extern, because ISO C99 section 6.9.2 +@@ -489,8 +558,17 @@ locate_handler (char const *keyword) + struct xhdr_tab const *p; +=20 + for (p =3D xhdr_tab; p->keyword; p++) +- if (strcmp (p->keyword, keyword) =3D=3D 0) +- return p; ++ if (p->prefix) ++ { ++ if (strncmp (p->keyword, keyword, strlen(p->keyword)) =3D=3D 0) ++ return p; ++ } ++ else ++ { ++ if (strcmp (p->keyword, keyword) =3D=3D 0) ++ return p; ++ } ++ + return NULL; + } +=20 +@@ -500,7 +578,7 @@ xheader_protected_pattern_p (const char *pattern) + struct xhdr_tab const *p; +=20 + for (p =3D xhdr_tab; p->keyword; p++) +- if ((p->flags & XHDR_PROTECTED) && fnmatch (pattern, p->keyword, 0)= =3D=3D 0) ++ if (!p->prefix && (p->flags & XHDR_PROTECTED) && fnmatch (pattern, = p->keyword, 0) =3D=3D 0) + return true; + return false; + } +@@ -511,7 +589,7 @@ xheader_protected_keyword_p (const char *keyword) + struct xhdr_tab const *p; +=20 + for (p =3D xhdr_tab; p->keyword; p++) +- if ((p->flags & XHDR_PROTECTED) && strcmp (p->keyword, keyword) =3D= =3D 0) ++ if (!p->prefix && (p->flags & XHDR_PROTECTED) && strcmp (p->keyword= , keyword) =3D=3D 0) + return true; + return false; + } +@@ -1470,6 +1548,27 @@ volume_filename_decoder (struct tar_stat_info *st= , + } +=20 + static void ++xattr_coder (struct tar_stat_info const *st , char const *keyword, ++ struct xheader *xhdr, void const *data) ++{ ++ struct xattr_array *xattr_map =3D st->xattr_map; ++ const size_t *off =3D 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 =3D NULL; ++ ++ xstr =3D 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) + { +@@ -1506,53 +1605,53 @@ sparse_minor_decoder (struct tar_stat_info *st, + } +=20 + struct xhdr_tab const xhdr_tab[] =3D { +- { "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 }, +=20 + /* Sparse file handling */ + { "GNU.sparse.name", path_coder, path_decoder, +- 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_d= ecoder, +- XHDR_PROTECTED }, ++ XHDR_PROTECTED, false }, +=20 + /* tar 1.14 - 1.15.90 keywords. */ + { "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 i= n 'x' + headers, and each of them was meaningful. It confilcted with POSIX= specs, + which requires that "when extended header records conflict, the la= st one + given in the header shall take precedence." */ + { "GNU.sparse.offset", sparse_offset_coder, sparse_offset_decoder= , +- XHDR_PROTECTED }, ++ XHDR_PROTECTED, false }, + { "GNU.sparse.numbytes", sparse_numbytes_coder, sparse_numbytes_dec= oder, +- XHDR_PROTECTED }, ++ XHDR_PROTECTED, false }, + /* tar 1.15.90 keyword, introduced to remove the above-mentioned conf= lict. */ + { "GNU.sparse.map", NULL /* Unused, see pax_dump_header() */, +- sparse_map_decoder, 0 }, ++ sparse_map_decoder, 0, false }, +=20 + { "GNU.dumpdir", dumpdir_coder, dumpdir_decoder, +- XHDR_PROTECTED }, ++ XHDR_PROTECTED, false }, +=20 + /* Keeps the tape/volume label. May be present only in the global hea= ders. + Equivalent to GNUTYPE_VOLHDR. */ + { "GNU.volume.label", volume_label_coder, volume_label_decoder, +- XHDR_PROTECTED | XHDR_GLOBAL }, ++ XHDR_PROTECTED | XHDR_GLOBAL, false }, +=20 + /* These may be present in a first global header of the archive. + They provide the same functionality as GNUTYPE_MULTIVOL header. +@@ -1561,11 +1660,14 @@ struct xhdr_tab const xhdr_tab[] =3D { + 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, +- 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 }, ++ ++ /* xattrs use the star format. note we only save some variants... */ ++ { "SCHILY.xattr", xattr_coder, xattr_decoder, 0, true }, +=20 +- { NULL, NULL, NULL, 0 } ++ { NULL, NULL, NULL, 0, false } + }; diff --git a/app-arch/tar/files/tar.1 b/app-arch/tar/files/tar.1 new file mode 100644 index 0000000..42fd22f --- /dev/null +++ b/app-arch/tar/files/tar.1 @@ -0,0 +1,816 @@ +.TH TAR 1 "Mar 2010" "GNU" "tar" +.SH NAME +tar \- The GNU version of the tape archiver (tar) utility +.SH SYNOPSIS +.B tar +.I [options] + +.I Operations: +.nf +.B [-]A --catenate --concatenate +.B [-]c --create +.B [-]d --diff --compare +.B [-]r --append +.B [-]t --list +.B [-]u --update +.B [-]x --extract --get +.B --delete +.fi + +.I Common Options: +.nf +.BR -C ", " --directory " DIR" +.BR -f ", " --file " FILE" +.BR -j ", " --bzip2 +.BR -J ", " --xz +.BR -p ", " --preserve-permissions +.BR -v ", " --verbose +.BR -z ", " --gzip +.fi + +.I All Options: +.br +[ +.BR -a ", " --auto-compress +] +[ +.BR --add-file " FILE" +] +[ +.BR --anchored +] +[ +.BR --atime-preserve +] +[ +.BR -b ", " --blocking-factor " N" +] +[ +.BR -B ", " --read-full-records +] +[ +.BR --backup " BACKUP-TYPE" +] +[ +.BR --block-compress +] +[ +.BR -C ", " --directory " DIR" +] +[ +.BR --checkpoint +] +[ +.BR --delay-directory-restore +] +[ +.BR --exclude " PATTERN" +] +[ +.BR --exclude-caches +] +[ +.BR --exclude-caches-all +] +[ +.BR --exclude-caches-under +] +[ +.BR --exclude-tag " FILE" +] +[ +.BR --exclude-tag-all " FILE" +] +[ +.BR --exclude-tag-under " FILE" +] +[ +.BR -f ", " --file " [HOSTNAME:]FILE" +] +[ +.BR -F ", " --info-script " FILE, " --new-volume-script " FILE" +] +[ +.BR --force-local +] +[ +.BR --format " FORMAT" +] +[ +.BR -g ", " --listed-incremental " SNAPSHOT" +] +[ +.BR -G ", " --incremental +] +[ +.BR --group " GROUP" +] +[ +.BR -h ", " --dereference +] +[ +.BR --help +] +[ +.BR -i ", " --ignore-zeros +] +[ +.BR -I ", " --use-compress-program " PROG" +] +[ +.BR --ignore-case +] +[ +.BR --ignore-command-error +] +[ +.BR --ignore-failed-read +] +[ +.BR --index-file " FILE" +] +[ +.BR -j ", " --bzip2 +] +[ +.BR -J ", " --xz +] +[ +.BR -k ", " --keep-old-files +] +[ +.BR -K ", " --starting-file " FILE" +] +[ +.BR --keep-newer-files +] +[ +.BR -l ", " --check-links +] +[ +.BR -L ", " --tape-length " N" +] +[ +.BR --lzip +] +[ +.BR --lzma +] +[ +.BR --lzop +] +[ +.BR -m ", " --touch ", " --modification-time +] +[ +.BR -M ", " --multi-volume +] +[ +.BR --mode " PERMISSIONS" +] +[ +.BR --mtime " DATE" +] +[ +.BR -N ", " --after-date " DATE, " --newer " DATE" +] +[ +.BR --newer-mtime " DATE" +] +[ +.BR --no-anchored +] +[ +.BR --no-auto-compress +] +[ +.BR --no-delay-directory-restore +] +[ +.BR --no-ignore-case +] +[ +.BR --no-ignore-command-error +] +[ +.BR --no-overwrite-dir +] +[ +.BR --no-quote-chars +] +[ +.BR --no-recursion +] +[ +.BR --no-same-permissions +] +[ +.BR --no-unquote +] +[ +.BR --no-wildcards +] +[ +.BR --no-wildcards-match-slash +] +[ +.BR --null +] +[ +.BR --numeric-owner +] +[ +.BR -o ", " --old-archive ", " --portability ", " --no-same-owner +] +[ +.BR -O ", " --to-stdout +] +[ +.BR --occurrence " NUM" +] +[ +.BR --one-file-system +] +[ +.BR --overwrite +] +[ +.BR --overwrite-dir +] +[ +.BR --owner " USER" +] +[ +.BR -p ", " --same-permissions ", " --preserve-permissions +] +[ +.BR -P ", " --absolute-names +] +[ +.BR --pax-option " KEYWORD-LIST" +] +[ +.BR --posix +] +[ +.BR --preserve +] +[ +.BR --quote-chars " STRING" +] +[ +.BR --quote-style " STYLE" +] +[ +.BR -R ", " --block-number +] +[ +.BR --record-size " SIZE" +] +[ +.BR --recursion +] +[ +.BR --recursive-unlink +] +[ +.BR --remove-files +] +[ +.BR --restrict +] +[ +.BR --rmt-command " CMD" +] +[ +.BR --rsh-command " CMD" +] +[ +.BR -s ", " --same-order ", " --preserve-order +] +[ +.BR -S ", " --sparse +] +[ +.BR --same-owner +] +[ +.BR --show-defaults +] +[ +.BR --show-omitted-dirs +] +[ +.BR --show-transformed-names ", " --show-stored-names +] +[ +.BR --strip-components " NUMBER" +] +[ +.BR --suffix " SUFFIX" +] +[ +.BR -T ", " --files-from " FILE" +] +[ +.BR --test-label +] +[ +.BR --to-command " COMMAND" +] +[ +.BR --transform " EXPRESSION" +] +[ +.BR --totals=09 +] +[ +.BR -U ", " --unlink-first +] +[ +.BR --unquote +] +[ +.BR --utc +] +[ +.BR -v ", " --verbose +] +[ +.BR -V ", " --label " NAME" +] +[ +.BR --version=09 +] +[ +.BR --volno-file " FILE" +] +[ +.BR -w ", " --interactive ", " --confirmation +] +[ +.BR -W ", " --verify +] +[ +.BR --wildcards +] +[ +.BR --wildcards-match-slash +] +[ +.BR -X ", " --exclude-from " FILE" +] +[ +.BR -z ", " --gzip ", " --gunzip ", " --ungzip +] +[ +.BR -Z ", " --compress ", " --uncompress +] +[ +.BR -[0-7][lmh] +] +.SH DESCRIPTION +This manual page documents the GNU version of \fBtar\fR, an archiving=20 +program designed to store and extract files from an archive file known=20 +as a \fItarfile\fR. A \fItarfile\fR may be made on a tape drive,=20 +however, it is also common to write a \fItarfile\fR to a normal file. =20 +The first argument to \fBtar\fR must be one of the options \fBAcdrtux\fR= ,=20 +followed by any optional functions. The final arguments to \fBtar\fR=20 +are the names of the files or directories which should be archived. The= =20 +use of a directory name always implies that the subdirectories below=20 +should be included in the archive. +.SH EXAMPLES +.TP +.B tar -xvf foo.tar +verbosely extract foo.tar +.TP +.B tar -xzf foo.tar.gz +extract gzipped foo.tar.gz +.TP +.B tar -cjf foo.tar.bz2 bar/ +create bzipped tar archive of the directory bar called foo.tar.bz2 +.TP +.B tar -xjf foo.tar.bz2 -C bar/ +extract bzipped foo.tar.bz2 after changing directory to bar +.TP +.B tar -xzf foo.tar.gz blah.txt +extract the file blah.txt from foo.tar.gz +.P +Note: When working with archives, specifying the compression option is o= ften +times unnecessary as \fBtar\fR will automatically detect the compression= type +based on the suffix of the archive. +.SH "FUNCTION LETTERS" +.TP +.B One of the following options must be used: +.TP +.BR -A ", " --catenate ", " --concatenate +append tar files to an archive +.TP +.BR -c ", " --create +create a new archive +.TP +.BR -d ", " --diff ", " --compare +find differences between archive and file system +.TP +.BR -r ", " --append +append files to the end of an archive +.TP +.BR -t ", " --list +list the contents of an archive +.TP +.BR -u ", " --update +only append files that are newer than the existing in archive +.TP +.BR -x ", " --extract ", " --get +extract files from an archive +.TP +.BR --delete +delete from the archive (not for use on magnetic tapes!) +.SH "COMMON OPTIONS" +.TP +.BR -C ", " --directory " DIR" +change to directory DIR +.TP +.BR -f ", " --file " [HOSTNAME:]FILE" +use archive file or device FILE (default is "-", meaning stdin/stdout) +.TP +.BR -j ", " --bzip2 +filter archive through bzip2; use to decompress .bz2 files +.TP +.BR -J ", " --xz +filter archive through xz; use to decompress .xz files +.TP +.BR -p ", " --preserve-permissions +extract all protection information +.TP +.BR -v ", " --verbose +verbosely list files processed +.TP +.BR -z ", " --gzip ", " --ungzip +filter the archive through gzip +.SH "ALL OPTIONS" +.TP +.BR -a ", " --auto-compress +use archive suffix to determine the compression program +.TP +.BR --add-file " FILE" +add specified FILE to the archive (useful if FILE starts with a dash) +.TP +.BR --anchored +patterns will match the start of file names +.TP +.BR --atime-preserve +don't change access times of files that are archived +.TP +.BR -b ", " --blocking-factor " N" +block size of Nx512 bytes (default N=3D20) +.TP +.BR -B ", " --read-full-blocks +reblock as we read (for reading 4.2BSD pipes) +.TP +.BR --backup " BACKUP-TYPE" +backup files instead of deleting them using BACKUP-TYPE simple or=20 +numbered +.TP +.BR --block-compress +block the output of compression program for tapes +.TP +.BR -C ", " --directory " DIR" +change to directory DIR +.TP +.BR --checkpoint +print directory names while reading the archive +.TP +.BR --delay-directory-restore +delay setting modification times and permissions of extracted directorie= s +until the end of extraction +.TP +.BR --exclude " PATTERN" +exclude files based upon PATTERN +.TP +.BR --exclude-caches +exclude directories that contain a cache directory tag +.TP +.BR --exclude-tag " FILE" +exclude directories that contain a file named FILE +.TP +.BR -f ", " --file " [HOSTNAME:]FILE" +use archive file or device FILE (default "-", meaning stdin/stdout) +.TP +.BR -F ", " --info-script " FILE, " --new-volume-script " FILE" +run script at end of each tape (implies \fI--multi-volume\fR) +.TP +.BR --force-local +archive file is local even if its name contains a colon +.TP +.BR --format " FORMAT" +selects the format of the created archive +.nf +\fIv7\fR - Unix V7 +\fIoldgnu\fR - GNU tar <=3D1.12 +\fIgnu\fR - GNU tar 1.13 +\fIustar\fR - POSIX.1-1988 +\fIposix\fR - POSIX.1-2001 +.fi +.TP +.BR -g ", " --listed-incremental " SNAPSHOT" +create/list/extract new GNU-format incremental backup +.TP +.BR --group " GROUP" +give files added to the archive a group id of GROUP instead of the group= id +of the source file; this option does not affect extraction +.TP +.BR -G ", " --incremental +create/list/extract old GNU-format incremental backup +.TP +.BR -h ", " --dereference +don't archive symlinks; archive the files they point to +.TP +.BR --help +like this manpage, but not as cool +.TP +.BR -i ", " --ignore-zeros +ignore blocks of zeros in archive (normally mean EOF) +.TP +.BR -I ", " --use-compress-program " PROG" +access the archive through PROG (which is generally a compression progra= m; +it must accept the \fI-d\fR option) +.TP +.BR --ignore-case +ignore case when excluding files +.TP +.BR --ignore-command-error +ignore exit codes of subprocesses +.TP +.BR --ignore-failed-read +don't exit with non-zero status on unreadable files +.TP +.BR --index-file " FILE" +send verbose output to FILE instead of stdout +.TP +.BR -j ", " --bzip2 +filter archive through bzip2, use to decompress .bz2 files +.TP +.BR -J ", " --xz +filter archive through xz; use to decompress .xz files +.TP +.BR -k ", " --keep-old-files +keep existing files; don't overwrite them from archive +.TP +.BR -K ", " --starting-file " FILE" +begin at file FILE in the archive +.TP +.BR --keep-newer-files +do not overwrite files which are newer than the archive +.TP +.BR -l ", " --check-links +warn if number of hard links to the file on the filesystem mismatchs +the number of links recorded in the archive +.TP +.BR -L ", " --tape-length " N" +change tapes after writing N*1024 bytes +.TP +.BR -m ", " --touch ", " --modification-time +don't extract file modified time +.TP +.BR -M ", " --multi-volume +create/list/extract multi-volume archive +.TP +.BR --mode " PERMISSIONS" +apply PERMISSIONS while adding files (see \fBchmod\fR(1)) +.TP +.BR --mtime " DATE" +when creating archives, use DATE as the modification time of the member= s, +instead of their actual modification times +.TP +.BR -N ", " --after-date " DATE, " --newer " DATE" +only store files that were modified or had status updates (permissions, +ACLs, extended attributes, ...) since DATE +.TP +.BR --newer-mtime " DATE" +like \fI--newer\fR, but only store files that were modified since DATE +.TP +.BR --no-anchored +match any subsequenceof the name's components with \fI--exclude\fR +.TP +.BR --no-auto-compress +do not use archive suffix to determine the compression program +.TP +.BR --no-delay-directory-restore +modification times and permissions of extracted directories are set when +all files from this directory have been extracted; this is the default +.TP +.BR --no-ignore-command-error +print warnings about subprocesses that terminated with a non-zero exit c= ode +.TP +.BR --no-ignore-case +use case-sensitive matching with \fI--exclude\fR +.TP +.BR --no-overwrite-dir +preserve metadata of existing directories when extracting files from an +archive +.TP +.BR --no-quote-chars " STRING" +remove characters listed in STRING from the list of quoted characters +set by a previous \fI--quote-chars\fR option +.TP +.BR --no-recursion +don't recurse into directories +.TP +.BR --no-same-permissions +apply user's umask when extracting files instead of recorded permissions +.TP +.BR --no-unquote +treat all input file or member names literally, do not interpret +escape sequences +.TP +.BR --no-wildcards +don't use wildcards with \fI--exclude\fR +.TP +.BR --no-wildcards-match-slash +wildcards do not match slashes (/) with \fI--exclude\fR +.TP +.BR --null +\fI--files-from\fR reads null-terminated names, disable \fI--directory\f= R +.TP +.BR --numeric-owner +always use numbers for user/group names +.TP +.BR -o ", " --old-archive ", " --portability +like \fI--format=3Dv7\fR; \fI-o\fR exhibits this behavior when creating = an=20 +archive (deprecated behavior) +.TP +.BR -o ", " --no-same-owner +do not attempt to restore ownership when extracting; \fI-o\fR exhibits=20 +this behavior when extracting an archive +.TP +.BR -O ", " --to-stdout +extract files to standard output +.TP +.BR --occurrence " NUM" +process only NUM occurrences of each named file; used with=20 +\fI--delete\fR, \fI--diff\fR, \fI--extract\fR, or \fI--list\fR +.TP +.BR --one-file-system +stay in local file system when creating an archive +.TP +.BR --one-file-system +stay in local file system when creating an archive +.TP +.BR --overwrite +overwrite existing files and directory metadata when extracting +.TP +.BR --overwrite-dir +overwrite directory metadata when extracting +.TP +.BR --owner " USER" +give files added to the archive a user id of USER instead of the user id +of the source file; this option does not affect extraction +.TP +.BR -p ", " --preserve-permissions ", " --same-permissions +extract all protection information +.TP +.BR -P ", " --absolute-names +don't strip leading `/'s from file names +.TP +.BR --pax-option " KEYWORD-LIST" +used only with POSIX.1-2001 archives to modify the way \fBtar\fR handles= =20 +extended header keywords +.TP +.BR --posix +like \fI--format=3Dposix\fR +.TP +.BR --preserve +like \fI--preserve-permissions\fR plus \fI--same-order\fR +.TP +.BR --quote-chars " STRING" +always quote the characters from STRING, even if the selected quoting +style would not quote them +.TP +.BR --quote-style " STYLE" +set the quoting style to be used when printing member and file names +.TP +.BR -R ", " --record-number +show record number within archive with each message +.TP +.BR --record-size " SIZE" +use SIZE bytes per record when accessing archives +.TP +.BR --recursion +recurse into directories +.TP +.BR --recursive-unlink +remove existing directories before extracting directories of the same na= me +.TP +.BR --remove-files +remove files after adding them to the archive +.TP +.BR --restrict +disable the use of some potentially harmful options; currently this +disables shell invocation from the multi-volume menu +.TP +.BR --rmt-command " CMD" +use CMD instead of the default /usr/sbin/rmt +.TP +.BR --rsh-command " CMD" +use remote CMD instead of \fBrsh\fR(1) +.TP +.BR -s ", " --same-order ", " --preserve-order +list of names to extract is sorted to match archive +.TP +.BR -S ", " --sparse +handle sparse files efficiently +.TP +.BR --same-owner +create extracted files with the same ownership=20 +.TP +.BR --show-defaults +display the default options used by \fBtar\fR +.TP +.BR --show-omitted-dirs +print directories \fBtar\fR skips while operating on an archive +.TP +.BR --show-transformed-names ", " --show-stored-names +display file or member names after applying any \fBsed\fR transformation= s +.TP +.BR --strip-components " NUMBER" +strip NUMBER of leading path components from file names before extractio= n +.TP +.BR --suffix " SUFFIX" +use SUFFIX instead of default '~' when backing up files +.TP +.BR -T ", " --files-from " FILE" +get names to extract or create from file FILE +.TP +.BR --test-label +read the volume label; if an argument is specified, test whether it +matches the volume label +.TP +.BR --to-command " COMMAND" +during extraction, pipe extracted files to the standard input of COMMAND +.TP +.BR --totals +print total bytes written with --create +.TP +.BR --transform " EXPRESSION" +transform file or member names using the \fBsed\fR replacement expressio= n +EXPRESSION +.TP +.BR -U ", " --unlink-first +remove existing files before extracting files of the same name +.TP +.BR --unquote +enable unquoting input file or member names; this is the default +.TP +.BR --utc +display file modification dates in UTC +.TP +.BR -v ", " --verbose +verbosely list files processed +.TP +.BR -V ", " --label " NAME" +create archive with volume name NAME +.TP +.BR --version +print \fBtar\fR program version number +.TP +.BR --volno-file " FILE" +keep track of which volume of a multi-volume archive its working in=20 +FILE; used with \fI--multi-volume\fR +.TP +.BR -w ", " --interactive ", " --confirmation +ask for confirmation for every action +.TP +.BR -W ", " --verify +attempt to verify the archive after writing it +.TP +.BR --wildcards +use wildcards with \fI--exclude\fR +.TP +.BR --wildcards-match-slash +wildcards match slashes (/) with \fI--exclude\fR +.TP +.BR -X ", " --exclude-from " FILE" +exclude files listed in FILE +.TP +.BR -z ", " --gzip ", " --gunzip ", " --ungzip +filter the archive through gzip +.TP +.BR -Z ", " --compress ", " --uncompress +filter the archive through compress +.TP +.BR -[0-7][lmh] +specify drive and density +.SH BUGS +The GNU folks, in general, abhor man pages and create info documents ins= tead. +The maintainer of \fBtar\fR falls into this category. Thus, this man pa= ge may=20 +not be complete nor current, and it is included in the Gentoo portage tr= ee=20 +because man is a great tool :). This man page was first taken from Debi= an=20 +Linux and has since been lovingly updated here. +.SH "REPORTING BUGS" +Please report bugs via http://bugs.gentoo.org/ +.SH "AUTHORS" +.nf +Debian Linux http://www.debian.org/ +Mike Frysinger +.fi diff --git a/app-arch/tar/metadata.xml b/app-arch/tar/metadata.xml new file mode 100644 index 0000000..96a2d58 --- /dev/null +++ b/app-arch/tar/metadata.xml @@ -0,0 +1,5 @@ + + + +base-system + diff --git a/app-arch/tar/tar-1.26-r3.ebuild b/app-arch/tar/tar-1.26-r3.e= build new file mode 100644 index 0000000..4049bac --- /dev/null +++ b/app-arch/tar/tar-1.26-r3.ebuild @@ -0,0 +1,78 @@ +# Copyright 1999-2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: /var/cvsroot/gentoo-x86/app-arch/tar/tar-1.26.ebuild,v 1.1 20= 11/03/13 20:46:42 vapier Exp $ + +EAPI=3D"3" + +inherit autotools flag-o-matic + +DESCRIPTION=3D"Use this to make tarballs :)" +HOMEPAGE=3D"http://www.gnu.org/software/tar/" +SRC_URI=3D"http://ftp.gnu.org/gnu/tar/${P}.tar.bz2 + ftp://alpha.gnu.org/gnu/tar/${P}.tar.bz2 + mirror://gnu/tar/${P}.tar.bz2" + +LICENSE=3D"GPL-3" +SLOT=3D"0" +KEYWORDS=3D"~alpha ~amd64 ~arm ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390= ~sh ~sparc ~x86 ~ppc-aix ~x86-fbsd ~x64-freebsd ~x86-freebsd ~hppa-hpux = ~ia64-hpux ~x86-interix ~amd64-linux ~ia64-linux ~x86-linux ~ppc-macos ~x= 64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solar= is ~x86-solaris" +IUSE=3D"nls static userland_GNU acl caps selinux xattr" + +RDEPEND=3D"" +DEPEND=3D"${RDEPEND} + nls? ( >=3Dsys-devel/gettext-0.10.35 )" + +src_prepare() { + epatch "${FILESDIR}"/${P}-full-xattr.patch #382067 + eautoreconf + + if ! use userland_GNU ; then + sed -i \ + -e 's:/backup\.sh:/gbackup.sh:' \ + scripts/{backup,dump-remind,restore}.in \ + || die "sed non-GNU" + fi +} + +src_configure() { + local myconf + use static && append-ldflags -static + use userland_GNU || myconf=3D"--program-prefix=3Dg" + if use acl || use caps || use selinux || use xattr ; then + myconf+=3D" --enable-xattr" + fi + # Work around bug in sandbox #67051 + gl_cv_func_chown_follows_symlink=3Dyes \ + FORCE_UNSAFE_CONFIGURE=3D1 \ + econf \ + --enable-backup-scripts \ + --bindir=3D"${EPREFIX}"/bin \ + --libexecdir=3D"${EPREFIX}"/usr/sbin \ + $(use_enable nls) \ + ${myconf} +} + +src_install() { + local p=3D"" + use userland_GNU || p=3Dg + + emake DESTDIR=3D"${D}" install || die + + if [[ -z ${p} ]] ; then + # a nasty yet required piece of baggage + exeinto /etc + doexe "${FILESDIR}"/rmt || die + fi + + # autoconf looks for gtar before tar (in configure scripts), hence + # in Prefix it is important that it is there, otherwise, a gtar from + # the host system (FreeBSD, Solaris, Darwin) will be found instead + # of the Prefix provided (GNU) tar + if use prefix ; then + dosym tar /bin/gtar + fi + + dodoc AUTHORS ChangeLog* NEWS README* THANKS + newman "${FILESDIR}"/tar.1 ${p}tar.1 + mv "${ED}"/usr/sbin/${p}backup{,-tar} + mv "${ED}"/usr/sbin/${p}restore{,-tar} +}