From: Ralf Wildenhues Date: Sun, 5 Oct 2008 10:35:27 +0000 (+0200) Subject: Atomic shared library install permissions on HP-UX. X-Git-Tag: v2.2.7b~195 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3531d11d42fe0ff7331d5857cba41a35c916d751;p=thirdparty%2Flibtool.git 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. Signed-off-by: Ralf Wildenhues --- diff --git a/ChangeLog b/ChangeLog index bdec7e6cc..cabc93d9b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2008-10-05 Ralf Wildenhues + + 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 Avoid gcc warning. diff --git a/Makefile.am b/Makefile.am index 8570db47b..8b19ea574 100644 --- a/Makefile.am +++ b/Makefile.am @@ -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)" \ diff --git a/doc/libtool.texi b/doc/libtool.texi index 59f387277..1ee12aafb 100644 --- a/doc/libtool.texi +++ b/doc/libtool.texi @@ -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 diff --git a/libltdl/config/ltmain.m4sh b/libltdl/config/ltmain.m4sh index ec7de23ec..696b6ab13 100644 --- a/libltdl/config/ltmain.m4sh +++ b/libltdl/config/ltmain.m4sh @@ -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 diff --git a/libltdl/m4/libtool.m4 b/libltdl/m4/libtool.m4 index 39ba996cb..caf88b187 100644 --- a/libltdl/m4/libtool.m4 +++ b/libltdl/m4/libtool.m4 @@ -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 index 000000000..e0a075c11 --- /dev/null +++ b/tests/install.at @@ -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