[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: install-sh misbehaves badly on buggy FreeBSD systems
From: |
Paul Eggert |
Subject: |
Re: install-sh misbehaves badly on buggy FreeBSD systems |
Date: |
Tue, 10 Oct 2006 12:11:25 -0700 |
User-agent: |
Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux) |
Stepan Kasal <address@hidden> writes:
> is there an implementation of mkdir which understands `-p' and `--' but
> does not understand `-m'?
Not in the sense described here, no. Ancient mkdir treats all
arguments as directories to be made, and `$mkdirprog $mkdir_mode -p --
"$tmpdir/d"' must fail because tmpdir does not exist. I don't think
we need to worry about any mkdir understanding -p and -- but not -m;
even if there were an animal, it should treat -m as an unknown option
and should fail.
Your other ideas look good. It's a bit more consistent to test
dir_arg rather than mkdir_mode (that's what the rest of the script
does). So here's a revised patch.
2006-10-10 Paul Eggert <address@hidden>
* 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>.
Also, don't bother to check for -m bugs unless we're using -m;
suggested by Stepan Kasal.
--- lib/install-sh.~1.35.~ 2006-07-09 09:09:31.000000000 -0700
+++ lib/install-sh 2006-10-10 12:05:29.000000000 -0700
@@ -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.