extrac23.at 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # Test suite for GNU tar. -*- Autotest -*-
  2. # Copyright 2020-2023 Free Software Foundation, Inc.
  3. #
  4. # This file is part of GNU tar.
  5. #
  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. #
  11. # GNU tar is distributed in the hope that it will be useful,
  12. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. # GNU General Public License for more details.
  15. #
  16. # You should have received a copy of the GNU General Public License
  17. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. AT_SETUP([--no-overwrite-dir])
  19. AT_KEYWORDS([extract extrac23 no-overwrite-dir])
  20. # Description: Implementation of the --no-overwrite-dir option was flawed in
  21. # tar versions up to 1.32.90. This option is intended to preserve metadata
  22. # of existing directories. In fact it worked only for non-empty directories.
  23. # Moreover, if the actual directory was owned by the user tar runs as and the
  24. # S_IWUSR bit was not set in its actual permissions, tar failed to create files
  25. # in it.
  26. #
  27. # Reported by: Michael Kaufmann <[email protected]>
  28. # References: <20200207112934.Horde.anXzYhAj2CHiwUrw5CuT0G-@webmail.michael-kaufmann.ch>,
  29. # https://lists.gnu.org/archive/html/bug-tar/2020-02/msg00003.html
  30. AT_TAR_CHECK([
  31. # Test if the directory permissions are restored properly.
  32. mkdir dir
  33. chmod 755 dir
  34. tar cf a.tar dir
  35. chmod 777 dir
  36. tar -xf a.tar --no-overwrite-dir
  37. genfile --stat=mode.777 dir
  38. # Test if temporary permissions are set correctly to allow the owner
  39. # to write to the directory.
  40. genfile --file dir/file
  41. tar cf a.tar dir
  42. rm dir/file
  43. chmod 400 dir
  44. tar -xf a.tar --no-overwrite-dir
  45. genfile --stat=mode.777 dir
  46. chmod 700 dir
  47. find dir
  48. ],
  49. [0],
  50. [777
  51. 400
  52. dir
  53. dir/file
  54. ])
  55. AT_CLEANUP