]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
* lib/install-sh (posix_mkdir): Reject FreeBSD 6.1 mkdir -p -m,
authorAlexandre Duret-Lutz <adl@gnu.org>
Sat, 14 Oct 2006 13:36:40 +0000 (13:36 +0000)
committerAlexandre Duret-Lutz <adl@gnu.org>
Sat, 14 Oct 2006 13:36:40 +0000 (13:36 +0000)
which incorrectly sets the mode of an existing destination
directory.  In some cases the unpatched install-sh could do the
equivalent of "chmod 777 /" or "chmod 0 /" on a buggy FreeBSD
system.  We hope this is rare in practice, but it's clearly worth
fixing.  Problem reported by Alex Unleashed in
<http://lists.gnu.org/archive/html/bug-autoconf/2006-10/msg00012.html>.
Also, don't bother to check for -m bugs unless we're using -m;
suggested by Stepan Kasal.

lib/install-sh

index 9d6a5eb7cd1e31899a10d3e780bef9f4ba8e27bc..60a23fb693089db309a68e42305f021091d5fbfe 100755 (executable)
@@ -336,12 +336,26 @@ do
            trap 'ret=$?; rmdir "$tmpdir/d" "$tmpdir" 2>/dev/null; exit $ret' 0
 
            if (umask $mkdir_umask &&
-               exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
+               exec $mkdirprog $mkdir_mode -p -- "$tmpdir/d") >/dev/null 2>&1
            then
-             # Check for bugs in HP-UX 11.23 and IRIX 6.5 mkdir.
-             case `ls -ld "$tmpdir"` in
-               d????-??-* ) posix_mkdir=:;;
-             esac
+             if test -z "$dir_arg" || {
+                  # Check for POSIX incompatibilities with -m.
+                  # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or
+                  # other-writeable bit of parent directory when it shouldn't.
+                  # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.
+                  ls_ld_tmpdir=`ls -ld "$tmpdir"`
+                  case $ls_ld_tmpdir in
+                    d????-?r-*) different_mode=700;;
+                    d????-?--*) different_mode=755;;
+                    *) false;;
+                  esac &&
+                  $mkdirprog -m$different_mode -p -- "$tmpdir" && {
+                    ls_ld_tmpdir_1=`ls -ld "$tmpdir"`
+                    test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"
+                  }
+                }
+             then posix_mkdir=:
+             fi
              rmdir "$tmpdir/d" "$tmpdir"
            else
              # Remove any dirs left behind by ancient mkdir implementations.