bug-autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

install-sh misbehaves badly on buggy FreeBSD systems


From: Paul Eggert
Subject: install-sh misbehaves badly on buggy FreeBSD systems
Date: Mon, 09 Oct 2006 16:17:53 -0700
User-agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.4 (gnu/linux)

Here's a proposed patch to Automake to work around the FreeBSD mkdir
bug described in
<http://lists.gnu.org/archive/html/bug-autoconf/2006-10/msg00012.html>

2006-10-09  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>.

--- lib/install-sh.~1.35.~      2006-07-09 09:09:31.000000000 -0700
+++ lib/install-sh      2006-10-09 16:15:34.000000000 -0700
@@ -336,12 +336,24 @@ 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
+             # Check for POSIX incompatibilities.
+             # 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.
+             # Ancient mkdir lacks -m and -p.
+             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 "X$ls_ld_tmpdir" = "X$ls_ld_tmpdir_1"
+               } &&
+               posix_mkdir=:
              rmdir "$tmpdir/d" "$tmpdir"
            else
              # Remove any dirs left behind by ancient mkdir implementations.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]