]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
Atomic shared library install permissions on HP-UX.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sun, 5 Oct 2008 10:35:27 +0000 (12:35 +0200)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sun, 5 Oct 2008 10:40:54 +0000 (12:40 +0200)
The HP-UX 11 runtime linker fails to mmap shared libraries
without execute permissions.  Fixing them with postinstall_cmds
may be too late, as ln, sed, and chmod may link against the
library being installed.

* libltdl/m4/libtool.m4 (install_override_mode): New LT_DECL.
(_LT_SYS_DYNAMIC_LINKER) [hpux9*, hpux10*, hpux11*]: Set it.
* libltdl/config/ltmain.m4sh (func_mode_install): Build a second
command line, $install_shared_prog, for the installation of the
shared library.  Override resp. set the permission mode if
install_override_mode is nonempty.
* doc/libtool.texi (libtool script contents): Document it.
* tests/install.at (Install tests): New test.
* Makefile.am (TESTSUITE_AT): Adjust.
(TESTS_ENVIRONMENT): Pass INSTALL.
Report by Bruno Haible.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
ChangeLog
Makefile.am
doc/libtool.texi
libltdl/config/ltmain.m4sh
libltdl/m4/libtool.m4
tests/install.at [new file with mode: 0644]

index bdec7e6ccb5835f4ec7b1aead2ad6b7096aaa39b..cabc93d9b724f4892a308ccddda5df601f05d02a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2008-10-05  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
+
+       Atomic shared library install permissions on HP-UX.
+       The HP-UX 11 runtime linker fails to mmap shared libraries
+       without execute permissions.  Fixing them with postinstall_cmds
+       may be too late, as ln, sed, and chmod may link against the
+       library being installed.
+
+       * libltdl/m4/libtool.m4 (install_override_mode): New LT_DECL.
+       (_LT_SYS_DYNAMIC_LINKER) [hpux9*, hpux10*, hpux11*]: Set it.
+       * libltdl/config/ltmain.m4sh (func_mode_install): Build a second
+       command line, $install_shared_prog, for the installation of the
+       shared library.  Override resp. set the permission mode if
+       install_override_mode is nonempty.
+       * doc/libtool.texi (libtool script contents): Document it.
+       * tests/install.at (Install tests): New test.
+       * Makefile.am (TESTSUITE_AT): Adjust.
+       (TESTS_ENVIRONMENT): Pass INSTALL.
+       Report by Bruno Haible.
+
 2008-09-26  Eric Blake  <ebb9@byu.net>
 
        Avoid gcc warning.
index 8570db47b4aa36496c825ee309d7d8efcffcbad0..8b19ea5747dc047f5900b0ed99a240ae9c8c6711 100644 (file)
@@ -460,6 +460,7 @@ TESTSUITE_AT        = tests/testsuite.at \
                  tests/archive-in-archive.at \
                  tests/execute-mode.at \
                  tests/localization.at \
+                 tests/install.at \
                  tests/destdir.at \
                  tests/old-m4-iface.at \
                  tests/am-subdir.at \
@@ -486,7 +487,7 @@ EXTRA_DIST     += $(srcdir)/$(TESTSUITE) $(TESTSUITE_AT) $(srcdir)/tests/package
 TESTS_ENVIRONMENT = MAKE="$(MAKE)" CC="$(CC)" CFLAGS="$(CFLAGS)" \
        CPP="$(CPP)" CPPFLAGS="$(CPPFLAGS)" LD="$(LD)" LDFLAGS="$(LDFLAGS)" \
        LIBS="$(LIBS)" LN_S="$(LN_S)" NM="$(NM)" RANLIB="$(RANLIB)" \
-       STRIP="$(STRIP)" \
+       STRIP="$(STRIP)" INSTALL="$(INSTALL)" \
        OBJEXT="$(OBJEXT)" EXEEXT="$(EXEEXT)" \
        SHELL="$(SHELL)" CONFIG_SHELL="$(SHELL)" \
        CXX="$(CXX)" CXXFLAGS="$(CXXFLAGS)" CXXCPP="$(CXXCPP)" \
index 59f38727734976c97645ae131c89f0aa4b8648ef..1ee12aafb6895468cedf7072904080b77e83a12c 100644 (file)
@@ -5819,6 +5819,15 @@ runtime path list, requiring libtool to relink the output when installing.
 Set to @samp{yes} or @samp{no}.  Default is @samp{no}.
 @end defvar
 
+@defvar install_override_mode
+Permission mode override for installation of shared libraries.  If the
+runtime linker fails to load libraries with wrong permissions, then it
+may fail to execute programs that are needed during installation,
+because these need the library that has just been installed.  In this
+case, it is necessary to pass the mode to @command{install} with
+@option{-m @var{install_override_mode}}.
+@end defvar
+
 @defvar libext
 The standard old archive suffix (normally @samp{a}).
 @end defvar
