summaryrefslogtreecommitdiff
path: root/lib/install-sh
diff options
context:
space:
mode:
authorAlexandre Duret-Lutz <adl@gnu.org>2006-10-14 13:36:40 +0000
committerAlexandre Duret-Lutz <adl@gnu.org>2006-10-14 13:36:40 +0000
commit73eeeac81a8d6c8470ff58eecdd75fa722e05cee (patch)
treef96f3387ef45a3122e90f51fb3babff67b831fd2 /lib/install-sh
parentff2589328fd425cf226a0baa2c433f0b6f491b09 (diff)
downloadautomake-73eeeac81a8d6c8470ff58eecdd75fa722e05cee.tar.gz
* 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 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.
Diffstat (limited to 'lib/install-sh')
-rwxr-xr-xlib/install-sh24
1 files changed, 19 insertions, 5 deletions
diff --git a/lib/install-sh b/lib/install-sh
index 9d6a5eb7c..60a23fb69 100755
--- a/lib/install-sh
+++ b/lib/install-sh
@@ -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.