Blob Blame History Raw
diff --git a/m4/tar.m4 b/m4/tar.m4
index ec8c83e..681fcbf 100644
--- a/m4/tar.m4
+++ b/m4/tar.m4
@@ -81,7 +81,31 @@ do
   AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
   rm -rf conftest.dir
   if test -s conftest.tar; then
-    AM_RUN_LOG([$am__untar <conftest.tar])
+    m4_if([$1], [ustar], [
+      if test "$_am_tool" = pax; then
+        # Automake bugs #8343 and #13588: 'pax' can hang when UIDs
+        # or GIDs are involved that requires more than 21 bits to
+        # be stored.
+        am_max_uid=2097151 # 2^21 - 1
+        am_max_gid=$am_max_uid
+        # The $UID and $GID variables are not portable, so we need to
+        # resort to the POSIX-mandated id(1) utility.  Errors here are
+        # definitely unexpected, so allow the users to see them (i.e.,
+        # no stderr redirection).
+        am_uid=`id -u || echo unknown`
+        am_gid=`id -g || echo unknown`
+        if test $am_uid -le $am_max_uid; then :; else
+          AS_ECHO(["$as_me: $LINENO: UID '$am_uid' too large for ustar"]) \
+          >&AS_MESSAGE_LOG_FD
+          continue
+        fi
+        if test $am_gid -le $am_max_gid; then :; else
+          AS_ECHO(["$as_me: $LINENO: UID '$am_gid' too large for ustar"]) \
+          >&AS_MESSAGE_LOG_FD
+          continue
+        fi
+      fi
+    ]) # $1 == ustar
     grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
   fi
 done