tar-ustar-id-too-high.sh 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. #! /bin/sh
  2. # Copyright (C) 2013-2017 Free Software Foundation, Inc.
  3. #
  4. # This program is free software; you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation; either version 2, or (at your option)
  7. # any later version.
  8. #
  9. # This program 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. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. # Check that UID or GID too high for the ustar format are correctly
  17. # rwcognized and diagnosed by configure. See bug#8343 and bug#13588.
  18. . test-init.sh
  19. cat > configure.ac <<END
  20. AC_INIT([$me], [1.0])
  21. AM_INIT_AUTOMAKE([tar-ustar])
  22. AC_CONFIG_FILES([Makefile])
  23. AC_OUTPUT
  24. END
  25. : > Makefile.am
  26. run_configure()
  27. {
  28. st=0; ./configure ${1+"$@"} >stdout || st=$?
  29. cat stdout || exit 1
  30. test $st -eq 0 || exit 1
  31. }
  32. checked ()
  33. {
  34. grep "^checking $1\.\.\. $2$" stdout
  35. }
  36. $ACLOCAL
  37. $AUTOCONF
  38. $AUTOMAKE
  39. mkdir bin
  40. cat > bin/id <<'END'
  41. #!/bin/sh -e
  42. case "$*" in
  43. -u) echo "${am_uid-1000}";;
  44. -g) echo "${am_gid-1000}";;
  45. *) echo "id: bad/unexpected usage" >&2; exit 1;;
  46. esac
  47. END
  48. chmod a+x bin/id
  49. PATH=$(pwd)/bin$PATH_SEPARATOR$PATH
  50. # Problematic ID reported in
  51. # <https://bugzilla.redhat.com/show_bug.cgi?id=843376>.
  52. am_uid=16777216; export am_uid
  53. am_gid=1000; export am_gid
  54. run_configure
  55. checked "whether UID '$am_uid' is supported by ustar format" "no"
  56. checked "whether GID '1000' is supported by ustar format" "yes"
  57. checked "how to create a ustar tar archive" "none"
  58. # Another problematic ID reported in
  59. # <https://bugzilla.redhat.com/show_bug.cgi?id=843376>.
  60. am_uid=1000; export am_uid
  61. am_gid=17000000; export am_gid
  62. run_configure
  63. checked "whether UID '1000' is supported by ustar format" "yes"
  64. checked "whether GID '$am_gid' is supported by ustar format" "no"
  65. checked "how to create a ustar tar archive" "none"
  66. # The minimal ID that is too big.
  67. two_to_twentyone=$((32 * 32 * 32 * 32 * 2))
  68. # <https://bugzilla.redhat.com/show_bug.cgi?id=843376>.
  69. am_uid=$two_to_twentyone; export am_uid
  70. am_gid=$two_to_twentyone; export am_gid
  71. run_configure
  72. checked "whether UID '$two_to_twentyone' is supported by ustar format" "no"
  73. checked "whether GID '$two_to_twentyone' is supported by ustar format" "no"
  74. checked "how to create a ustar tar archive" "none"
  75. :