ignfail.sh 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #! /bin/sh
  2. # This file is part of GNU tar testsuite.
  3. # Copyright (C) 2004 Free Software Foundation, Inc.
  4. #
  5. # This program 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 2, or (at your option)
  8. # any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
  18. # 02111-1307, USA.
  19. # Unreadable directories yielded error despite --ignore-failed-read.
  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