Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 382067 | Differences between
and this patch

Collapse All | Expand All

(-)tar-1.26.orig//configure.ac (-1 / +19 lines)
Lines 44-50 Link Here
44
  sys/param.h sys/device.h sys/gentape.h \
44
  sys/param.h sys/device.h sys/gentape.h \
45
  sys/inet.h sys/io/trioctl.h \
45
  sys/inet.h sys/io/trioctl.h \
46
  sys/mtio.h sys/time.h sys/tprintf.h sys/tape.h \
46
  sys/mtio.h sys/time.h sys/tprintf.h sys/tape.h \
47
  unistd.h locale.h)
47
  unistd.h locale.h attr/xattr.h sys/acl.h)
48
48
49
AC_CHECK_HEADERS([sys/buf.h], [], [],
49
AC_CHECK_HEADERS([sys/buf.h], [], [],
50
[#if HAVE_SYS_PARAM_H
50
[#if HAVE_SYS_PARAM_H
Lines 91-96 Link Here
91
tar_PAXUTILS
91
tar_PAXUTILS
92
92
93
AC_CHECK_FUNCS_ONCE([fchmod fchown fsync lstat mkfifo readlink symlink])
93
AC_CHECK_FUNCS_ONCE([fchmod fchown fsync lstat mkfifo readlink symlink])
94
AC_CHECK_FUNCS(getxattr  fgetxattr  lgetxattr \
95
               setxattr  fsetxattr  lsetxattr \
96
               listxattr flistxattr llistxattr,
97
               AC_DEFINE(HAVE_XATTRS,,[Define if we have a working extended attributes]),)
98
AC_CHECK_LIB(acl, acl_get_fd)
99
94
AC_CHECK_DECLS([getgrgid],,, [#include <grp.h>])
100
AC_CHECK_DECLS([getgrgid],,, [#include <grp.h>])
95
AC_CHECK_DECLS([getpwuid],,, [#include <pwd.h>])
101
AC_CHECK_DECLS([getpwuid],,, [#include <pwd.h>])
96
AC_CHECK_DECLS([time],,, [#include <time.h>])
102
AC_CHECK_DECLS([time],,, [#include <time.h>])
Lines 214-219 Link Here
214
# Iconv
220
# Iconv
215
AM_ICONV
221
AM_ICONV
216
AC_CHECK_HEADERS(iconv.h)
222
AC_CHECK_HEADERS(iconv.h)
223
AC_CHECK_HEADERS(attr/xattr.h)
217
AC_CHECK_TYPE(iconv_t,:,
224
AC_CHECK_TYPE(iconv_t,:,
218
              AC_DEFINE(iconv_t, int,
225
              AC_DEFINE(iconv_t, int,
219
                        [Conversion descriptor type]),
226
                        [Conversion descriptor type]),
Lines 223-228 Link Here
223
#endif
230
#endif
224
])
231
])
225
232
233
AC_ARG_ENABLE(selinux,
234
  AC_HELP_STRING([--enable-selinux],
235
    [enable SELinux support (disabled by default)]),
236
  [selinux_enabled=$enableval],
237
  [selinux_enabled=no])
238
239
if test "x$selinux_enabled" = xyes; then
240
  AC_CHECK_LIB(selinux, getfilecon)
241
  AC_CHECK_HEADERS(selinux/selinux.h)
242
fi
243
226
# Gettext.
244
# Gettext.
227
AM_GNU_GETTEXT([external], [need-formatstring-macros])
245
AM_GNU_GETTEXT([external], [need-formatstring-macros])
228
AM_GNU_GETTEXT_VERSION([0.16])
246
AM_GNU_GETTEXT_VERSION([0.16])
(-)tar-1.26.orig//doc/tar.texi (+75 lines)
Lines 2369-2374 Link Here
2369
@samp{/} from member names.  This option disables that behavior.
2369
@samp{/} from member names.  This option disables that behavior.
2370
@xref{absolute}.
2370
@xref{absolute}.
2371
2371
2372
@opsummary{acl}
2373
@item --acls
2374
Causes @command{tar} to store ACL's.  @xref{Attributes}.
2375
2372
@opsummary{after-date}
2376
@opsummary{after-date}
2373
@item --after-date
2377
@item --after-date
2374
2378
Lines 2914-2919 Link Here
2914
also back up files for which any status information has
2918
also back up files for which any status information has
2915
changed).  @xref{after}.
2919
changed).  @xref{after}.
2916
2920
2921
@opsummary{no-acl}
2922
@item --no-acls
2923
Causes @command{tar} not to store and not to extract ACL's.  @xref{Attributes}.
2924
2917
@opsummary{no-anchored}
2925
@opsummary{no-anchored}
2918
@item --no-anchored
2926
@item --no-anchored
2919
An exclude pattern can match any subsequence of the name's components.
2927
An exclude pattern can match any subsequence of the name's components.
Lines 2997-3007 Link Here
2997
the archive can be seeked or not.  Use this option to disable this
3005
the archive can be seeked or not.  Use this option to disable this
2998
mechanism.
3006
mechanism.
2999
3007
3008
@opsummary{no-selinux}
3009
@item --no-selinux
3010
Causes @command{tar} not to store and not to extract SELinux security context.
3011
@xref{Attributes}.
3012
3000
@opsummary{no-unquote}
3013
@opsummary{no-unquote}
3001
@item --no-unquote
3014
@item --no-unquote
3002
Treat all input file or member names literally, do not interpret
3015
Treat all input file or member names literally, do not interpret
3003
escape sequences.  @xref{input name quoting}.
3016
escape sequences.  @xref{input name quoting}.
3004
3017
3018
@opsummary{no-xattrs}
3019
@item --no-xattrs
3020
Causes @command{tar} not to store and not to extract xattrs. This option also
3021
enables @option{--no-selinux} and @option{--no-acls}.  @xref{Attributes}.
3022
3005
@opsummary{no-wildcards}
3023
@opsummary{no-wildcards}
3006
@item --no-wildcards
3024
@item --no-wildcards
3007
Do not use wildcards.
3025
Do not use wildcards.
Lines 3234-3239 Link Here
3234
archive is open for reading (e.g. with @option{--list} or
3252
archive is open for reading (e.g. with @option{--list} or
3235
@option{--extract} options).
3253
@option{--extract} options).
3236
3254
3255
@opsummary{selinux}
3256
@item --selinux
3257
Causes @command{tar} to store SElinux security context.  @xref{Attributes}.
3258
3259
3237
@opsummary{show-defaults}
3260
@opsummary{show-defaults}
3238
@item --show-defaults
3261
@item --show-defaults
3239
3262
Lines 3447-3452 Link Here
3447
messages are suppressed if @var{keyword} is prefixed with @samp{no-}.
3470
messages are suppressed if @var{keyword} is prefixed with @samp{no-}.
3448
@xref{warnings}.
3471
@xref{warnings}.
3449
3472
3473
@opsummary{xattrs}
3474
@item --xattrs
3475
Causes @command{tar} to store xattrs. This option also enables
3476
@option{--selinux} and @option{--acls}.  @xref{Attributes}.
3477
3450
@opsummary{wildcards}
3478
@opsummary{wildcards}
3451
@item --wildcards
3479
@item --wildcards
3452
Use wildcards when matching member names with patterns.
3480
Use wildcards when matching member names with patterns.
Lines 8659-8664 Link Here
8659
most @samp{posix} archives as well, with the only exception that any
8687
most @samp{posix} archives as well, with the only exception that any
8660
additional information (such as long file names etc.) will in such
8688
additional information (such as long file names etc.) will in such
8661
case be extracted as plain text files along with the files it refers to.
8689
case be extracted as plain text files along with the files it refers to.
8690
This is the only format that can store ACLs, SELinux context and extended
8691
attributes.
8662
8692
8663
This archive format will be the default format for future versions
8693
This archive format will be the default format for future versions
8664
of @GNUTAR{}.
8694
of @GNUTAR{}.
Lines 9293-9298 Link Here
9293
9323
9294
This option is deprecated, and will be removed in @GNUTAR{} version 1.23.
9324
This option is deprecated, and will be removed in @GNUTAR{} version 1.23.
9295
9325
9326
@opindex acls
9327
@item --acls
9328
This option causes @command{tar} to store the current ACL in the archive.
9329
9330
The @option{--acls} option has no equivalent short option name.
9331
9332
@opindex selinux
9333
@item --selinux
9334
This option causes @command{tar} to store the current SELinux security context
9335
information in the archive.
9336
9337
The @option{--selinux} option has no equivalent short option name.
9338
9339
@opindex xattrs
9340
@item --xattrs
9341
This option causes @command{tar} to store the current extended attributes in
9342
the archive. This option also enables @option{--acls} and @option{--selinux} if
9343
they haven't been set already.
9344
9345
The @option{--xattrs} option has no equivalent short option name.
9346
9347
@opindex no-acls
9348
@item --no-acls
9349
This option causes @command{tar} not to store the current ACL in the archive
9350
and not to extract any ACL information in an archive.
9351
9352
The @option{--no-acls} option has no equivalent short option name.
9353
9354
@opindex no-selinux
9355
@item --no-selinux
9356
This option causes @command{tar} not to store the current SELinux security
9357
context information in the archive and not to extract any SELinux information in
9358
an archive.
9359
9360
The @option{--no-selinux} option has no equivalent short option name.
9361
9362
@opindex no-xattrs
9363
@item --no-xattrs
9364
This option causes @command{tar} not to store the current extended attributes in
9365
the archive and not to extract any extended attributes in an archive. This
9366
option also enables @option{--no-acls} and @option{--no-selinux} if
9367
they haven't been set already.
9368
9369
The @option{--no-xattrs} option has no equivalent short option name.
9370
9296
@end table
9371
@end table
9297
9372
9298
@node Portability
9373
@node Portability
(-)tar-1.26.orig//src/common.h (+18 lines)
Lines 253-258 Link Here
253
/* If positive, preserve permissions when extracting.  */
253
/* If positive, preserve permissions when extracting.  */
254
GLOBAL int same_permissions_option;
254
GLOBAL int same_permissions_option;
255
255
256
/* If positive, save the SELinux context.  */
257
GLOBAL int selinux_context_option;
258
259
/* If positive, save the ACLs.  */
260
GLOBAL int acls_option;
261
262
/* If positive, save the user and root xattrs.  */
263
GLOBAL int xattrs_option;
264
256
/* When set, strip the given number of file name components from the file name
265
/* When set, strip the given number of file name components from the file name
257
   before extracting */
266
   before extracting */
258
GLOBAL size_t strip_name_components;
267
GLOBAL size_t strip_name_components;
Lines 707-712 Link Here
707
716
708
void update_archive (void);
717
void update_archive (void);
709
718
719
/* Module attrs.c.  */
720
#include "xattrs.h"
721
710
/* Module xheader.c.  */
722
/* Module xheader.c.  */
711
723
712
void xheader_decode (struct tar_stat_info *stat);
724
void xheader_decode (struct tar_stat_info *stat);
Lines 727-732 Link Here
727
bool xheader_keyword_deleted_p (const char *kw);
739
bool xheader_keyword_deleted_p (const char *kw);
728
char *xheader_format_name (struct tar_stat_info *st, const char *fmt,
740
char *xheader_format_name (struct tar_stat_info *st, const char *fmt,
729
			   size_t n);
741
			   size_t n);
742
void xheader_xattr_init(struct tar_stat_info *st);
743
void xheader_xattr_free(struct xattr_array *vals, size_t sz);
744
void xheader_xattr_copy(const struct tar_stat_info *st,
745
                        struct xattr_array **vals, size_t *sz);
746
void xheader_xattr_add(struct tar_stat_info *st,
747
                       const char *key, const char *val, size_t len);
730
748
731
/* Module system.c */
749
/* Module system.c */
732
750
(-)tar-1.26.orig//src/create.c (-3 / +47 lines)
Lines 24-29 Link Here
24
#include <quotearg.h>
24
#include <quotearg.h>
25
25
26
#include "common.h"
26
#include "common.h"
27
27
#include <hash.h>
28
#include <hash.h>
28
29
29
/* Error number to use when an impostor is discovered.
30
/* Error number to use when an impostor is discovered.
Lines 936-941 Link Here
936
      GNAME_TO_CHARS (st->gname, header->header.gname);
937
      GNAME_TO_CHARS (st->gname, header->header.gname);
937
    }
938
    }
938
939
940
  if (archive_format == POSIX_FORMAT)
941
    {
942
      if (acls_option > 0)
943
        {
944
          if (st->acls_a_ptr)
945
            xheader_store ("SCHILY.acl.access", st, NULL);
946
          if (st->acls_d_ptr)
947
            xheader_store ("SCHILY.acl.default", st, NULL);
948
        }
949
      if ((selinux_context_option > 0) && st->cntx_name)
950
        xheader_store ("RHT.security.selinux", st, NULL);
951
      if (xattrs_option > 0)
952
        {
953
          size_t scan_xattr = 0;
954
          struct xattr_array *xattr_map = st->xattr_map;
955
956
          while (scan_xattr < st->xattr_map_size)
957
            {
958
              xheader_store (xattr_map[scan_xattr].xkey, st, &scan_xattr);
959
              ++scan_xattr;
960
            }
961
        }
962
    }
963
939
  return header;
964
  return header;
940
}
965
}
941
966
Lines 1711-1716 Link Here
1711
      bool ok;
1736
      bool ok;
1712
      struct stat final_stat;
1737
      struct stat final_stat;
1713
1738
1739
      xattrs_acls_get(st, p, fd, !is_dir);
1740
      xattrs_selinux_get(st, p, fd);
1741
      xattrs_xattrs_get(st, p, fd);
1742
1714
      if (is_dir)
1743
      if (is_dir)
1715
	{
1744
	{
1716
	  const char *tag_file_name;
1745
	  const char *tag_file_name;
Lines 1829-1834 Link Here
1829
      if (NAME_FIELD_SIZE - (archive_format == OLDGNU_FORMAT) < size)
1858
      if (NAME_FIELD_SIZE - (archive_format == OLDGNU_FORMAT) < size)
1830
	write_long_link (st);
1859
	write_long_link (st);
1831
1860
1861
      xattrs_selinux_get(st, p, -1);
1862
      xattrs_xattrs_get(st, p, -1);
1863
1832
      block_ordinal = current_block_ordinal ();
1864
      block_ordinal = current_block_ordinal ();
1833
      st->stat.st_size = 0;	/* force 0 size on symlink */
1865
      st->stat.st_size = 0;	/* force 0 size on symlink */
1834
      header = start_header (st);
1866
      header = start_header (st);
Lines 1847-1857 Link Here
1847
    }
1879
    }
1848
#endif
1880
#endif
1849
  else if (S_ISCHR (st->stat.st_mode))
1881
  else if (S_ISCHR (st->stat.st_mode))
1850
    type = CHRTYPE;
1882
    {
1883
      type = CHRTYPE;
1884
      xattrs_selinux_get(st, p, -1);
1885
      xattrs_xattrs_get(st, p, -1);
1886
    }
1851
  else if (S_ISBLK (st->stat.st_mode))
1887
  else if (S_ISBLK (st->stat.st_mode))
1852
    type = BLKTYPE;
1888
    {
1889
      type = BLKTYPE;
1890
      xattrs_selinux_get(st, p, -1);
1891
      xattrs_xattrs_get(st, p, -1);
1892
    }
1853
  else if (S_ISFIFO (st->stat.st_mode))
1893
  else if (S_ISFIFO (st->stat.st_mode))
1854
    type = FIFOTYPE;
1894
    {
1895
      type = FIFOTYPE;
1896
      xattrs_selinux_get(st, p, -1);
1897
      xattrs_xattrs_get(st, p, -1);
1898
    }
1855
  else if (S_ISSOCK (st->stat.st_mode))
1899
  else if (S_ISSOCK (st->stat.st_mode))
1856
    {
1900
    {
1857
      WARNOPT (WARN_FILE_IGNORED,
1901
      WARNOPT (WARN_FILE_IGNORED,
(-)tar-1.26.orig//src/extract.c (+123 lines)
Lines 97-102 Link Here
97
    /* Directory that the name is relative to.  */
97
    /* Directory that the name is relative to.  */
98
    int change_dir;
98
    int change_dir;
99
99
100
    /* extended attributes*/
101
    char *cntx_name;
102
    char *acls_a_ptr;
103
    size_t acls_a_len;
104
    char *acls_d_ptr;
105
    size_t acls_d_len;
106
    size_t xattr_map_size;   /* Size of the xattr map */
107
    struct xattr_array *xattr_map;
100
    /* Length and contents of name.  */
108
    /* Length and contents of name.  */
101
    size_t file_name_len;
109
    size_t file_name_len;
102
    char file_name[1];
110
    char file_name[1];
Lines 134-139 Link Here
134
       hard-linked together.  */
142
       hard-linked together.  */
135
    struct string_list *sources;
143
    struct string_list *sources;
136
144
145
    /* SELinux context */
146
    char *cntx_name;
147
148
    /* ACLs */
149
    char *acls_a_ptr;
150
    size_t acls_a_len;
151
    char *acls_d_ptr;
152
    size_t acls_d_len;
153
154
    size_t xattr_map_size;   /* Size of the xattr map */
155
    struct xattr_array *xattr_map;
156
137
    /* The desired target of the desired link.  */
157
    /* The desired target of the desired link.  */
138
    char target[1];
158
    char target[1];
139
  };
159
  };
Lines 335-340 Link Here
335
	utime_error (file_name);
355
	utime_error (file_name);
336
    }
356
    }
337
357
358
  xattrs_acls_set(st, file_name, typeflag);
359
  xattrs_selinux_set(st, file_name, typeflag);
360
  xattrs_xattrs_set(st, file_name, typeflag);
361
338
  if (0 < same_owner_option && ! interdir)
362
  if (0 < same_owner_option && ! interdir)
339
    {
363
    {
340
      /* Some systems allow non-root users to give files away.  Once this
364
      /* Some systems allow non-root users to give files away.  Once this
Lines 431-436 Link Here
431
  data->atflag = atflag;
455
  data->atflag = atflag;
432
  data->after_links = 0;
456
  data->after_links = 0;
433
  data->change_dir = chdir_current;
457
  data->change_dir = chdir_current;
458
  data->cntx_name = NULL;
459
  if (st)
460
    assign_string (&data->cntx_name, st->cntx_name);
461
  if (st && st->acls_a_ptr)
462
    {
463
      data->acls_a_ptr = xmemdup(st->acls_a_ptr, st->acls_a_len + 1);
464
      data->acls_a_len = st->acls_a_len;
465
    }
466
  else
467
    {
468
      data->acls_a_ptr = NULL;
469
      data->acls_a_len = 0;
470
    }
471
  if (st && st->acls_d_ptr)
472
    {
473
      data->acls_d_ptr = xmemdup(st->acls_d_ptr, st->acls_d_len + 1);
474
      data->acls_d_len = st->acls_d_len;
475
    }
476
  else
477
    {
478
      data->acls_d_ptr = NULL;
479
      data->acls_d_len = 0;
480
    }
481
  if (st)
482
    xheader_xattr_copy (st, &data->xattr_map, &data->xattr_map_size);
483
  else
484
    {
485
      data->xattr_map = NULL;
486
      data->xattr_map_size = 0;
487
    }
434
  strcpy (data->file_name, file_name);
488
  strcpy (data->file_name, file_name);
435
  delayed_set_stat_head = data;
489
  delayed_set_stat_head = data;
436
  if (must_be_dot_or_slash (file_name))
490
  if (must_be_dot_or_slash (file_name))
Lines 673-678 Link Here
673
  return RECOVER_NO;
727
  return RECOVER_NO;
674
}
728
}
675
729
730
/* Restore stat extended attributes (xattr) for FILE_NAME, using information
731
   given in *ST.  Restore before extraction because they may affect layout.
732
   If not restoring permissions, invert the
733
   INVERT_PERMISSIONS bits from the file's current permissions.
734
   TYPEFLAG specifies the type of the file.
735
   FILE_CREATED indicates set_xattr has created the file */
736
static int
737
set_xattr (char const *file_name, struct tar_stat_info const *st,
738
	   mode_t invert_permissions, char typeflag, int *file_created)
739
{
740
  int status = 0;
741
  bool interdir_made = false;
742
743
  if ((xattrs_option >= 0) && st->xattr_map_size) {
744
    mode_t mode = current_stat_info.stat.st_mode & MODE_RWX & ~ current_umask;
745
746
    do
747
      status = mknod (file_name, mode ^ invert_permissions, 0);
748
    while (status && maybe_recoverable ((char *)file_name, false, &interdir_made));
749
    xattrs_xattrs_set(st, file_name, typeflag);
750
    *file_created = 1;
751
  }
752
  return(status);
753
}
754
676
/* Fix the statuses of all directories whose statuses need fixing, and
755
/* Fix the statuses of all directories whose statuses need fixing, and
677
   which are not ancestors of FILE_NAME.  If AFTER_LINKS is
756
   which are not ancestors of FILE_NAME.  If AFTER_LINKS is
678
   nonzero, do this for all such directories; otherwise, stop at the
757
   nonzero, do this for all such directories; otherwise, stop at the
Lines 733-744 Link Here
733
	  sb.stat.st_gid = data->gid;
812
	  sb.stat.st_gid = data->gid;
734
	  sb.atime = data->atime;
813
	  sb.atime = data->atime;
735
	  sb.mtime = data->mtime;
814
	  sb.mtime = data->mtime;
815
	  sb.cntx_name = data->cntx_name;
816
	  sb.acls_a_ptr = data->acls_a_ptr;
817
	  sb.acls_a_len = data->acls_a_len;
818
	  sb.acls_d_ptr = data->acls_d_ptr;
819
	  sb.acls_d_len = data->acls_d_len;
820
	  sb.xattr_map = data->xattr_map;
821
	  sb.xattr_map_size = data->xattr_map_size;
736
	  set_stat (data->file_name, &sb,
822
	  set_stat (data->file_name, &sb,
737
		    -1, current_mode, current_mode_mask,
823
		    -1, current_mode, current_mode_mask,
738
		    DIRTYPE, data->interdir, data->atflag);
824
		    DIRTYPE, data->interdir, data->atflag);
739
	}
825
	}
740
826
741
      delayed_set_stat_head = data->next;
827
      delayed_set_stat_head = data->next;
828
      xheader_xattr_free (data->xattr_map, data->xattr_map_size);
829
      free (data->cntx_name);
830
      free (data->acls_a_ptr);
831
      free (data->acls_d_ptr);
742
      free (data);
832
      free (data);
743
    }
833
    }
744
}
834
}
Lines 854-859 Link Here
854
944
855
static int
945
static int
856
open_output_file (char const *file_name, int typeflag, mode_t mode,
946
open_output_file (char const *file_name, int typeflag, mode_t mode,
947
                  int file_created,
857
		  mode_t *current_mode, mode_t *current_mode_mask)
948
		  mode_t *current_mode, mode_t *current_mode_mask)
858
{
949
{
859
  int fd;
950
  int fd;
Lines 864-869 Link Here
864
		     ? O_TRUNC | (dereference_option ? 0 : O_NOFOLLOW)
955
		     ? O_TRUNC | (dereference_option ? 0 : O_NOFOLLOW)
865
		     : O_EXCL));
956
		     : O_EXCL));
866
957
958
  /* File might be created in set_xattr. So clear O_EXCL to avoid open() failure */
959
  if (file_created)
960
    openflag = openflag & ~O_EXCL;
961
867
  if (typeflag == CONTTYPE)
962
  if (typeflag == CONTTYPE)
868
    {
963
    {
869
      static int conttype_diagnosed;
964
      static int conttype_diagnosed;
Lines 934-939 Link Here
934
  bool interdir_made = false;
1029
  bool interdir_made = false;
935
  mode_t mode = (current_stat_info.stat.st_mode & MODE_RWX
1030
  mode_t mode = (current_stat_info.stat.st_mode & MODE_RWX
936
		 & ~ (0 < same_owner_option ? S_IRWXG | S_IRWXO : 0));
1031
		 & ~ (0 < same_owner_option ? S_IRWXG | S_IRWXO : 0));
1032
  mode_t invert_permissions = 0 < same_owner_option ? mode & (S_IRWXG | S_IRWXO) : 0;
937
  mode_t current_mode = 0;
1033
  mode_t current_mode = 0;
938
  mode_t current_mode_mask = 0;
1034
  mode_t current_mode_mask = 0;
939
1035
Lines 950-956 Link Here
950
    }
1046
    }
951
  else
1047
  else
952
    {
1048
    {
1049
      int file_created = 0;
1050
      if (set_xattr (file_name, &current_stat_info, invert_permissions,
1051
		     typeflag, &file_created))
1052
        {
1053
          skip_member ();
1054
          open_error (file_name);
1055
          return 1;
1056
        }
1057
953
      while ((fd = open_output_file (file_name, typeflag, mode,
1058
      while ((fd = open_output_file (file_name, typeflag, mode,
1059
                                     file_created,
954
				     &current_mode, &current_mode_mask))
1060
				     &current_mode, &current_mode_mask))
955
	     < 0)
1061
	     < 0)
956
	{
1062
	{
Lines 1091-1096 Link Here
1091
			    + strlen (file_name) + 1);
1197
			    + strlen (file_name) + 1);
1092
      p->sources->next = 0;
1198
      p->sources->next = 0;
1093
      strcpy (p->sources->string, file_name);
1199
      strcpy (p->sources->string, file_name);
1200
      p->cntx_name = NULL;
1201
      assign_string (&p->cntx_name, current_stat_info.cntx_name);
1202
      p->acls_a_ptr = NULL;
1203
      p->acls_a_len = 0;
1204
      p->acls_d_ptr = NULL;
1205
      p->acls_d_len = 0;
1206
      xheader_xattr_copy (&current_stat_info, &p->xattr_map, &p->xattr_map_size);
1094
      strcpy (p->target, current_stat_info.link_name);
1207
      strcpy (p->target, current_stat_info.link_name);
1095
1208
1096
      h = delayed_set_stat_head;
1209
      h = delayed_set_stat_head;
Lines 1525-1530 Link Here
1525
		  st1.stat.st_gid = ds->gid;
1638
		  st1.stat.st_gid = ds->gid;
1526
		  st1.atime = ds->atime;
1639
		  st1.atime = ds->atime;
1527
		  st1.mtime = ds->mtime;
1640
		  st1.mtime = ds->mtime;
1641
                  st1.cntx_name = ds->cntx_name;
1642
                  st1.acls_a_ptr = ds->acls_a_ptr;
1643
                  st1.acls_a_len = ds->acls_a_len;
1644
                  st1.acls_d_ptr = ds->acls_d_ptr;
1645
                  st1.acls_d_len = ds->acls_d_len;
1646
                  st1.xattr_map = ds->xattr_map;
1647
                  st1.xattr_map_size = ds->xattr_map_size;
1528
		  set_stat (source, &st1, -1, 0, 0, SYMTYPE,
1648
		  set_stat (source, &st1, -1, 0, 0, SYMTYPE,
1529
			    false, AT_SYMLINK_NOFOLLOW);
1649
			    false, AT_SYMLINK_NOFOLLOW);
1530
		  valid_source = source;
1650
		  valid_source = source;
Lines 1539-1544 Link Here
1539
	  sources = next;
1659
	  sources = next;
1540
	}
1660
	}
1541
1661
1662
   xheader_xattr_free (ds->xattr_map, ds->xattr_map_size);
1663
   free (ds->cntx_name);
1664
1542
      {
1665
      {
1543
	struct delayed_link *next = ds->next;
1666
	struct delayed_link *next = ds->next;
1544
	free (ds);
1667
	free (ds);
(-)tar-1.26.orig//src/list.c (+7 lines)
Lines 604-609 Link Here
604
  assign_string (&stat_info->gname,
604
  assign_string (&stat_info->gname,
605
		 header->header.gname[0] ? header->header.gname : NULL);
605
		 header->header.gname[0] ? header->header.gname : NULL);
606
606
607
  stat_info->acls_a_ptr = NULL;
608
  stat_info->acls_a_len = 0;
609
  stat_info->acls_d_ptr = NULL;
610
  stat_info->acls_d_len = 0;
611
  stat_info->cntx_name = NULL;
612
  xheader_xattr_init(stat_info);
613
607
  if (format == OLDGNU_FORMAT && incremental_option)
614
  if (format == OLDGNU_FORMAT && incremental_option)
608
    {
615
    {
609
      stat_info->atime.tv_sec = TIME_FROM_HEADER (header->oldgnu_header.atime);
616
      stat_info->atime.tv_sec = TIME_FROM_HEADER (header->oldgnu_header.atime);
(-)tar-1.26.orig//src/Makefile.am (-3 / +4 lines)
Lines 20-26 Link Here
20
20
21
bin_PROGRAMS = tar
21
bin_PROGRAMS = tar
22
22
23
noinst_HEADERS = arith.h common.h tar.h
23
noinst_HEADERS = arith.h common.h tar.h xattrs.h
24
tar_SOURCES = \
24
tar_SOURCES = \
25
 buffer.c\
25
 buffer.c\
26
 checkpoint.c\
26
 checkpoint.c\
Lines 42-51 Link Here
42
 unlink.c\
42
 unlink.c\
43
 update.c\
43
 update.c\
44
 utf8.c\
44
 utf8.c\
45
 warning.c
45
 warning.c\
46
 xattrs.c
46
47
47
INCLUDES = -I$(top_srcdir)/gnu -I../ -I../gnu -I$(top_srcdir)/lib -I../lib
48
INCLUDES = -I$(top_srcdir)/gnu -I../ -I../gnu -I$(top_srcdir)/lib -I../lib
48
49
49
LDADD = ../lib/libtar.a ../gnu/libgnu.a $(LIBINTL) $(LIBICONV)
50
LDADD = ../lib/libtar.a ../gnu/libgnu.a $(LIBINTL) $(LIBICONV)
50
51
51
tar_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_EACCESS)
52
tar_LDADD = $(LIBS) $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_EACCESS)
(-)tar-1.26.orig//src/tar.c (-2 / +78 lines)
Lines 255-261 Link Here
255
255
256
enum
256
enum
257
{
257
{
258
  ANCHORED_OPTION = CHAR_MAX + 1,
258
  ACLS_OPTION = CHAR_MAX + 1,
259
  ANCHORED_OPTION,
259
  ATIME_PRESERVE_OPTION,
260
  ATIME_PRESERVE_OPTION,
260
  BACKUP_OPTION,
261
  BACKUP_OPTION,
261
  CHECK_DEVICE_OPTION,
262
  CHECK_DEVICE_OPTION,
Lines 288-293 Link Here
288
  MODE_OPTION,
289
  MODE_OPTION,
289
  MTIME_OPTION,
290
  MTIME_OPTION,
290
  NEWER_MTIME_OPTION,
291
  NEWER_MTIME_OPTION,
292
  NO_ACLS_OPTION,
291
  NO_ANCHORED_OPTION,
293
  NO_ANCHORED_OPTION,
292
  NO_AUTO_COMPRESS_OPTION,
294
  NO_AUTO_COMPRESS_OPTION,
293
  NO_CHECK_DEVICE_OPTION,
295
  NO_CHECK_DEVICE_OPTION,
Lines 301-309 Link Here
301
  NO_SAME_OWNER_OPTION,
303
  NO_SAME_OWNER_OPTION,
302
  NO_SAME_PERMISSIONS_OPTION,
304
  NO_SAME_PERMISSIONS_OPTION,
303
  NO_SEEK_OPTION,
305
  NO_SEEK_OPTION,
306
  NO_SELINUX_CONTEXT_OPTION,
304
  NO_UNQUOTE_OPTION,
307
  NO_UNQUOTE_OPTION,
305
  NO_WILDCARDS_MATCH_SLASH_OPTION,
308
  NO_WILDCARDS_MATCH_SLASH_OPTION,
306
  NO_WILDCARDS_OPTION,
309
  NO_WILDCARDS_OPTION,
310
  NO_XATTR_OPTION,
307
  NULL_OPTION,
311
  NULL_OPTION,
308
  NUMERIC_OWNER_OPTION,
312
  NUMERIC_OWNER_OPTION,
309
  OCCURRENCE_OPTION,
313
  OCCURRENCE_OPTION,
Lines 325-330 Link Here
325
  RMT_COMMAND_OPTION,
329
  RMT_COMMAND_OPTION,
326
  RSH_COMMAND_OPTION,
330
  RSH_COMMAND_OPTION,
327
  SAME_OWNER_OPTION,
331
  SAME_OWNER_OPTION,
332
  SELINUX_CONTEXT_OPTION,
328
  SHOW_DEFAULTS_OPTION,
333
  SHOW_DEFAULTS_OPTION,
329
  SHOW_OMITTED_DIRS_OPTION,
334
  SHOW_OMITTED_DIRS_OPTION,
330
  SHOW_TRANSFORMED_NAMES_OPTION,
335
  SHOW_TRANSFORMED_NAMES_OPTION,
Lines 340-346 Link Here
340
  VOLNO_FILE_OPTION,
345
  VOLNO_FILE_OPTION,
341
  WARNING_OPTION,
346
  WARNING_OPTION,
342
  WILDCARDS_MATCH_SLASH_OPTION,
347
  WILDCARDS_MATCH_SLASH_OPTION,
343
  WILDCARDS_OPTION
348
  WILDCARDS_OPTION,
349
  XATTR_OPTION
344
};
350
};
345
351
346
const char *argp_program_version = "tar (" PACKAGE_NAME ") " VERSION;
352
const char *argp_program_version = "tar (" PACKAGE_NAME ") " VERSION;
Lines 486-491 Link Here
486
  {NULL, 0, NULL, 0,
492
  {NULL, 0, NULL, 0,
487
   N_("Handling of file attributes:"), GRID },
493
   N_("Handling of file attributes:"), GRID },
488
494
495
  {"acls", ACLS_OPTION, 0, 0,
496
   N_("Save the ACLs to the archive"), GRID+1 },
497
  {"no-acls", NO_ACLS_OPTION, 0, 0,
498
   N_("Don't extract the ACLs from the archive"), GRID+1 },
489
  {"owner", OWNER_OPTION, N_("NAME"), 0,
499
  {"owner", OWNER_OPTION, N_("NAME"), 0,
490
   N_("force NAME as owner for added files"), GRID+1 },
500
   N_("force NAME as owner for added files"), GRID+1 },
491
  {"group", GROUP_OPTION, N_("NAME"), 0,
501
  {"group", GROUP_OPTION, N_("NAME"), 0,
Lines 516-521 Link Here
516
  {"preserve-order", 's', 0, 0,
526
  {"preserve-order", 's', 0, 0,
517
   N_("sort names to extract to match archive"), GRID+1 },
527
   N_("sort names to extract to match archive"), GRID+1 },
518
  {"same-order", 0, 0, OPTION_ALIAS, NULL, GRID+1 },
528
  {"same-order", 0, 0, OPTION_ALIAS, NULL, GRID+1 },
529
  {"selinux", SELINUX_CONTEXT_OPTION, 0, 0,
530
   N_("Save the SELinux context to the archive"), GRID+1 },
531
  {"no-selinux", NO_SELINUX_CONTEXT_OPTION, 0, 0,
532
   N_("Don't extract the SELinux context from the archive"), GRID+1 },
533
  {"xattrs", XATTR_OPTION, 0, 0,
534
   N_("Save the user/root xattrs to the archive"), GRID+1 },
535
  {"no-xattrs", NO_XATTR_OPTION, 0, 0,
536
   N_("Don't extract the user/root xattrs from the archive"), GRID+1 },
519
  {"preserve", PRESERVE_OPTION, 0, 0,
537
  {"preserve", PRESERVE_OPTION, 0, 0,
520
   N_("same as both -p and -s"), GRID+1 },
538
   N_("same as both -p and -s"), GRID+1 },
521
  {"delay-directory-restore", DELAY_DIRECTORY_RESTORE_OPTION, 0, 0,
539
  {"delay-directory-restore", DELAY_DIRECTORY_RESTORE_OPTION, 0, 0,
Lines 2079-2084 Link Here
2079
      same_permissions_option = -1;
2097
      same_permissions_option = -1;
2080
      break;
2098
      break;
2081
2099
2100
    case ACLS_OPTION:
2101
      set_archive_format ("posix");
2102
      acls_option = 1;
2103
      break;
2104
2105
    case NO_ACLS_OPTION:
2106
      acls_option = -1;
2107
      break;
2108
2109
    case SELINUX_CONTEXT_OPTION:
2110
      set_archive_format ("posix");
2111
      selinux_context_option = 1;
2112
      break;
2113
2114
    case NO_SELINUX_CONTEXT_OPTION:
2115
      selinux_context_option = -1;
2116
      break;
2117
2118
    case XATTR_OPTION:
2119
      set_archive_format ("posix");
2120
      if (!acls_option) acls_option = 1;
2121
      if (!selinux_context_option) selinux_context_option = 1;
2122
      xattrs_option = 1;
2123
      break;
2124
2125
    case NO_XATTR_OPTION:
2126
      if (!acls_option) acls_option = -1;
2127
      if (!selinux_context_option) selinux_context_option = -1;
2128
      xattrs_option = -1;
2129
      break;
2130
2082
    case RECURSION_OPTION:
2131
    case RECURSION_OPTION:
2083
      recursion_option = FNM_LEADING_DIR;
2132
      recursion_option = FNM_LEADING_DIR;
2084
      break;
2133
      break;
Lines 2461-2466 Link Here
2461
	  || subcommand_option != LIST_SUBCOMMAND))
2510
	  || subcommand_option != LIST_SUBCOMMAND))
2462
    USAGE_ERROR ((0, 0, _("--pax-option can be used only on POSIX archives")));
2511
    USAGE_ERROR ((0, 0, _("--pax-option can be used only on POSIX archives")));
2463
2512
2513
  /* star create's non-POSIX typed archives with xattr support, so allow the
2514
     extra headers */
2515
  if ((acls_option > 0)
2516
      && archive_format != POSIX_FORMAT
2517
      && (subcommand_option != EXTRACT_SUBCOMMAND
2518
	  || subcommand_option != DIFF_SUBCOMMAND
2519
	  || subcommand_option != LIST_SUBCOMMAND))
2520
    USAGE_ERROR ((0, 0, _("--acls can be used only on POSIX archives")));
2521
2522
  if ((selinux_context_option > 0)
2523
      && archive_format != POSIX_FORMAT
2524
      && (subcommand_option != EXTRACT_SUBCOMMAND
2525
	  || subcommand_option != DIFF_SUBCOMMAND
2526
	  || subcommand_option != LIST_SUBCOMMAND))
2527
    USAGE_ERROR ((0, 0, _("--selinux can be used only on POSIX archives")));
2528
2529
  if ((xattrs_option > 0)
2530
      && archive_format != POSIX_FORMAT
2531
      && (subcommand_option != EXTRACT_SUBCOMMAND
2532
	  || subcommand_option != DIFF_SUBCOMMAND
2533
	  || subcommand_option != LIST_SUBCOMMAND))
2534
    USAGE_ERROR ((0, 0, _("--xattrs can be used only on POSIX archives")));
2535
2464
  /* If ready to unlink hierarchies, so we are for simpler files.  */
2536
  /* If ready to unlink hierarchies, so we are for simpler files.  */
2465
  if (recursive_unlink_option)
2537
  if (recursive_unlink_option)
2466
    old_files_option = UNLINK_FIRST_OLD_FILES;
2538
    old_files_option = UNLINK_FIRST_OLD_FILES;
Lines 2713-2723 Link Here
2713
tar_stat_destroy (struct tar_stat_info *st)
2785
tar_stat_destroy (struct tar_stat_info *st)
2714
{
2786
{
2715
  tar_stat_close (st);
2787
  tar_stat_close (st);
2788
  xheader_xattr_free (st->xattr_map, st->xattr_map_size);
2716
  free (st->orig_file_name);
2789
  free (st->orig_file_name);
2717
  free (st->file_name);
2790
  free (st->file_name);
2718
  free (st->link_name);
2791
  free (st->link_name);
2719
  free (st->uname);
2792
  free (st->uname);
2720
  free (st->gname);
2793
  free (st->gname);
2794
  free (st->cntx_name);
2795
  free (st->acls_a_ptr);
2796
  free (st->acls_d_ptr);
2721
  free (st->sparse_map);
2797
  free (st->sparse_map);
2722
  free (st->dumpdir);
2798
  free (st->dumpdir);
2723
  xheader_destroy (&st->xhdr);
2799
  xheader_destroy (&st->xhdr);
(-)tar-1.26.orig//src/tar.h (+20 lines)
Lines 276-281 Link Here
276
  uintmax_t string_length;
276
  uintmax_t string_length;
277
};
277
};
278
278
279
/* Information about xattrs for a file.  */
280
struct xattr_array
281
  {
282
    char *xkey;
283
    char *xval_ptr;
284
    size_t xval_len;
285
  };
286
279
struct tar_stat_info
287
struct tar_stat_info
280
{
288
{
281
  char *orig_file_name;     /* name of file read from the archive header */
289
  char *orig_file_name;     /* name of file read from the archive header */
Lines 287-292 Link Here
287
295
288
  char          *uname;     /* user name of owner */
296
  char          *uname;     /* user name of owner */
289
  char          *gname;     /* group name of owner */
297
  char          *gname;     /* group name of owner */
298
299
  char *cntx_name;          /* SELinux context for the current archive entry. */
300
301
  char *acls_a_ptr;         /* Access ACLs for the current archive entry. */
302
  size_t acls_a_len;        /* Access ACLs for the current archive entry. */
303
304
  char *acls_d_ptr;         /* Default ACLs for the current archive entry. */
305
  size_t acls_d_len;        /* Default ACLs for the current archive entry. */
306
290
  struct stat   stat;       /* regular filesystem stat */
307
  struct stat   stat;       /* regular filesystem stat */
291
308
292
  /* STAT doesn't always have access, data modification, and status
309
  /* STAT doesn't always have access, data modification, and status
Lines 309-314 Link Here
309
  size_t sparse_map_size;   /* Size of the sparse map */
326
  size_t sparse_map_size;   /* Size of the sparse map */
310
  struct sp_array *sparse_map;
327
  struct sp_array *sparse_map;
311
328
329
  size_t xattr_map_size;   /* Size of the xattr map */
330
  struct xattr_array *xattr_map;
331
312
  /* Extended headers */
332
  /* Extended headers */
313
  struct xheader xhdr;
333
  struct xheader xhdr;
314
334
(-)tar-1.26.orig//src/xattrs.c (+489 lines)
Line 0 Link Here
1
/* Create a tar archive.
2
3
   Copyright (C) 2006 Free Software Foundation, Inc.
4
5
   Written by James Antill, on 2006-07-27.
6
7
   This program is free software; you can redistribute it and/or modify it
8
   under the terms of the GNU General Public License as published by the
9
   Free Software Foundation; either version 2, or (at your option) any later
10
   version.
11
12
   This program is distributed in the hope that it will be useful, but
13
   WITHOUT ANY WARRANTY; without even the implied warranty of
14
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
15
   Public License for more details.
16
17
   You should have received a copy of the GNU General Public License along
18
   with this program; if not, write to the Free Software Foundation, Inc.,
19
   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.  */
20
21
#include <system.h>
22
23
#include <quotearg.h>
24
25
#include "common.h"
26
27
28
#ifndef HAVE_SELINUX_SELINUX_H
29
# undef HAVE_LIBSELINUX
30
#endif
31
32
#ifndef HAVE_ATTR_XATTR_H
33
# undef HAVE_XATTRS
34
#endif
35
36
#ifndef HAVE_SYS_ACL_H
37
# undef HAVE_LIBACL
38
#endif
39
40
#ifdef HAVE_SELINUX_SELINUX_H
41
# include <selinux/selinux.h>
42
#endif
43
44
#ifdef HAVE_ATTR_XATTR_H
45
# include <attr/xattr.h>
46
#endif
47
48
#ifdef HAVE_SYS_ACL_H
49
# include <sys/acl.h>
50
#endif
51
52
53
#if 0 /* unused by xattr's atm. */
54
static void xattrs__fd_get(struct tar_stat_info *st,
55
                           char const *file_name, int fd, const char *attr,
56
                           char **ret_ptr, size_t *ret_len)
57
{
58
#ifdef HAVE_XATTRS
59
  static ssize_t asz = 1024;
60
  ssize_t ret = 0;
61
  static char *val = NULL;
62
63
  if (!val) val = xmalloc (asz);
64
65
  while (((ret = fgetxattr (fd, attr, val, asz)) == -1) &&
66
         (errno == ERANGE))
67
    {
68
      asz <<= 1;
69
      val = xrealloc (val, asz);
70
    }
71
72
  if (ret != -1)
73
    {
74
      *ret_ptr = xmemdup (val, ret + 1);
75
      *ret_len = ret;
76
    }
77
  else if (errno != ENOATTR)
78
    call_arg_warn ("fgetxattr", file_name);
79
#endif
80
}
81
#endif
82
83
static void xattrs__acls_get_a(struct tar_stat_info *st,
84
                               char const *file_name, int fd,
85
                               char **ret_ptr, size_t *ret_len)
86
{ /* "system.posix_acl_access" */
87
#ifdef HAVE_LIBACL
88
  char *val = NULL;
89
  ssize_t len;
90
  acl_t acl;
91
92
  if (fd != -1)
93
  {
94
    if ((acl = acl_get_fd (fd)) == (acl_t)NULL)
95
    {
96
      if (errno != ENOTSUP)
97
        call_arg_warn ("acl_get_fd", file_name);
98
      return;
99
    }
100
  }
101
  else if ((acl = acl_get_file (file_name, ACL_TYPE_ACCESS)) == (acl_t)NULL)
102
  {
103
    if (errno != ENOTSUP)
104
      call_arg_warn ("acl_get_file", file_name);
105
    return;
106
  }
107
108
109
  val = acl_to_text(acl, &len);
110
  acl_free (acl);
111
112
  if (val == NULL)
113
  {
114
    call_arg_warn ("acl_to_text", file_name);
115
    return;
116
  }
117
118
  *ret_ptr = xstrdup (val);
119
  *ret_len = len;
120
121
  acl_free (val);
122
#endif
123
}
124
125
static void xattrs__acls_get_d(struct tar_stat_info *st,
126
                               char const *file_name,
127
                               char **ret_ptr, size_t *ret_len)
128
{ /* "system.posix_acl_default" */
129
#ifdef HAVE_LIBACL
130
  char *val = NULL;
131
  ssize_t len;
132
  acl_t acl;
133
134
  if ((acl = acl_get_file (file_name, ACL_TYPE_DEFAULT)) == (acl_t)NULL)
135
  {
136
    if (errno != ENOTSUP)
137
      call_arg_warn ("acl_get_file", file_name);
138
    return;
139
  }
140
141
  val = acl_to_text(acl, &len);
142
  acl_free (acl);
143
144
  if (val == NULL)
145
  {
146
    call_arg_warn ("acl_to_text", file_name);
147
    return;
148
  }
149
150
  *ret_ptr = xstrdup (val);
151
  *ret_len = len;
152
153
  acl_free (val);
154
#endif
155
}
156
157
void xattrs_acls_get(struct tar_stat_info *st, char const *file_name, int fd,
158
                     int xisfile)
159
{
160
  if (acls_option > 0)
161
    {
162
#ifndef HAVE_LIBACL
163
      static int done = 0;
164
      if (!done)
165
          WARN ((0, 0, _("ACL support requested, but not available")));
166
      done = 1;
167
#endif
168
      xattrs__acls_get_a (st, file_name, fd,
169
                          &st->acls_a_ptr, &st->acls_a_len);
170
      if (!xisfile)
171
        xattrs__acls_get_d (st, file_name,
172
                            &st->acls_d_ptr, &st->acls_d_len);
173
    }
174
}
175
176
void xattrs_selinux_get(struct tar_stat_info *st, char const *file_name, int fd)
177
{
178
  if (selinux_context_option > 0)
179
  {
180
#ifndef HAVE_LIBSELINUX
181
      static int done = 0;
182
      if (!done)
183
          WARN ((0, 0, _("SELinux support requested, but not available")));
184
      done = 1;
185
#else
186
    if (fd == -1)
187
    {
188
      if ((lgetfilecon (file_name, &st->cntx_name) == -1) && (errno != ENOTSUP) && (errno != ENODATA))
189
        call_arg_warn ("lgetfilecon", file_name);
190
    }
191
    else if ((fgetfilecon (fd, &st->cntx_name) == -1) && (errno != ENOTSUP) && (errno != ENODATA))
192
      call_arg_warn ("fgetfilecon", file_name);
193
#endif
194
  }
195
}
196
197
void xattrs_xattrs_get(struct tar_stat_info *st, char const *file_name, int fd)
198
{
199
  if (xattrs_option > 0)
200
    { /* get all xattrs ... this include security.* and system.* if
201
         available. We filter them here, but we have to filter them
202
         in xattrs_xattrs_set() anyway.
203
      */
204
      static ssize_t xsz = 1024;
205
      static char *xatrs = NULL;
206
      ssize_t xret = -1;
207
208
#ifndef HAVE_XATTRS
209
      static int done = 0;
210
      if ((xattrs_option > 0) && !done)
211
          WARN ((0, 0, _("Xattr support requested, but not available")));
212
      done = 1;
213
#else
214
215
      if (!xatrs) xatrs = xmalloc (xsz);
216
217
      while (((fd == -1) ?
218
              ((xret = llistxattr (file_name, xatrs, xsz)) == -1) :
219
              ((xret = flistxattr (fd, xatrs, xsz)) == -1)) &&
220
             (errno == ERANGE))
221
        {
222
          xsz <<= 1;
223
          xatrs = xrealloc (xatrs, xsz);
224
        }
225
226
      if (xret == -1)
227
        call_arg_warn ((fd == -1) ? "llistxattrs" : "flistxattrs", file_name);
228
      else
229
        {
230
          const char *attr = xatrs;
231
          static ssize_t asz = 1024;
232
          static char *val = NULL;
233
234
          if (!val) val = xmalloc (asz);
235
236
          while (xret > 0)
237
            {
238
              size_t len = strlen (attr);
239
              ssize_t aret = 0;
240
241
              /* Archive all xattrs during creation, decide at extraction time
242
               * which ones are of interest/use for the target filesystem. */
243
              while (((fd == -1) ?
244
                      ((aret = lgetxattr (file_name, attr, val, asz)) == -1) :
245
                      ((aret = fgetxattr (fd, attr, val, asz)) == -1)) &&
246
                     (errno == ERANGE))
247
                {
248
                  asz <<= 1;
249
                  val = xrealloc (val, asz);
250
                }
251
252
              if (aret != -1)
253
                xheader_xattr_add (st, attr, val, aret);
254
              else if (errno != ENOATTR)
255
                call_arg_warn ((fd==-1) ? "lgetxattr" : "fgetxattr", file_name);
256
257
              attr += len + 1;
258
              xret -= len + 1;
259
            }
260
        }
261
#endif
262
    }
263
}
264
265
static void xattrs__fd_set(struct tar_stat_info const *st,
266
                           char const *file_name, char typeflag,
267
                           const char *attr,
268
                           const char *ptr, size_t len)
269
{
270
#ifdef HAVE_XATTRS
271
  if (ptr)
272
    {
273
      const char *sysname = "setxattr";
274
      int ret = -1;
275
276
      if (typeflag != SYMTYPE)
277
        ret = setxattr (file_name, attr, ptr, len, 0);
278
      else
279
        {
280
          sysname = "lsetxattr";
281
          ret = lsetxattr (file_name, attr, ptr, len, 0);
282
        }
283
284
      /* do not print warnings when SELinux is disabled */
285
      if ((ret == -1) && (errno != EPERM) && (errno != ENOTSUP))
286
        call_arg_error(sysname, file_name);
287
    }
288
#endif
289
}
290
291
/* convert unix permissions into an ACL ... needed due to "default" ACLs */
292
#ifdef HAVE_LIBACL
293
static acl_t perms2acl(int perms)
294
{
295
  char val[] = "user::---,group::---,other::---";
296
  /*            0123456789 123456789 123456789 123456789 */
297
298
   /* user */
299
  if (perms & 0400) val[ 6] = 'r';
300
  if (perms & 0200) val[ 7] = 'w';
301
  if (perms & 0100) val[ 8] = 'x';
302
303
  /* group */
304
  if (perms & 0040) val[17] = 'r';
305
  if (perms & 0020) val[18] = 'w';
306
  if (perms & 0010) val[19] = 'x';
307
308
  /* other */
309
  if (perms & 0004) val[28] = 'r';
310
  if (perms & 0002) val[29] = 'w';
311
  if (perms & 0001) val[30] = 'x';
312
313
  return (acl_from_text (val));
314
}
315
#endif
316
317
static char *skip_to_ext_fields(char *ptr)
318
{
319
  ptr += strcspn(ptr, ":,\n"); /* skip tag name. Ie. user/group/default/mask */
320
321
  if (*ptr != ':')
322
    return (ptr); /* error? no user/group field */
323
  ++ptr;
324
325
  ptr += strcspn(ptr, ":,\n"); /* skip user/group name */
326
327
  if (*ptr != ':')
328
    return (ptr); /* error? no perms field */
329
  ++ptr;
330
331
  ptr += strcspn(ptr, ":,\n"); /* skip perms */
332
333
  if (*ptr != ':')
334
    return (ptr); /* no extra fields */
335
336
  return (ptr);
337
}
338
339
/* The POSIX draft allows extra fields after the three main ones. Star
340
   uses this to add a fourth field for user/group which is the numeric ID.
341
   We just skip all extra fields atm. */
342
static const char *fixup_extra_acl_fields(const char *ptr)
343
{
344
  char *src = (char *)ptr;
345
  char *dst = (char *)ptr;
346
347
  while (*src)
348
  {
349
    const char *old = src;
350
    size_t len = 0;
351
352
    src = skip_to_ext_fields(src);
353
    len = src - old;
354
    if (old != dst) memmove(dst, old, len);
355
    dst += len;
356
357
    if (*src == ':') /* We have extra fields, skip them all */
358
      src += strcspn(src, "\n,");
359
360
    if ((*src == '\n') || (*src == ','))
361
      *dst++ = *src++; /* also done when dst == src, but that's ok */
362
  }
363
  if (src != dst)
364
    *dst = 0;
365
366
  return ptr;
367
}
368
369
static void xattrs__acls_set(struct tar_stat_info const *st,
370
                             char const *file_name, int type,
371
                             const char *ptr, size_t len)
372
{ /* "system.posix_acl_access" */
373
#ifdef HAVE_LIBACL
374
  acl_t acl;
375
376
  if (ptr)
377
    {
378
      /* assert (strlen (ptr) == len); */
379
      ptr = fixup_extra_acl_fields(ptr);
380
381
      acl = acl_from_text (ptr);
382
      acls_option = 1;
383
    }
384
  else if (acls_option > 0)
385
    acl = perms2acl (st->stat.st_mode);
386
  else
387
    return; /* don't call acl functions unless we first hit an ACL, or
388
               --acls was passed explicitly */
389
390
  if (acl == (acl_t)NULL)
391
    {
392
      call_arg_warn ("acl_from_text", file_name);
393
      return;
394
    }
395
396
  if (acl_set_file (file_name, type, acl) == -1)
397
    {
398
      if (errno != ENOTSUP)
399
        call_arg_warn ("acl_set_file", file_name);
400
    }
401
  acl_free (acl);
402
#endif
403
}
404
405
void xattrs_acls_set(struct tar_stat_info const *st,
406
                     char const *file_name, char typeflag)
407
{
408
  if ((acls_option >= 0) && (typeflag != SYMTYPE))
409
    {
410
#ifndef HAVE_LIBACL
411
      static int done = 0;
412
      if (!done)
413
        WARN ((0, 0, _("ACL support requested, but not available")));
414
      done = 1;
415
#else
416
      xattrs__acls_set (st, file_name, ACL_TYPE_ACCESS,
417
                        st->acls_a_ptr, st->acls_a_len);
418
      if ((typeflag == DIRTYPE) || (typeflag == GNUTYPE_DUMPDIR))
419
        xattrs__acls_set (st, file_name, ACL_TYPE_DEFAULT,
420
                          st->acls_d_ptr, st->acls_d_len);
421
#endif
422
    }
423
}
424
425
void xattrs_selinux_set(struct tar_stat_info const *st,
426
                        char const *file_name, char typeflag)
427
{
428
  if ((selinux_context_option >= 0) && st->cntx_name)
429
    {
430
      const char *sysname = "setfilecon";
431
      int ret = -1;
432
433
#ifndef HAVE_LIBSELINUX
434
      static int done = 0;
435
      if (!done)
436
          WARN ((0, 0, _("SELinux support requested, but not available")));
437
      done = 1;
438
#else
439
      if (typeflag != SYMTYPE)
440
        ret = setfilecon (file_name, st->cntx_name);
441
      else
442
        {
443
          sysname = "lsetfilecon";
444
          ret = lsetfilecon (file_name, st->cntx_name);
445
        }
446
447
      if ((ret == -1) && (errno == EPERM))
448
        call_arg_warn(sysname, file_name);
449
      else if ((ret == -1) && (errno != EOPNOTSUPP))
450
        call_arg_error(sysname, file_name);
451
#endif
452
    }
453
}
454
455
void xattrs_xattrs_set(struct tar_stat_info const *st,
456
                       char const *file_name, char typeflag)
457
{
458
  if ((xattrs_option >= 0) && st->xattr_map_size)
459
    {
460
      size_t scan = 0;
461
462
#ifndef HAVE_XATTRS
463
      static int done = 0;
464
      if (!done)
465
          WARN ((0, 0, _("Xattr support requested, but not available")));
466
      done = 1;
467
#else
468
      while (scan < st->xattr_map_size)
469
        {
470
          char *keyword = st->xattr_map[scan].xkey;
471
472
          /* assert (!memcpy (keyword, "SCHILY.xattr.", strlen("SCHILY.xattr."))); */
473
          keyword += strlen("SCHILY.xattr.");
474
475
          if (strncmp (keyword, "user.", strlen("user.")) &&
476
              strncmp (keyword, "lustre.", strlen("lustre.")) &&
477
              strncmp (keyword, "trusted.", strlen("trusted.")) &&
478
              strncmp (keyword, "security.NTACL", strlen("security.NTACL")))
479
            continue; /* don't try and set anything but normal xattrs */
480
481
          xattrs__fd_set (st, file_name, typeflag, keyword,
482
                          st->xattr_map[scan].xval_ptr,
483
                          st->xattr_map[scan].xval_len);
484
485
          ++scan;
486
        }
487
#endif
488
    }
489
}
(-)tar-1.26.orig//src/xattrs.h (+14 lines)
Line 0 Link Here
1
2
extern void xattrs_acls_get(struct tar_stat_info *st,
3
                            char const *file_name, int fd, int xisfile);
4
extern void xattrs_selinux_get(struct tar_stat_info *st,
5
                               char const *file_name, int fd);
6
extern void xattrs_xattrs_get(struct tar_stat_info *st,
7
                              char const *file_name, int fd);
8
9
extern void xattrs_acls_set(struct tar_stat_info const *st,
10
                            char const *file_name, char typeflag);
11
extern void xattrs_selinux_set(struct tar_stat_info const *st,
12
                               char const *file_name, char typeflag);
13
extern void xattrs_xattrs_set(struct tar_stat_info const *st,
14
                              char const *file_name, char typeflag);
(-)tar-1.26.orig//src/xheader.c (-31 / +204 lines)
Lines 460-465 Link Here
460
    }
460
    }
461
}
461
}
462
462
463
void xheader_xattr_init(struct tar_stat_info *st)
464
{
465
  st->xattr_map = NULL;
466
  st->xattr_map_size = 0;
467
}
468
469
void xheader_xattr_free(struct xattr_array *xattr_map, size_t xattr_map_size)
470
{
471
  size_t scan = 0;
472
473
  while (scan < xattr_map_size)
474
    {
475
      free (xattr_map[scan].xkey);
476
      free (xattr_map[scan].xval_ptr);
477
478
      ++scan;
479
    }
480
  free (xattr_map);
481
}
482
483
static void xheader_xattr__add(struct xattr_array **xattr_map,
484
                               size_t *xattr_map_size,
485
                               const char *key, const char *val, size_t len)
486
{
487
  size_t pos = (*xattr_map_size)++;
488
489
  *xattr_map = xrealloc (*xattr_map,
490
                         *xattr_map_size * sizeof(struct xattr_array));
491
  (*xattr_map)[pos].xkey = xstrdup (key);
492
  (*xattr_map)[pos].xval_ptr = xmemdup (val, len + 1);
493
  (*xattr_map)[pos].xval_len = len;
494
}
495
496
void xheader_xattr_add(struct tar_stat_info *st,
497
                       const char *key, const char *val, size_t len)
498
{
499
  size_t klen = strlen (key);
500
  char *xkey = xmalloc (strlen("SCHILY.xattr.") + klen + 1);
501
  char *tmp = xkey;
502
503
  tmp = stpcpy (tmp, "SCHILY.xattr.");
504
  tmp = stpcpy (tmp, key);
505
506
  xheader_xattr__add (&st->xattr_map, &st->xattr_map_size, xkey, val, len);
507
508
  free (xkey);
509
}
510
511
void xheader_xattr_copy(const struct tar_stat_info *st,
512
                        struct xattr_array **xattr_map, size_t *xattr_map_size)
513
{
514
  size_t scan = 0;
515
516
  *xattr_map = NULL;
517
  *xattr_map_size = 0;
518
519
  while (scan < st->xattr_map_size)
520
    {
521
      char  *key = st->xattr_map[scan].xkey;
522
      char  *val = st->xattr_map[scan].xval_ptr;
523
      size_t len = st->xattr_map[scan].xval_len;
524
525
      xheader_xattr__add(xattr_map, xattr_map_size, key, val, len);
526
527
      ++scan;
528
    }
529
}
530
463
531
464
/* General Interface */
532
/* General Interface */
465
533
Lines 473-478 Link Here
473
		 struct xheader *, void const *data);
541
		 struct xheader *, void const *data);
474
  void (*decoder) (struct tar_stat_info *, char const *, char const *, size_t);
542
  void (*decoder) (struct tar_stat_info *, char const *, char const *, size_t);
475
  int flags;
543
  int flags;
544
  bool prefix;
476
};
545
};
477
546
478
/* This declaration must be extern, because ISO C99 section 6.9.2
547
/* This declaration must be extern, because ISO C99 section 6.9.2
Lines 489-496 Link Here
489
  struct xhdr_tab const *p;
558
  struct xhdr_tab const *p;
490
559
491
  for (p = xhdr_tab; p->keyword; p++)
560
  for (p = xhdr_tab; p->keyword; p++)
492
    if (strcmp (p->keyword, keyword) == 0)
561
    if (p->prefix)
493
      return p;
562
      {
563
        if (strncmp (p->keyword, keyword, strlen(p->keyword)) == 0)
564
          return p;
565
      }
566
  else
567
      {
568
        if (strcmp (p->keyword, keyword) == 0)
569
          return p;
570
      }
571
494
  return NULL;
572
  return NULL;
495
}
573
}
496
574
Lines 500-506 Link Here
500
  struct xhdr_tab const *p;
578
  struct xhdr_tab const *p;
501
579
502
  for (p = xhdr_tab; p->keyword; p++)
580
  for (p = xhdr_tab; p->keyword; p++)
503
    if ((p->flags & XHDR_PROTECTED) && fnmatch (pattern, p->keyword, 0) == 0)
581
    if (!p->prefix && (p->flags & XHDR_PROTECTED) && fnmatch (pattern, p->keyword, 0) == 0)
504
      return true;
582
      return true;
505
  return false;
583
  return false;
506
}
584
}
Lines 511-517 Link Here
511
  struct xhdr_tab const *p;
589
  struct xhdr_tab const *p;
512
590
513
  for (p = xhdr_tab; p->keyword; p++)
591
  for (p = xhdr_tab; p->keyword; p++)
514
    if ((p->flags & XHDR_PROTECTED) && strcmp (p->keyword, keyword) == 0)
592
    if (!p->prefix && (p->flags & XHDR_PROTECTED) && strcmp (p->keyword, keyword) == 0)
515
      return true;
593
      return true;
516
  return false;
594
  return false;
517
}
595
}
Lines 1470-1475 Link Here
1470
}
1548
}
1471
1549
1472
static void
1550
static void
1551
xattr_selinux_coder (struct tar_stat_info const *st, char const *keyword,
1552
                     struct xheader *xhdr, void const *data)
1553
{
1554
  code_string (st->cntx_name, keyword, xhdr);
1555
}
1556
1557
static void
1558
xattr_selinux_decoder (struct tar_stat_info *st,
1559
                       char const *keyword, char const *arg, size_t size)
1560
{
1561
  decode_string (&st->cntx_name, arg);
1562
}
1563
1564
static void
1565
xattr_acls_a_coder (struct tar_stat_info const *st , char const *keyword,
1566
                    struct xheader *xhdr, void const *data)
1567
{
1568
  xheader_print_n (xhdr, keyword, st->acls_a_ptr, st->acls_a_len);
1569
}
1570
1571
static void
1572
xattr_acls_a_decoder (struct tar_stat_info *st,
1573
                      char const *keyword, char const *arg, size_t size)
1574
{
1575
  st->acls_a_ptr = xmemdup (arg, size + 1);
1576
  st->acls_a_len = size;
1577
}
1578
1579
static void
1580
xattr_acls_d_coder (struct tar_stat_info const *st , char const *keyword,
1581
                    struct xheader *xhdr, void const *data)
1582
{
1583
  xheader_print_n (xhdr, keyword, st->acls_d_ptr, st->acls_d_len);
1584
}
1585
1586
static void
1587
xattr_acls_d_decoder (struct tar_stat_info *st,
1588
                      char const *keyword, char const *arg, size_t size)
1589
{
1590
  st->acls_d_ptr = xmemdup (arg, size + 1);
1591
  st->acls_d_len = size;
1592
}
1593
1594
static void
1595
xattr_coder (struct tar_stat_info const *st , char const *keyword,
1596
             struct xheader *xhdr, void const *data)
1597
{
1598
  struct xattr_array *xattr_map = st->xattr_map;
1599
  const size_t *off = data;
1600
  xheader_print_n (xhdr, keyword,
1601
                   xattr_map[*off].xval_ptr, xattr_map[*off].xval_len);
1602
}
1603
1604
static void
1605
xattr_decoder (struct tar_stat_info *st,
1606
               char const *keyword, char const *arg, size_t size)
1607
{
1608
  char *xstr = NULL;
1609
1610
  xstr = xmemdup(arg, size + 1);
1611
  xheader_xattr_add(st, keyword + strlen("SCHILY.xattr."), xstr, size);
1612
  free(xstr);
1613
}
1614
1615
static void
1473
sparse_major_coder (struct tar_stat_info const *st, char const *keyword,
1616
sparse_major_coder (struct tar_stat_info const *st, char const *keyword,
1474
		    struct xheader *xhdr, void const *data)
1617
		    struct xheader *xhdr, void const *data)
1475
{
1618
{
Lines 1506-1558 Link Here
1506
}
1649
}
1507
1650
1508
struct xhdr_tab const xhdr_tab[] = {
1651
struct xhdr_tab const xhdr_tab[] = {
1509
  { "atime",	atime_coder,	atime_decoder,	  0 },
1652
  { "atime",   atime_coder,    atime_decoder,    0, false },
1510
  { "comment",	dummy_coder,	dummy_decoder,	  0 },
1653
  { "comment", dummy_coder,    dummy_decoder,    0, false },
1511
  { "charset",	dummy_coder,	dummy_decoder,	  0 },
1654
  { "charset", dummy_coder,    dummy_decoder,    0, false },
1512
  { "ctime",	ctime_coder,	ctime_decoder,	  0 },
1655
  { "ctime",   ctime_coder,    ctime_decoder,    0, false },
1513
  { "gid",	gid_coder,	gid_decoder,	  0 },
1656
  { "gid",     gid_coder,      gid_decoder,      0, false },
1514
  { "gname",	gname_coder,	gname_decoder,	  0 },
1657
  { "gname",   gname_coder,    gname_decoder,    0, false },
1515
  { "linkpath", linkpath_coder, linkpath_decoder, 0 },
1658
  { "linkpath", linkpath_coder, linkpath_decoder, 0, false },
1516
  { "mtime",	mtime_coder,	mtime_decoder,	  0 },
1659
  { "mtime",   mtime_coder,    mtime_decoder,    0, false },
1517
  { "path",	path_coder,	path_decoder,	  0 },
1660
  { "path",    path_coder,     path_decoder,     0, false },
1518
  { "size",	size_coder,	size_decoder,	  0 },
1661
  { "size",    size_coder,     size_decoder,     0, false },
1519
  { "uid",	uid_coder,	uid_decoder,	  0 },
1662
  { "uid",     uid_coder,      uid_decoder,      0, false },
1520
  { "uname",	uname_coder,	uname_decoder,	  0 },
1663
  { "uname",   uname_coder,    uname_decoder,    0, false },
1521
1664
1522
  /* Sparse file handling */
1665
  /* Sparse file handling */
1523
  { "GNU.sparse.name",       path_coder, path_decoder,
1666
  { "GNU.sparse.name",       path_coder, path_decoder,
1524
    XHDR_PROTECTED },
1667
    XHDR_PROTECTED, false },
1525
  { "GNU.sparse.major",      sparse_major_coder, sparse_major_decoder,
1668
  { "GNU.sparse.major",      sparse_major_coder, sparse_major_decoder,
1526
    XHDR_PROTECTED },
1669
    XHDR_PROTECTED, false },
1527
  { "GNU.sparse.minor",      sparse_minor_coder, sparse_minor_decoder,
1670
  { "GNU.sparse.minor",      sparse_minor_coder, sparse_minor_decoder,
1528
    XHDR_PROTECTED },
1671
    XHDR_PROTECTED, false },
1529
  { "GNU.sparse.realsize",   sparse_size_coder, sparse_size_decoder,
1672
  { "GNU.sparse.realsize",   sparse_size_coder, sparse_size_decoder,
1530
    XHDR_PROTECTED },
1673
    XHDR_PROTECTED, false },
1531
  { "GNU.sparse.numblocks",  sparse_numblocks_coder, sparse_numblocks_decoder,
1674
  { "GNU.sparse.numblocks",  sparse_numblocks_coder, sparse_numblocks_decoder,
1532
    XHDR_PROTECTED },
1675
    XHDR_PROTECTED, false },
1533
1676
1534
  /* tar 1.14 - 1.15.90 keywords. */
1677
  /* tar 1.14 - 1.15.90 keywords. */
1535
  { "GNU.sparse.size",       sparse_size_coder, sparse_size_decoder,
1678
  { "GNU.sparse.size",       sparse_size_coder, sparse_size_decoder,
1536
    XHDR_PROTECTED },
1679
    XHDR_PROTECTED, false },
1537
  /* tar 1.14 - 1.15.1 keywords. Multiple instances of these appeared in 'x'
1680
  /* tar 1.14 - 1.15.1 keywords. Multiple instances of these appeared in 'x'
1538
     headers, and each of them was meaningful. It confilcted with POSIX specs,
1681
     headers, and each of them was meaningful. It confilcted with POSIX specs,
1539
     which requires that "when extended header records conflict, the last one
1682
     which requires that "when extended header records conflict, the last one
1540
     given in the header shall take precedence." */
1683
     given in the header shall take precedence." */
1541
  { "GNU.sparse.offset",     sparse_offset_coder, sparse_offset_decoder,
1684
  { "GNU.sparse.offset",     sparse_offset_coder, sparse_offset_decoder,
1542
    XHDR_PROTECTED },
1685
    XHDR_PROTECTED, false },
1543
  { "GNU.sparse.numbytes",   sparse_numbytes_coder, sparse_numbytes_decoder,
1686
  { "GNU.sparse.numbytes",   sparse_numbytes_coder, sparse_numbytes_decoder,
1544
    XHDR_PROTECTED },
1687
    XHDR_PROTECTED, false },
1545
  /* tar 1.15.90 keyword, introduced to remove the above-mentioned conflict. */
1688
  /* tar 1.15.90 keyword, introduced to remove the above-mentioned conflict. */
1546
  { "GNU.sparse.map",        NULL /* Unused, see pax_dump_header() */,
1689
  { "GNU.sparse.map",        NULL /* Unused, see pax_dump_header() */,
1547
    sparse_map_decoder, 0 },
1690
    sparse_map_decoder, 0, false },
1548
1691
1549
  { "GNU.dumpdir",           dumpdir_coder, dumpdir_decoder,
1692
  { "GNU.dumpdir",           dumpdir_coder, dumpdir_decoder,
1550
    XHDR_PROTECTED },
1693
    XHDR_PROTECTED, false },
1551
1694
1552
  /* Keeps the tape/volume label. May be present only in the global headers.
1695
  /* Keeps the tape/volume label. May be present only in the global headers.
1553
     Equivalent to GNUTYPE_VOLHDR.  */
1696
     Equivalent to GNUTYPE_VOLHDR.  */
1554
  { "GNU.volume.label", volume_label_coder, volume_label_decoder,
1697
  { "GNU.volume.label", volume_label_coder, volume_label_decoder,
1555
    XHDR_PROTECTED | XHDR_GLOBAL },
1698
    XHDR_PROTECTED | XHDR_GLOBAL, false },
1556
1699
1557
  /* These may be present in a first global header of the archive.
1700
  /* These may be present in a first global header of the archive.
1558
     They provide the same functionality as GNUTYPE_MULTIVOL header.
1701
     They provide the same functionality as GNUTYPE_MULTIVOL header.
Lines 1561-1571 Link Here
1561
     GNU.volume.offset keeps the offset of the start of this volume,
1704
     GNU.volume.offset keeps the offset of the start of this volume,
1562
     otherwise kept in oldgnu_header.offset.  */
1705
     otherwise kept in oldgnu_header.offset.  */
1563
  { "GNU.volume.filename", volume_label_coder, volume_filename_decoder,
1706
  { "GNU.volume.filename", volume_label_coder, volume_filename_decoder,
1564
    XHDR_PROTECTED | XHDR_GLOBAL },
1707
    XHDR_PROTECTED | XHDR_GLOBAL, false },
1565
  { "GNU.volume.size", volume_size_coder, volume_size_decoder,
1708
  { "GNU.volume.size", volume_size_coder, volume_size_decoder,
1566
    XHDR_PROTECTED | XHDR_GLOBAL },
1709
    XHDR_PROTECTED | XHDR_GLOBAL, false },
1567
  { "GNU.volume.offset", volume_offset_coder, volume_offset_decoder,
1710
  { "GNU.volume.offset", volume_offset_coder, volume_offset_decoder,
1568
    XHDR_PROTECTED | XHDR_GLOBAL },
1711
    XHDR_PROTECTED | XHDR_GLOBAL, false },
1712
1713
  /* We get the SELinux value from filecon, so add a namespace for SELinux
1714
     instead of storing it in SCHILY.xattr.* (which would be RAW). */
1715
  { "RHT.security.selinux",
1716
    xattr_selinux_coder, xattr_selinux_decoder, 0, false },
1717
1718
  /* ACLs, use the star format... */
1719
  { "SCHILY.acl.access",
1720
    xattr_acls_a_coder, xattr_acls_a_decoder, 0, false },
1721
1722
  { "SCHILY.acl.default",
1723
    xattr_acls_d_coder, xattr_acls_d_decoder, 0, false },
1724
1725
  /* FIXME: These are compat. for FC-6 ... we shipped a tar using the generic
1726
     header names by accident. */
1727
  { "SCHILY.xattr.security.selinux",
1728
    xattr_selinux_coder, xattr_selinux_decoder, 0, false },
1729
  { "SCHILY.xattr.system.posix_acl_access",
1730
    xattr_acls_a_coder, xattr_acls_a_decoder, 0, false },
1731
  { "SCHILY.xattr.system.posix_acl_default",
1732
    xattr_acls_d_coder, xattr_acls_d_decoder, 0, false },
1733
1734
  /* xattrs use the star format.  note we only save some variants... */
1735
  { "SCHILY.xattr.user",    xattr_coder, xattr_decoder, 0, true },
1736
  { "SCHILY.xattr.trusted", xattr_coder, xattr_decoder, 0, true },
1737
  { "SCHILY.xattr.lustre",  xattr_coder, xattr_decoder, 0, true },
1738
  { "SCHILY.xattr.security.NTACL", xattr_coder, xattr_decoder, 0, true },
1739
1740
  /* ignore everything else in the xattr namespaces... */
1741
  { "SCHILY.xattr",         dummy_coder, dummy_decoder, 0, true },
1569
1742
1570
  { NULL, NULL, NULL, 0 }
1743
  { NULL, NULL, NULL, 0, false }
1571
};
1744
};

Return to bug 382067