Add basic suuport for extended attributes.
* src/Makefile.am: Add xattrs.[ch] * src/xattrs.c: New file. * src/xattrs.h: New file. * src/common.h (READ_LIKE_SUBCOMMAND): New define. (selinux_context_option, acls_option, xattrs_option): New globals. (xheader_xattr_init, xheader_xattr_free) (xheader_xattr_copy, xheader_xattr_add): New protos. (WARN_XATTR_WRITE): New mask. * src/create.c (start_header): Handle xattrs pairs if in POSIX format. (dump_file0): Handle extended attributes. * src/extract.c (delayed_set_stat,delayed_link) <xattr_map_size> <xattr_map>: New members. (set_xattr): New static function. (open_output_file): Accept an additional argument indicating whether the file has already been created. (set_stat,delay_set_stat) (apply_nonancestor_delayed_set_stat) (extract_file): Handle extended attributes. * src/list.c (decode_header, simple_print_header): Display extended attributes. * src/tar.c: New options --xattrs, --no-xattrs, --xattrs-include, --xattrs-exclude (tar_stat_destroy): Free the xattr_map storage. * src/tar.h (xattr_array): New struct. (tar_stat_info) <xattr_map_size, xattr_map>: New members. * src/warning.c: New warning control keyword "xattr-write". * src/xheader.c (xheader_xattr_init) (xheader_xattr_free, xheader_xattr_add) (xheader_xattr_copy): New functions. (struct xhdr_tab) <prefix>: New member. (locate_handler): Permit selecting the keyword based on its prefix. (xheader_protected_pattern_p) (xheader_protected_keyword_p): Likewise. (xattr_coder, xattr_decoder): New functions. (xhdr_tab): Reflect the changes to struct xhdr_tab. New keyword "SCHILY.xattr". * tests/Makefile.am: Add new tests. * tests/testsuite.at: Likewise. (AT_CHECK_UTIL, AT_XATTRS_UTILS_PREREQ) (AT_CAPABILITIES_UTILS_PREREQ, AT_XATTRS_PREREQ): New defuns. * tests/xattr01.at: New test. * tests/xattr02.at: New test. * tests/xattr03.at: New test. * tests/xattr04.at: New test. * tests/capabs_raw01.at: New test.
This commit is contained in:
committed by
Sergey Poznyakoff
parent
b997c90f9e
commit
696338043e
@@ -1,7 +1,7 @@
|
||||
# Makefile for GNU tar regression tests.
|
||||
|
||||
# Copyright (C) 1996, 1997, 1999, 2000, 2001, 2003, 2004, 2005,
|
||||
# 2006, 2007, 2009 Free Software Foundation, Inc.
|
||||
# 2006, 2007, 2009, 2012 Free Software Foundation, Inc.
|
||||
|
||||
# François Pinard <pinard@iro.umontreal.ca>, 1988.
|
||||
# Sergey Poznyakoff <gray@mirddin.farlep.net>, 2004.
|
||||
@@ -173,7 +173,12 @@ TESTSUITE_AT = \
|
||||
star/multi-fail.at\
|
||||
star/ustar-big-2g.at\
|
||||
star/ustar-big-8g.at\
|
||||
star/pax-big-10g.at
|
||||
star/pax-big-10g.at\
|
||||
xattr01.at\
|
||||
xattr02.at\
|
||||
xattr03.at\
|
||||
xattr04.at\
|
||||
capabs_raw01.at
|
||||
|
||||
TESTSUITE = $(srcdir)/testsuite
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Process this file with autom4te to create testsuite. -*- Autotest -*-
|
||||
|
||||
# Test suite for GNU tar.
|
||||
# Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Free Software
|
||||
# Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010, 2012 Free Software
|
||||
# Foundation, Inc.
|
||||
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
@@ -117,6 +117,36 @@ m4_define([AT_TAR_MKHIER],[
|
||||
install-sh -d $1 >/dev/null dnl
|
||||
m4_if([$2],,,&& genfile --file [$1]/[$2]) || AT_SKIP_TEST])
|
||||
|
||||
dnl Skip test when utlity does not return expected return value
|
||||
m4_define([AT_CHECK_UTIL],[
|
||||
$1 &> /dev/null
|
||||
if test "$?" != $2; then
|
||||
AT_SKIP_TEST
|
||||
fi
|
||||
])
|
||||
|
||||
m4_define([AT_XATTRS_UTILS_PREREQ],[
|
||||
file=$( mktemp -p . )
|
||||
AT_CHECK_UTIL(setfattr -n user.test -v test $file,0)
|
||||
AT_CHECK_UTIL(getfattr $file,0)
|
||||
])
|
||||
m4_define([AT_CAPABILITIES_UTILS_PREREQ],[
|
||||
file=$( mktemp -p . )
|
||||
AT_CHECK_UTIL(setcap "= cap_chown=ei" $file,0)
|
||||
AT_CHECK_UTIL(getcap $file,0)
|
||||
rm -rf $file
|
||||
])
|
||||
m4_define([AT_XATTRS_PREREQ],[
|
||||
AT_XATTRS_UTILS_PREREQ
|
||||
file=$( mktemp -p . )
|
||||
setfattr -n user.test -v ahoj $file
|
||||
# check whether tar fails to store xattrs
|
||||
err=$( tar --xattrs -cf /dev/null $file 2>&1 >/dev/null | wc -l )
|
||||
if test "$err" != "0"; then
|
||||
AT_SKIP_TEST
|
||||
fi
|
||||
])
|
||||
|
||||
m4_include([sparsemvp.at])
|
||||
|
||||
AT_INIT
|
||||
@@ -284,3 +314,10 @@ m4_include([star/ustar-big-2g.at])
|
||||
m4_include([star/ustar-big-8g.at])
|
||||
|
||||
m4_include([star/pax-big-10g.at])
|
||||
|
||||
m4_include([xattr01.at])
|
||||
m4_include([xattr02.at])
|
||||
m4_include([xattr03.at])
|
||||
m4_include([xattr04.at])
|
||||
|
||||
m4_include([capabs_raw01.at])
|
||||
|
||||
Reference in New Issue
Block a user