extrac06.at 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. # Process this file with autom4te to create testsuite. -*- Autotest -*-
  2. # Test suite for GNU tar.
  3. # Copyright 2006-2023 Free Software Foundation, Inc.
  4. # This file is part of GNU tar.
  5. # GNU tar is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 3 of the License, or
  8. # (at your option) any later version.
  9. # GNU tar is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. # The bug occurs when extracting from a tarfile a directory when the directory
  16. # already exists and the version in the tarfile has more permissive
  17. # permissions than your umask. In this case, the permissions of the
  18. # existing directory will toggle between the version which complies with
  19. # your umask (which would be correct, without -p) and the version from the
  20. # tarfile.
  21. #
  22. # Reported by: Ian Jackson <[email protected]>
  23. #
  24. # References: <[email protected]>
  25. #
  26. AT_SETUP([mode of extracted directories])
  27. AT_KEYWORDS([extract extract06 directory mode])
  28. AT_TAR_CHECK([
  29. # Force umask
  30. umask 022
  31. # Make sure user's umask is honored, even if we are superuser
  32. TAR_OPTIONS="$TAR_OPTIONS --no-same-permissions"
  33. # Create a directory
  34. mkdir directory
  35. chmod 777 directory
  36. genfile --stat=mode:777 directory
  37. # Archive it
  38. tar cf arc directory
  39. # Change its permissions ...
  40. chmod 755 directory
  41. genfile --stat=mode:777 directory
  42. # ... and attempt to restore it twice
  43. tar xf arc directory --warning=no-timestamp
  44. genfile --stat=mode:777 directory
  45. tar xf arc directory --warning=no-timestamp
  46. genfile --stat=mode:777 directory
  47. # After both restores, the directory mode should be 755
  48. ],
  49. [0],
  50. [777
  51. 755
  52. 755
  53. 755
  54. ])
  55. AT_CLEANUP