Prepare for implementing extended attribute support.
This patch adds *xattr() stubs in case extended attribute support is not present and implements the *attrat() family of functions. Based on the patch by Pavel Raiskup <pavel@raiskup.cz> for gnulib. * acinclude.m4 (TAR_HEADERS_ATTR_XATTR_H): New defun. * configure.ac: Call TAR_HEADERS_ATTR_XATTR_H * lib/Makefile.am: Add xattr-at.[ch], distribute attr-xattr.in.h [!TAR_COND_XATTR_H]: Build attr/xattr.h * lib/attr-xattr.in.h: New file. * lib/xattr-at.c: New file. * lib/xattr-at.h: New file.
This commit is contained in:
26
acinclude.m4
26
acinclude.m4
@@ -24,3 +24,29 @@ AC_DEFUN([TAR_COMPR_PROGRAM],[
|
||||
[tar_compr_var=m4_if($2,,$1,$2)])
|
||||
AC_DEFINE_UNQUOTED(tar_compr_define, "$tar_compr_var",
|
||||
[Define to the program name of ]$1[ compressor program])])
|
||||
|
||||
# Provide <attr/xattr.h>, if necessary
|
||||
|
||||
AC_DEFUN([TAR_HEADERS_ATTR_XATTR_H],
|
||||
[
|
||||
AC_ARG_WITH([xattrs],
|
||||
AS_HELP_STRING([--without-xattrs], [don't use linux extended attributes]),
|
||||
[], [with_xattrs=maybe]
|
||||
)
|
||||
|
||||
AC_CHECK_HEADERS([attr/xattr.h])
|
||||
AM_CONDITIONAL([TAR_COND_XATTR_H],[test "$ac_cv_header_attr_xattr_h" = yes])
|
||||
if test "$ac_cv_header_attr_xattr_h" = yes; then
|
||||
AC_CHECK_FUNCS(getxattr fgetxattr lgetxattr \
|
||||
setxattr fsetxattr lsetxattr \
|
||||
listxattr flistxattr llistxattr,
|
||||
# only when functions are present
|
||||
AC_DEFINE([HAVE_ATTR_XATTR_H], [1],
|
||||
[define to 1 if we have <attr/xattr.h> header])
|
||||
if test "$with_xattrs" != no; then
|
||||
AC_DEFINE([HAVE_XATTRS],,[Define when we have working linux xattrs.])
|
||||
fi
|
||||
)
|
||||
fi
|
||||
])
|
||||
|
||||
@@ -90,6 +90,8 @@ gl_INIT
|
||||
# paxutils modules
|
||||
tar_PAXUTILS
|
||||
|
||||
TAR_HEADERS_ATTR_XATTR_H
|
||||
|
||||
AC_CHECK_FUNCS_ONCE([fchmod fchown fsync lstat mkfifo readlink symlink])
|
||||
AC_CHECK_DECLS([getgrgid],,, [#include <grp.h>])
|
||||
AC_CHECK_DECLS([getpwuid],,, [#include <pwd.h>])
|
||||
|
||||
@@ -28,11 +28,24 @@ BUILT_SOURCES = rmt-command.h
|
||||
CLEANFILES = rmt-command.h rmt-command.h-t
|
||||
INCLUDES = -I$(top_srcdir)/gnu -I../ -I../gnu
|
||||
|
||||
noinst_HEADERS = system.h system-ioctl.h rmt.h paxlib.h stdopen.h
|
||||
noinst_HEADERS = system.h system-ioctl.h rmt.h paxlib.h stdopen.h xattr-at.h
|
||||
libtar_a_SOURCES = \
|
||||
paxerror.c paxexit-status.c paxlib.h paxnames.c \
|
||||
prepargs.c prepargs.h \
|
||||
rtapelib.c \
|
||||
rmt.h \
|
||||
stdopen.c stdopen.h \
|
||||
system.h system-ioctl.h
|
||||
system.h system-ioctl.h \
|
||||
xattr-at.c
|
||||
|
||||
if !TAR_COND_XATTR_H
|
||||
BUILT_SOURCES += attr/xattr.h
|
||||
attr/xattr.h: attr-xattr.in.h $(top_builddir)/config.status
|
||||
$(AM_V_at)$(MKDIR_P) attr
|
||||
$(AM_V_GEN)rm -f $@-t $@ && \
|
||||
cp $(srcdir)/attr-xattr.in.h attr/xattr.h
|
||||
|
||||
MOSTLYCLEANFILES = attr/xattr.h attr/xattr.h
|
||||
endif
|
||||
|
||||
EXTRA_DIST = attr-xattr.in.h
|
||||
|
||||
58
lib/attr-xattr.in.h
Normal file
58
lib/attr-xattr.in.h
Normal file
@@ -0,0 +1,58 @@
|
||||
/* Replacement <attr/xattr.h> for platforms that lack it.
|
||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 3 of the License, 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef TAR_ATTR_XATTR_H
|
||||
#define TAR_ATTR_XATTR_H
|
||||
#include <errno.h>
|
||||
|
||||
/* setting */
|
||||
static inline int setxattr (const char *path, const char *name, const void
|
||||
*value, size_t size, int flags)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
|
||||
static inline int lsetxattr (const char *path, const char *name, const void
|
||||
*value, size_t size, int flags)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
|
||||
static inline int fsetxattr (int filedes, const char *name, const void *value,
|
||||
size_t size, int flags)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
|
||||
|
||||
/* getting */
|
||||
static inline ssize_t getxattr (const char *path, const char *name, void *value,
|
||||
size_t size)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
static inline ssize_t lgetxattr (const char *path, const char *name, void
|
||||
*value, size_t size)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
static inline ssize_t fgetxattr (int filedes, const char *name, void *value,
|
||||
size_t size)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
|
||||
|
||||
/* listing */
|
||||
static inline ssize_t listxattr (const char *path, char *list, size_t size)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
|
||||
static inline ssize_t llistxattr (const char *path, char *list, size_t size)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
|
||||
static inline ssize_t flistxattr (int filedes, char *list, size_t size)
|
||||
{ errno = ENOTSUP; return -1; }
|
||||
|
||||
#endif
|
||||
|
||||
110
lib/xattr-at.c
Normal file
110
lib/xattr-at.c
Normal file
@@ -0,0 +1,110 @@
|
||||
/* openat-style fd-relative functions for operating with extended file
|
||||
attributes.
|
||||
|
||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "xattr-at.h"
|
||||
#include "openat.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "dirname.h" /* solely for definition of IS_ABSOLUTE_FILE_NAME */
|
||||
#include "save-cwd.h"
|
||||
|
||||
#include "openat-priv.h"
|
||||
|
||||
/* setxattrat */
|
||||
#define AT_FUNC_NAME setxattrat
|
||||
#define AT_FUNC_F1 setxattr
|
||||
#define AT_FUNC_POST_FILE_PARAM_DECLS , const char *name, const void *value \
|
||||
, size_t size, int flags
|
||||
#define AT_FUNC_POST_FILE_ARGS , name, value, size, flags
|
||||
#include "at-func.c"
|
||||
#undef AT_FUNC_NAME
|
||||
#undef AT_FUNC_F1
|
||||
#undef AT_FUNC_POST_FILE_PARAM_DECLS
|
||||
#undef AT_FUNC_POST_FILE_ARGS
|
||||
|
||||
/* lsetxattrat */
|
||||
#define AT_FUNC_NAME lsetxattrat
|
||||
#define AT_FUNC_F1 lsetxattr
|
||||
#define AT_FUNC_POST_FILE_PARAM_DECLS , const char *name, const void *value \
|
||||
, size_t size, int flags
|
||||
#define AT_FUNC_POST_FILE_ARGS , name, value, size, flags
|
||||
#include "at-func.c"
|
||||
#undef AT_FUNC_NAME
|
||||
#undef AT_FUNC_F1
|
||||
#undef AT_FUNC_POST_FILE_PARAM_DECLS
|
||||
#undef AT_FUNC_POST_FILE_ARGS
|
||||
|
||||
/* getxattrat */
|
||||
#define AT_FUNC_NAME getxattrat
|
||||
#define AT_FUNC_RESULT ssize_t
|
||||
#define AT_FUNC_F1 getxattr
|
||||
#define AT_FUNC_POST_FILE_PARAM_DECLS , const char *name, void *value \
|
||||
, size_t size
|
||||
#define AT_FUNC_POST_FILE_ARGS , name, value, size
|
||||
#include "at-func.c"
|
||||
#undef AT_FUNC_NAME
|
||||
#undef AT_FUNC_F1
|
||||
#undef AT_FUNC_RESULT
|
||||
#undef AT_FUNC_POST_FILE_PARAM_DECLS
|
||||
#undef AT_FUNC_POST_FILE_ARGS
|
||||
|
||||
/* lgetxattrat */
|
||||
#define AT_FUNC_NAME lgetxattrat
|
||||
#define AT_FUNC_RESULT ssize_t
|
||||
#define AT_FUNC_F1 lgetxattr
|
||||
#define AT_FUNC_POST_FILE_PARAM_DECLS , const char *name, void *value \
|
||||
, size_t size
|
||||
#define AT_FUNC_POST_FILE_ARGS , name, value, size
|
||||
#include "at-func.c"
|
||||
#undef AT_FUNC_NAME
|
||||
#undef AT_FUNC_F1
|
||||
#undef AT_FUNC_RESULT
|
||||
#undef AT_FUNC_POST_FILE_PARAM_DECLS
|
||||
#undef AT_FUNC_POST_FILE_ARGS
|
||||
|
||||
/* listxattrat */
|
||||
#define AT_FUNC_NAME listxattrat
|
||||
#define AT_FUNC_RESULT ssize_t
|
||||
#define AT_FUNC_F1 listxattr
|
||||
#define AT_FUNC_POST_FILE_PARAM_DECLS , char *list , size_t size
|
||||
#define AT_FUNC_POST_FILE_ARGS , list , size
|
||||
#include "at-func.c"
|
||||
#undef AT_FUNC_NAME
|
||||
#undef AT_FUNC_F1
|
||||
#undef AT_FUNC_RESULT
|
||||
#undef AT_FUNC_POST_FILE_PARAM_DECLS
|
||||
#undef AT_FUNC_POST_FILE_ARGS
|
||||
|
||||
/* llistxattrat */
|
||||
#define AT_FUNC_NAME llistxattrat
|
||||
#define AT_FUNC_RESULT ssize_t
|
||||
#define AT_FUNC_F1 llistxattr
|
||||
#define AT_FUNC_POST_FILE_PARAM_DECLS , char *list , size_t size
|
||||
#define AT_FUNC_POST_FILE_ARGS , list , size
|
||||
#include "at-func.c"
|
||||
#undef AT_FUNC_NAME
|
||||
#undef AT_FUNC_F1
|
||||
#undef AT_FUNC_RESULT
|
||||
#undef AT_FUNC_POST_FILE_PARAM_DECLS
|
||||
#undef AT_FUNC_POST_FILE_ARGS
|
||||
66
lib/xattr-at.h
Normal file
66
lib/xattr-at.h
Normal file
@@ -0,0 +1,66 @@
|
||||
/* Prototypes for openat-style fd-relative functions for operating with
|
||||
extended file attributes.
|
||||
|
||||
Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, 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 General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#ifndef XATTRS_AT_H
|
||||
#define XATTRS_AT_H
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <attr/xattr.h>
|
||||
|
||||
/* These are the dir-fd-relative variants of the functions without the
|
||||
"at" suffix. For example, setxattrat (AT_FDCWD, path, name, value, size,
|
||||
flags &c) is usually equivalent to setxattr (file, name, value, size,
|
||||
flags). For more info use the setxattr(2), getxattr(2) or listxattr(2)
|
||||
manpages. */
|
||||
|
||||
/* dir-fd-relative setxattr. Operation sets the VALUE of the extended
|
||||
attribute identified by NAME and associated with the given PATH in the
|
||||
filesystem relatively to directory identified by DIR_FD. See the
|
||||
setxattr(2) manpage for the description of all parameters. */
|
||||
int setxattrat (int dir_fd, const char *path, const char *name,
|
||||
const void *value, size_t size, int flags);
|
||||
|
||||
/* dir-fd-relative lsetxattr. This function is just like setxattrat,
|
||||
except when DIR_FD and FILE specify a symlink: lsetxattrat operates on the
|
||||
symlink, while the setxattrat operates on the referent of the symlink. */
|
||||
int lsetxattrat (int dir_fd, const char *path, const char *name,
|
||||
const void *value, size_t size, int flags);
|
||||
|
||||
/* dir-fd-relative getxattr. Operation gets the VALUE of the extended
|
||||
attribute idenfified by NAME and associated with the given PATH in the
|
||||
filesystem relatively to directory identified by DIR_FD. For more info
|
||||
about all parameters see the getxattr(2) manpage. */
|
||||
ssize_t getxattrat (int dir_fd, const char *path, const char *name,
|
||||
void *value, size_t size);
|
||||
|
||||
/* dir-fd-relative lgetxattr. This function is just like getxattrat,
|
||||
except when DIR_FD and FILE specify a symlink: lgetxattrat operates on the
|
||||
symlink, while the getxattrat operates on the referent of the symlink. */
|
||||
ssize_t lgetxattrat (int dir_fd, const char *path, const char *name,
|
||||
void *value, size_t size);
|
||||
|
||||
/* dir-fd-relative listxattr. Obtain the list of extended attrubtes names. For
|
||||
more info see the listxattr(2) manpage. */
|
||||
ssize_t listxattrat (int dir_fd, const char *path, char *list, size_t size);
|
||||
|
||||
/* dir-fd-relative llistxattr. This function is just like listxattrat,
|
||||
except when DIR_FD and FILE specify a symlink: llistxattr operates on the
|
||||
symlink, while the listxattrat operates on the referent of the symlink. */
|
||||
ssize_t llistxattrat (int dir_fd, const char *path, char *list, size_t size);
|
||||
|
||||
#endif /* XATTRS_AT_H */
|
||||
51
tests/capabs_raw01.at
Normal file
51
tests/capabs_raw01.at
Normal file
@@ -0,0 +1,51 @@
|
||||
# Process this file with autom4te to create testsuite. -*- Autotest -*-
|
||||
#
|
||||
# Test suite for GNU tar.
|
||||
# Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3, 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Test description: Test if file capabilities are archived/restored correctly
|
||||
# using just the default xattr support (capabilities are stored/restored in
|
||||
# binary format -> system dependant).
|
||||
|
||||
AT_SETUP([capabilities: binary store/restore])
|
||||
AT_KEYWORDS([xattrs capabilities capabs_raw01])
|
||||
|
||||
AT_TAR_CHECK([
|
||||
AT_PRIVILEGED_PREREQ
|
||||
AT_XATTRS_PREREQ
|
||||
AT_CAPABILITIES_UTILS_PREREQ
|
||||
|
||||
mkdir dir
|
||||
genfile --file dir/file
|
||||
|
||||
setcap "= cap_chown=ei" dir/file
|
||||
|
||||
# archive whole directory including binary xattrs
|
||||
tar --xattrs -cf archive.tar dir
|
||||
|
||||
# clear the directory
|
||||
rm -rf dir
|
||||
|
||||
# restore _all_ xattrs (not just the user.* domain)
|
||||
tar --xattrs --xattrs-include='*' -xf archive.tar
|
||||
|
||||
getcap dir/file
|
||||
],
|
||||
[0],
|
||||
[dir/file = cap_chown+ei
|
||||
])
|
||||
|
||||
AT_CLEANUP
|
||||
47
tests/xattr01.at
Normal file
47
tests/xattr01.at
Normal file
@@ -0,0 +1,47 @@
|
||||
# Process this file with autom4te to create testsuite. -*- Autotest -*-
|
||||
#
|
||||
# Test suite for GNU tar.
|
||||
# Copyright (C) 2011 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3, 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Test description:
|
||||
#
|
||||
# This is basic test for support of extended attributes.
|
||||
|
||||
AT_SETUP([xattrs: basic functionality])
|
||||
AT_KEYWORDS([xattrs xattr01])
|
||||
|
||||
AT_TAR_CHECK([
|
||||
AT_XATTRS_PREREQ
|
||||
mkdir dir
|
||||
genfile --file dir/file
|
||||
|
||||
setfattr -n user.test -v OurDirValue dir
|
||||
setfattr -n user.test -v OurFileValue dir/file
|
||||
|
||||
tar --xattrs -cf archive.tar dir
|
||||
|
||||
rm -rf dir
|
||||
tar --xattrs -xf archive.tar
|
||||
|
||||
getfattr -h -d dir | grep -v -e '^#' -e ^$
|
||||
getfattr -h -d dir/file | grep -v -e '^#' -e ^$
|
||||
],
|
||||
[0],
|
||||
[user.test="OurDirValue"
|
||||
user.test="OurFileValue"
|
||||
])
|
||||
|
||||
AT_CLEANUP
|
||||
55
tests/xattr02.at
Normal file
55
tests/xattr02.at
Normal file
@@ -0,0 +1,55 @@
|
||||
# Process this file with autom4te to create testsuite. -*- Autotest -*-
|
||||
#
|
||||
# Test suite for GNU tar.
|
||||
# Copyright (C) 2011 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3, 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Test description:
|
||||
#
|
||||
# Cooperation of the '-C' option and storing/restoring extended attributes.
|
||||
|
||||
AT_SETUP([xattrs: change directory with -C option])
|
||||
AT_KEYWORDS([xattrs xattr02])
|
||||
|
||||
AT_TAR_CHECK([
|
||||
AT_XATTRS_PREREQ
|
||||
|
||||
mkdir dir
|
||||
mkdir dir/subdir
|
||||
mkdir dir/subdir/subsubdir
|
||||
genfile --file dir/file1
|
||||
genfile --file dir/subdir/file2
|
||||
|
||||
setfattr -n user.test -v OurFile1Value dir/file1
|
||||
setfattr -n user.test -v OurFile2Value dir/subdir/file2
|
||||
setfattr -n user.test -v OurDirValue dir/subdir/subsubdir
|
||||
|
||||
tar --xattrs -cf archive.tar -C dir file1 -C subdir file2 subsubdir
|
||||
|
||||
rm -rf dir
|
||||
|
||||
tar --xattrs -xf archive.tar
|
||||
|
||||
getfattr -h -d file1 | grep -v -e '^#' -e ^$
|
||||
getfattr -h -d file2 | grep -v -e '^#' -e ^$
|
||||
getfattr -h -d subsubdir | grep -v -e '^#' -e ^$
|
||||
],
|
||||
[0],
|
||||
[user.test="OurFile1Value"
|
||||
user.test="OurFile2Value"
|
||||
user.test="OurDirValue"
|
||||
])
|
||||
|
||||
AT_CLEANUP
|
||||
56
tests/xattr03.at
Normal file
56
tests/xattr03.at
Normal file
@@ -0,0 +1,56 @@
|
||||
# Process this file with autom4te to create testsuite. -*- Autotest -*-
|
||||
#
|
||||
# Test suite for GNU tar.
|
||||
# Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3, 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Test description:
|
||||
#
|
||||
# Setup of the trusted.* domain under privileged user.
|
||||
|
||||
AT_SETUP([xattrs: trusted.* attributes])
|
||||
AT_KEYWORDS([xattrs xattr03])
|
||||
|
||||
AT_TAR_CHECK([
|
||||
AT_PRIVILEGED_PREREQ
|
||||
AT_XATTRS_PREREQ
|
||||
|
||||
mkdir dir
|
||||
mkdir dir/subdir
|
||||
mkdir dir/subdir/subsubdir
|
||||
genfile --file dir/file1
|
||||
genfile --file dir/subdir/file2
|
||||
|
||||
setfattr -n trusted.test -v OurFile1Value dir/file1
|
||||
setfattr -n trusted.test -v OurFile2Value dir/subdir/file2
|
||||
setfattr -n trusted.test -v OurDirValue dir/subdir/subsubdir
|
||||
|
||||
tar --xattrs -cf archive.tar -C dir file1 -C subdir file2 subsubdir
|
||||
|
||||
rm -rf dir
|
||||
|
||||
tar --xattrs --xattrs-include=trusted* -xf archive.tar
|
||||
|
||||
getfattr -mtrusted. -d file1 | grep -v -e '^#' -e ^$
|
||||
getfattr -mtrusted. -d file2 | grep -v -e '^#' -e ^$
|
||||
getfattr -mtrusted. -d subsubdir | grep -v -e '^#' -e ^$
|
||||
],
|
||||
[0],
|
||||
[trusted.test="OurFile1Value"
|
||||
trusted.test="OurFile2Value"
|
||||
trusted.test="OurDirValue"
|
||||
])
|
||||
|
||||
AT_CLEANUP
|
||||
48
tests/xattr04.at
Normal file
48
tests/xattr04.at
Normal file
@@ -0,0 +1,48 @@
|
||||
# Process this file with autom4te to create testsuite. -*- Autotest -*-
|
||||
#
|
||||
# Test suite for GNU tar.
|
||||
# Copyright (C) 2012 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3, 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 General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Test description: Test for the regression caused by tar update from 1.23 to
|
||||
# 1.26, Red Hat xattr patch was not ready for open->openat conversion.
|
||||
#
|
||||
# Related commit 4bde4f3. See the bug: https://bugzilla.redhat.com/717684
|
||||
|
||||
AT_SETUP([xattrs: s/open/openat/ regression])
|
||||
AT_KEYWORDS([xattrs xattr04])
|
||||
|
||||
AT_TAR_CHECK([
|
||||
AT_XATTRS_PREREQ
|
||||
|
||||
mkdir dir
|
||||
mkdir output
|
||||
genfile --file dir/file
|
||||
|
||||
setfattr -n user.test -v value dir/file
|
||||
|
||||
# archive whole directory including binary xattrs
|
||||
tar --xattrs -cf archive.tar -C dir .
|
||||
|
||||
tar --xattrs -xf archive.tar -C output
|
||||
ret=$?
|
||||
getfattr -h -d output/file | grep -v -e '^#' -e ^$
|
||||
exit $ret
|
||||
],
|
||||
[0],
|
||||
[user.test="value"
|
||||
])
|
||||
|
||||
AT_CLEANUP
|
||||
Reference in New Issue
Block a user