index ec7de23ec07ede210f902434f1adcac937d1621e..696b6ab1359ed92abd3970740b4a6c152b826374 100644 (file)
@@ -1458,6 +1458,7 @@ func_mode_install ()
     # Aesthetically quote it.
     func_quote_for_eval "$arg"
     install_prog="$install_prog$func_quote_for_eval_result"
+    install_shared_prog=$install_prog
 
     # We need to accept at least all the BSD install flags.
     dest=
@@ -1467,8 +1468,10 @@ func_mode_install ()
     install_type=
     isdir=no
     stripme=
+    no_mode=:
     for arg
     do
+      arg2=
       if test -n "$dest"; then
        files="$files $dest"
        dest=$arg
@@ -1495,6 +1498,10 @@ func_mode_install ()
       *)
        # If the previous option needed an argument, then skip it.
        if test -n "$prev"; then
+         if test "x$prev" = x-m && test -n "$install_override_mode"; then
+           arg2=$install_override_mode
+           no_mode=false
+         fi
          prev=
        else
          dest=$arg
@@ -1506,6 +1513,10 @@ func_mode_install ()
       # Aesthetically quote the argument.
       func_quote_for_eval "$arg"
       install_prog="$install_prog $func_quote_for_eval_result"
+      if test -n "$arg2"; then
+       func_quote_for_eval "$arg2"
+      fi
+      install_shared_prog="$install_shared_prog $func_quote_for_eval_result"
     done
 
     test -z "$install_prog" && \
@@ -1514,6 +1525,11 @@ func_mode_install ()
     test -n "$prev" && \
       func_fatal_help "the \`$prev' option requires an argument"
 
+    if test -n "$install_override_mode" && $no_mode; then
+      func_quote_for_eval "$install_override_mode"
+      install_shared_prog="$install_shared_prog -m $func_quote_for_eval_result"
+    fi
+
     if test -z "$files"; then
       if test -z "$dest"; then
        func_fatal_help "no file or destination specified"
@@ -1634,7 +1650,7 @@ func_mode_install ()
          test -n "$relink_command" && srcname="$realname"T
 
          # Install the shared library and build the symlinks.
-         func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
+         func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
              'exit $?'
          tstripme="$stripme"
          case $host_os in
index 39ba996cb960e22873667c57deeff94bf23bef56..caf88b1874e8c670c3ec22778ab0a7df21675bd6 100644 (file)
@@ -2386,8 +2386,10 @@ hpux9* | hpux10* | hpux11*)
     soname_spec='${libname}${release}${shared_ext}$major'
     ;;
   esac
-  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
   postinstall_cmds='chmod 555 $lib'
+  # or fails outright, so override atomically:
+  install_override_mode=555
   ;;
 
 interix[[3-9]]*)
@@ -2705,6 +2707,8 @@ _LT_DECL([], [library_names_spec], [1],
     The last name is the one that the linker finds with -lNAME]])
 _LT_DECL([], [soname_spec], [1],
     [[The coded name of the library, if different from the real name]])
+_LT_DECL([], [install_override_mode], [1],
+    [Permission mode override for installation of shared libraries])
 _LT_DECL([], [postinstall_cmds], [2],
     [Command to use after installation of a shared archive])
 _LT_DECL([], [postuninstall_cmds], [2],
diff --git a/tests/install.at b/tests/install.at
new file mode 100644 (file)
index 0000000..e0a075c
--- /dev/null
@@ -0,0 +1,51 @@
+# install.at -- install mode tests             -*- Autotest -*-
+#
+#   Copyright (C) 2008 Free Software Foundation, Inc.
+#   Written by Ralf Wildenhues, 2008
+#
+#   This file is part of GNU Libtool.
+#
+# GNU Libtool is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# GNU Libtool is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from  http://www.gnu.org/licenses/gpl.html,
+# or obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+####
+
+AT_SETUP([Install tests])
+AT_KEYWORDS([libtool])
+
+# Ensure that install_override_mode overrides the mode of the shared
+# library (and only the shared library).
+
+AT_CHECK([$LIBTOOL --features | grep 'enable shared libraries' || exit 77],
+        [], [ignore])
+sed 's,^\(install_override_mode=\).*,&755,' < $LIBTOOL > ./libtool
+LIBTOOL=./libtool
+chmod a+rx $LIBTOOL
+
+inst=`pwd`/inst
+mkdir inst
+
+echo 'int a () { return 0; }' > a.c
+$LIBTOOL --mode=compile $CC $CPPFLAGS $CFLAGS -c a.c
+$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o liba.la a.lo -rpath $inst
+AT_CHECK([$LIBTOOL --mode=install $INSTALL liba.la $inst],
+        [], [stdout], [ignore])
+AT_CHECK([grep ' -m 755' stdout], [], [ignore])
+AT_CHECK([$LIBTOOL --mode=install $INSTALL -m 644 liba.la $inst],
+        [], [stdout], [ignore])
+AT_CHECK([grep ' -m 755' stdout], [], [ignore])
+AT_CHECK([grep ' -m 644.*liba.la' stdout], [], [ignore])
+
+AT_CLEANUP