4
0

onetop05.at 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # Process this file with autom4te to create testsuite. -*- Autotest -*-
  2. #
  3. # Test suite for GNU tar.
  4. # Copyright 2015-2016 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])
  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. genfile --file d/file
  31. tar -cf d.tar -C d .
  32. rm -rf d
  33. (mkdir d1
  34. chmod 700 d1
  35. cd d1
  36. tar --one-top-level=top -xpf ../d.tar)
  37. mode=$(genfile --stat=mode.777 d1)
  38. if test 700 = $mode; then
  39. echo "CWD: OK"
  40. else
  41. echo "CWD: mode changed: 700 != $mode"
  42. fi
  43. mkdir d2
  44. chmod 700 d2
  45. tar -C d2 --one-top-level=top -xpf d.tar
  46. mode=$(genfile --stat=mode.777 d2)
  47. if test 700 = $mode; then
  48. echo "DIR: OK"
  49. else
  50. echo "DIR: mode changed: 700 != $mode"
  51. fi
  52. mode=$(genfile --stat=mode.7777 d2/top)
  53. if test $mode = $orig_mode; then
  54. echo "TOP: OK"
  55. else
  56. echo "TOP: mode changed: $orig_mode != $mode"
  57. fi
  58. ],
  59. [0],
  60. [CWD: OK
  61. DIR: OK
  62. TOP: OK
  63. ])
  64. AT_CLEANUP