capabs_raw01.at 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. # Process this file with autom4te to create testsuite. -*- Autotest -*-
  2. #
  3. # Test suite for GNU tar.
  4. # Copyright 2012-2023 Free Software Foundation, Inc.
  5. # This file is part of GNU tar.
  6. # GNU tar is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU General Public License as published by
  8. # the Free Software Foundation; either version 3 of the License, or
  9. # (at your option) any later version.
  10. # GNU tar is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. #
  17. # Test description: Test if file capabilities are archived/restored correctly
  18. # using just the default xattr support (capabilities are stored/restored in
  19. # binary format -> system dependent).
  20. AT_SETUP([capabilities: binary store/restore])
  21. AT_KEYWORDS([xattrs capabilities capabs_raw01])
  22. AT_TAR_CHECK([
  23. AT_PRIVILEGED_PREREQ
  24. AT_XATTRS_PREREQ
  25. AT_CAPABILITIES_UTILS_PREREQ
  26. mkdir dir
  27. genfile --file dir/file
  28. setcap "= cap_chown=ei" dir/file
  29. # archive whole directory including binary xattrs
  30. tar --xattrs -cf archive.tar dir
  31. # clear the directory
  32. rm -rf dir
  33. # restore _all_ xattrs (not just the user.* domain)
  34. tar --xattrs --xattrs-include='*' -xf archive.tar
  35. # Newer systems print = instead of + here
  36. getcap dir/file | sed 's/+/=/'
  37. ],
  38. [0],
  39. [dir/file = cap_chown=ei
  40. ])
  41. AT_CLEANUP