diff options
author | Stefano Lattarini <stefano.lattarini@gmail.com> | 2013-02-17 16:42:46 +0100 |
---|---|---|
committer | Stefano Lattarini <stefano.lattarini@gmail.com> | 2013-04-28 10:43:10 +0200 |
commit | edfd3bc4c1057be0b5553b5789a44f1b77bb2b45 (patch) | |
tree | 47f733698af5a74278f896698fc6dcc4256b11a0 /t/tar-ustar-id-too-high.sh | |
parent | 24dbfd93188d5302545d55b59a3853b2115a982e (diff) | |
download | automake-edfd3bc4c1057be0b5553b5789a44f1b77bb2b45.tar.gz |
tar: format 'ustar' cannot support UID/GID longer than 21 bits
See automake bug#8343 and bug#13588.
POSIX 1988 'ustar' format is defined with *fixed-size* fields. There
is notably a 21 bits limit (2097151) for the UID and the GID.
Tom Rini tom_rini@mentor.com says (in bug#8343):
When the user has a UID or GID that is larger than the ustar format
supports, pax does not error out gracefully in some cases (FC13).
Marc Herbert <marc.herbert@intel.com> adds (in bug#8343):
When "configure" is run by a user with an UID bigger than 21 bits,
BSD pax 3.4 aborts when trying to create the 'conftest.tar' test
archive and leaves an empty or corrupted conftest.tar file behind.
In the next step, pax tries to extract this incomplete or corrupted
archive and this *** hangs the whole ./configure script ***.
Note: GNU cpio 2.9 pretends to pass the test but it is a LIE: it
silently truncates any big UID to its lower 21 bits. I don't know
what can be the consequences of this lie.
I think there is currently a design issue in automake/m4/tar.m4
considering that a ustar archive should should *never* succeed when
./configure is run from a big user ID.
Months later, Petr Hracek <phracek@redhat.com> reports a similar issue
(in bug#13588) for Fedora 17:
I am trying to solve problem in case a user is created with big
UID and during configuration pax hangs with message
ATTENTION! pax archive volume change required.
Ready for archive volume: 1
Input archive name or "." to quit pax.
Archive name >
and needs user interaction.
Reference: <https://bugzilla.redhat.com/show_bug.cgi?id=843376>
Time to fix this issue, on the line of a preliminary patch provided by
Petr Hracek in bug#13588. The final patch ended up being remarkably
different from that original proposition, though.
* m4/tar.m4 (_AM_PROG_TAR): If the UID or GID of the current user is
too high (> 2097151), the 'ustar' format cannot work. Adjust checks
accordingly. Some related code reordering and clean-up.
* t/tar-ustar-id-too-high.sh: New test.
* t/list-of-tests.mk: Add it.
* t/tar.sh: While at it, tweak and enhance a little.
* t/tar2.sh: Likewise.
* t/tar3.sh: Likewise.
* t/tar-override.sh: Likewise.
* NEWS: Update.
* THANKS: Likewise.
Helped-by: Pavel Raiskup <praiskup@redhat.com>
Helped-by: Petr Hracek <phracek@redhat.com>
Helped-by: Marc Herbert <marc.herbert@intel.com>
Helped-by: Tom Rini <tom_rini@mentor.com>
Signed-off-by: Stefano Lattarini <stefano.lattarini@gmail.com>
Diffstat (limited to 't/tar-ustar-id-too-high.sh')
-rwxr-xr-x | t/tar-ustar-id-too-high.sh | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/t/tar-ustar-id-too-high.sh b/t/tar-ustar-id-too-high.sh new file mode 100755 index 000000000..79ae89d85 --- /dev/null +++ b/t/tar-ustar-id-too-high.sh @@ -0,0 +1,88 @@ +#! /bin/sh +# Copyright (C) 2013 Free Software Foundation, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +# Check that UID or GID too high for the ustar format are correctly +# rwcognized and diagnosed by configure. See bug#8343 and bug#13588. + +. test-init.sh + +cat > configure.ac <<END +AC_INIT([$me], [1.0]) +AM_INIT_AUTOMAKE([tar-ustar]) +AC_CONFIG_FILES([Makefile]) +AC_OUTPUT +END + +: > Makefile.am + +run_configure() +{ + st=0; ./configure ${1+"$@"} >stdout || st=$? + cat stdout || exit 1 + test $st -eq 0 || exit 1 +} + +checked () +{ + grep "^checking $1\.\.\. $2$" stdout +} + +$ACLOCAL +$AUTOCONF +$AUTOMAKE + +mkdir bin +cat > bin/id <<'END' +#!/bin/sh -e +case "$*" in + -u) echo "${am_uid-1000}";; + -g) echo "${am_gid-1000}";; + *) echo "id: bad/unexpected usage" >&2; exit 1;; +esac +END +chmod a+x bin/id + +PATH=$(pwd)/bin$PATH_SEPARATOR$PATH + +# Problematic ID reported in +# <https://bugzilla.redhat.com/show_bug.cgi?id=843376>. +am_uid=16777216; export am_uid +am_gid=1000; export am_gid +run_configure +checked "whether UID '$am_uid' is supported by ustar format" "no" +checked "whether GID '1000' is supported by ustar format" "yes" +checked "how to create a ustar tar archive" "none" + +# Another problematic ID reported in +# <https://bugzilla.redhat.com/show_bug.cgi?id=843376>. +am_uid=1000; export am_uid +am_gid=17000000; export am_gid +run_configure +checked "whether UID '1000' is supported by ustar format" "yes" +checked "whether GID '$am_gid' is supported by ustar format" "no" +checked "how to create a ustar tar archive" "none" + +# The minimal ID that is too big. +two_to_twentyone=$((32 * 32 * 32 * 32 * 2)) +# <https://bugzilla.redhat.com/show_bug.cgi?id=843376>. +am_uid=$two_to_twentyone; export am_uid +am_gid=$two_to_twentyone; export am_gid +run_configure +checked "whether UID '$two_to_twentyone' is supported by ustar format" "no" +checked "whether GID '$two_to_twentyone' is supported by ustar format" "no" +checked "how to create a ustar tar archive" "none" + +: |