acls03.at 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. # Process this file with autom4te to create testsuite. -*- Autotest -*-
  2. #
  3. # Test suite for GNU tar.
  4. # Copyright 2013-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:
  18. #
  19. # Check the storing/restoring with/without default ACLs. When --acls is passed,
  20. # restored directory tree should always match archive contents (even when the
  21. # archive does not contain any ACLs).
  22. #
  23. # References:
  24. # http://www.mail-archive.com/[email protected]/msg04355.html
  25. AT_SETUP([acls: default ACLs])
  26. AT_KEYWORDS([xattrs acls acls03 chdir])
  27. m4_define([ACL_LISTDIR], [
  28. cd $1
  29. $1="$(find d1 | sort | xargs -n 1 getfacl)"
  30. cd ..
  31. ])
  32. m4_define([ACL_ASSERT], [
  33. echo "$$1" > $1.log
  34. echo "$$2" > $2.log
  35. if test ! "$$1" "$3" "$$2"; then
  36. echo "bad '$1' against '$2' output"
  37. fi
  38. ])
  39. AT_TAR_CHECK([
  40. AT_XATTRS_UTILS_PREREQ
  41. AT_ACLS_PREREQ
  42. AT_SORT_PREREQ
  43. MYNAME=$( id -un )
  44. MYGROUP=$( id -gn )
  45. # Prepare directory structure with default ACLs
  46. mkdir -p pure/d1/d2
  47. genfile --file pure/d1/f2a
  48. genfile --file pure/d1/f2b
  49. genfile --file pure/d1/d2/f3a
  50. genfile --file pure/d1/d2/f3b
  51. setfacl -m g:$MYGROUP:r-x pure/d1
  52. setfacl -d -m g:$MYGROUP:rwx pure/d1
  53. setfacl -d -m u:$MYNAME:rwx pure/d1
  54. # "*a" files have "some" additional ACLs
  55. setfacl -m u:$MYNAME:--- pure/d1/d2/f3a
  56. setfacl -m u:$MYNAME:--- pure/d1/f2a
  57. # use default format (no acls stored)
  58. tar -cf noacl.tar -C pure d1
  59. # use posix format, acls stored
  60. tar --acls -cf acl.tar -C pure d1
  61. # Directory names are chosen based on "how the files were extracted from
  62. # archive". Equivalent no* tags are used also:
  63. # ^sacl_ — extracted archive has stored ACLs
  64. # _def_ — target directory (-C) has default ACLs
  65. # _optacl$ — extraction was done with --acls option
  66. mkdir sacl_def_optacl
  67. mkdir sacl_def_optnoacl
  68. mkdir sacl_nodef_optacl
  69. mkdir sacl_nodef_optnoacl
  70. mkdir nosacl_def_optacl
  71. mkdir nosacl_def_optnoacl
  72. mkdir nosacl_nodef_optacl
  73. mkdir nosacl_nodef_optnoacl
  74. setfacl -d -m u:$MYNAME:--- nosacl_def_optnoacl sacl_def_optnoacl sacl_def_optacl nosacl_def_optacl
  75. setfacl -d -m g:$MYGROUP:--- nosacl_def_optnoacl sacl_def_optnoacl sacl_def_optacl nosacl_def_optacl
  76. tar -xf acl.tar -C sacl_nodef_optnoacl
  77. tar --acls -xf acl.tar -C sacl_nodef_optacl
  78. tar -xf acl.tar -C sacl_def_optnoacl
  79. tar --acls -xf acl.tar -C sacl_def_optacl
  80. tar -xf noacl.tar -C nosacl_def_optnoacl
  81. # _NO_ ACLs in output
  82. tar -xf noacl.tar -C nosacl_nodef_optnoacl
  83. tar -xf noacl.tar -C nosacl_nodef_optacl
  84. tar -cf noacl_repackaged.tar -C nosacl_nodef_optnoacl d1
  85. # _NO_ ACLs in output (even when default ACLs exist)
  86. tar --acls -xf noacl_repackaged.tar -C nosacl_def_optacl
  87. ACL_LISTDIR(pure)
  88. ACL_LISTDIR(sacl_def_optacl)
  89. ACL_LISTDIR(sacl_def_optnoacl)
  90. ACL_LISTDIR(sacl_nodef_optacl)
  91. ACL_LISTDIR(sacl_nodef_optnoacl)
  92. ACL_LISTDIR(nosacl_def_optacl)
  93. ACL_LISTDIR(nosacl_def_optnoacl)
  94. ACL_LISTDIR(nosacl_nodef_optacl)
  95. ACL_LISTDIR(nosacl_nodef_optnoacl)
  96. ACL_ASSERT(pure, sacl_def_optacl, =)
  97. ACL_ASSERT(sacl_def_optacl, sacl_nodef_optacl, =)
  98. ACL_ASSERT(sacl_def_optnoacl, nosacl_def_optnoacl, =)
  99. ACL_ASSERT(sacl_nodef_optnoacl, nosacl_nodef_optnoacl, =)
  100. ACL_ASSERT(nosacl_def_optacl, nosacl_nodef_optacl, =)
  101. ACL_ASSERT(nosacl_def_optacl, nosacl_nodef_optnoacl, =)
  102. ACL_ASSERT(sacl_def_optacl, sacl_def_optnoacl, !=)
  103. ACL_ASSERT(sacl_def_optacl, nosacl_def_optnoacl, !=)
  104. ACL_ASSERT(nosacl_def_optnoacl, nosacl_nodef_optnoacl, !=)
  105. ],
  106. [0],
  107. [],
  108. [])
  109. AT_CLEANUP