ignfail.sh 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #! /bin/sh
  2. # Unreadable directories yielded error despite --ignore-failed-read.
  3. # This file is part of GNU tar testsuite.
  4. # Copyright (C) 2004 Free Software Foundation, Inc.
  5. #
  6. # This program 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 2, or (at your option)
  9. # any later version.
  10. #
  11. # This program 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, write to the Free Software
  18. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  19. # 02111-1307, USA.
  20. . ./preset
  21. . $srcdir/before
  22. > check-uid
  23. set - x`ls -l check-uid`
  24. uid_name="$3"
  25. set - x`ls -ln check-uid`
  26. uid_number="$3"
  27. if test "$uid_name" = root || test "$uid_number" = 0; then
  28. # The test is meaningless for super-user.
  29. rm check-uid
  30. else
  31. touch file
  32. mkdir directory
  33. touch directory/file
  34. echo 1>&2 -----
  35. chmod 000 file
  36. tar cf archive file
  37. status=$?
  38. chmod 600 file
  39. test $status = 2 || exit 1
  40. echo 1>&2 -----
  41. chmod 000 file
  42. tar cf archive --ignore-failed-read file || exit 1
  43. status=$?
  44. chmod 600 file
  45. test $status = 0 || exit 1
  46. echo 1>&2 -----
  47. chmod 000 directory
  48. tar cf archive directory
  49. status=$?
  50. chmod 700 directory
  51. test $status = 2 || exit 1
  52. echo 1>&2 -----
  53. chmod 000 directory
  54. tar cf archive --ignore-failed-read directory || exit 1
  55. status=$?
  56. chmod 700 directory
  57. test $status = 0 || exit 1
  58. err="\
  59. -----
  60. tar: file: Cannot open: Permission denied
  61. tar: Error exit delayed from previous errors
  62. -----
  63. tar: file: Warning: Cannot open: Permission denied
  64. -----
  65. tar: directory: Cannot savedir: Permission denied
  66. tar: Error exit delayed from previous errors
  67. -----
  68. tar: directory: Warning: Cannot savedir: Permission denied
  69. "
  70. fi
  71. . $srcdir/after