onetop05.at 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # Process this file with autom4te to create testsuite. -*- Autotest -*-
  2. #
  3. # Test suite for GNU tar.
  4. # Copyright 2015-2023 Free Software Foundation, Inc.
  5. #
  6. # This file is part of GNU tar.
  7. #
  8. # GNU tar is free software; you can redistribute it and/or modify
  9. # it under the terms of the GNU General Public License as published by
  10. # the Free Software Foundation; either version 3 of the License, or
  11. # (at your option) any later version.
  12. #
  13. # GNU tar is distributed in the hope that it will be useful,
  14. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. # GNU General Public License for more details.
  17. #
  18. # You should have received a copy of the GNU General Public License
  19. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. #
  21. AT_SETUP([tar --one-top-level restoring permissions])
  22. AT_KEYWORDS([extract onetop onetop05 chdir])
  23. # When extracting an archive that contains ./ with the --one-top-level option,
  24. # the mode and ownership of ./ would be incorrectly applied to the current
  25. # working directory, instead of the requested top-level directory.
  26. AT_TAR_CHECK([
  27. orig_mode=3702
  28. mkdir d
  29. chmod $orig_mode d
  30. mode=$(genfile --stat=mode.7777 d)
  31. test $mode = $orig_mode || AT_SKIP_TEST
  32. genfile --file d/file
  33. tar -cf d.tar -C d .
  34. rm -rf d
  35. (mkdir d1
  36. chmod 700 d1
  37. cd d1
  38. tar --one-top-level=top -xpf ../d.tar)
  39. mode=$(genfile --stat=mode.777 d1)
  40. if test 700 = $mode; then
  41. echo "CWD: OK"
  42. else
  43. echo "CWD: mode changed: 700 != $mode"
  44. fi
  45. mkdir d2
  46. chmod 700 d2
  47. tar -C d2 --one-top-level=top -xpf d.tar
  48. mode=$(genfile --stat=mode.777 d2)
  49. if test 700 = $mode; then
  50. echo "DIR: OK"
  51. else
  52. echo "DIR: mode changed: 700 != $mode"
  53. fi
  54. mode=$(genfile --stat=mode.7777 d2/top)
  55. if test $mode = $orig_mode; then
  56. echo "TOP: OK"
  57. else
  58. echo "TOP: mode changed: $orig_mode != $mode"
  59. fi
  60. ],
  61. [0],
  62. [CWD: OK
  63. DIR: OK
  64. TOP: OK
  65. ])
  66. AT_CLEANUP