Hello Paul, is there an implementation of mkdir which understands `-p' and `--' but does not understand `-m'?
If such an implementation existed, it could cause problems with your new code: The call $mkdirprog -m $different_mode -p -- "$tmpdir" might create directories ./-m and ./$different_mode . A possible fix is to skip the check for -m bugs if the first mkdir call did not contain `-m'. Attached please find a variation of your patch. Do you like this version? I'm using `test -z "$mkdir_mode"' because $mkdir_mode may not be a binary operator, so -z is safe here. Moreover, I removed the `X' from the last test call, because it is more readable this way and we know that the ls_ld_tmpdir* variables start with `d'. Have a nice day, Stepan Kasal
2006-10-09 Paul Eggert <[EMAIL PROTECTED]> and Stepan Kasal <[EMAIL PROTECTED]> * lib/install-sh (posix_mkdir): Reject FreeBSD 6.1 mkdir -p -m, 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 in <http://lists.gnu.org/archive/html/bug-autoconf/2006-10/msg00012.html>. Index: lib/install-sh =================================================================== RCS file: /cvs/automake/automake/lib/install-sh,v retrieving revision 1.35 diff -u -r1.35 install-sh --- lib/install-sh 9 Jul 2006 16:09:31 -0000 1.35 +++ lib/install-sh 10 Oct 2006 09:03:38 -0000 @@ -336,12 +336,27 @@ 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 "$mkdir_mode"; then + posix_mkdir=: + else + # Check for POSIX incompatibilities of -m. + # FreeBSD 6.1 mkdir -m -p sets mode of existing directory. + # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or + # other-writeable bit of parent directory when it shouldn't. + 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" + } && + posix_mkdir=: + fi rmdir "$tmpdir/d" "$tmpdir" else # Remove any dirs left behind by ancient mkdir implementations.