]> git.ipfire.org Git - thirdparty/automake.git/commitdiff
Cope with whitespace in $MISSING and $install_sh.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Thu, 27 Nov 2008 20:46:36 +0000 (21:46 +0100)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Thu, 27 Nov 2008 21:00:33 +0000 (22:00 +0100)
* configure.ac (am_AUTOHEADER): New substitution, save the value
of $AUTOHEADER before AM_INIT_AUTOMAKE may add $MISSING.
* tests/defs.in: Use am_AUTOHEADER.
* lib/am/install.am: Fix typo.
* m4/install-sh.m4 (AM_PROG_INSTALL_SH): Add suitable
single-quote quoting to install_sh, but only if needed.
* m4/missing.m4 (AM_MISSING_HAS_RUN): Add suitable double-quote
quoting to MISSING, but only if needed.
* m4/sanity.m4 (AM_SANITY_CHECK): Abort configure if `pwd` or
$srcdir contain shell meta-characters that cannot be handled;
space and tab are allowed in the former only.
* tests/sanity.test: New test.
* tests/Makefile.am: Adjust.
* NEWS: Update.
Reports by Jim Meyering and others.

Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
19 files changed:
ChangeLog
Makefile.in
NEWS
configure
configure.ac
doc/Makefile.in
lib/Automake/Makefile.in
lib/Automake/tests/Makefile.in
lib/Makefile.in
lib/am/Makefile.in
lib/am/install.am
m4/Makefile.in
m4/install-sh.m4
m4/missing.m4
m4/sanity.m4
tests/Makefile.am
tests/Makefile.in
tests/defs.in
tests/sanity.test [new file with mode: 0755]

index ef7f710a5186cd2a47d55adee8916da44ab1bfbb..c31e083c2b3903d919c6ff3fe382bbc18ae097f4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,23 @@
+2008-11-27  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
+           Jim Meyering  <jim@meyering.net>
+
+       Cope with whitespace in $MISSING and $install_sh.
+       * configure.ac (am_AUTOHEADER): New substitution, save the value
+       of $AUTOHEADER before AM_INIT_AUTOMAKE may add $MISSING.
+       * tests/defs.in: Use am_AUTOHEADER.
+       * lib/am/install.am: Fix typo.
+       * m4/install-sh.m4 (AM_PROG_INSTALL_SH): Add suitable
+       single-quote quoting to install_sh, but only if needed.
+       * m4/missing.m4 (AM_MISSING_HAS_RUN): Add suitable double-quote
+       quoting to MISSING, but only if needed.
+       * m4/sanity.m4 (AM_SANITY_CHECK): Abort configure if `pwd` or
+       $srcdir contain shell meta-characters that cannot be handled;
+       space and tab are allowed in the former only.
+       * tests/sanity.test: New test.
+       * tests/Makefile.am: Adjust.
+       * NEWS: Update.
+       Reports by Jim Meyering and others.
+
 2008-11-24  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        Let `missing' also work with versioned and prefixed programs.
index 7f8b81088e9e4d6f3e1df13eebfa94677ea5873d..375bf9b2a0c1264fae08086785785decb7be1318 100644 (file)
@@ -172,6 +172,7 @@ abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
 abs_top_srcdir = @abs_top_srcdir@
 am_AUTOCONF = @am_AUTOCONF@
+am_AUTOHEADER = @am_AUTOHEADER@
 am__leading_dot = @am__leading_dot@
 am__tar = @am__tar@
 am__untar = @am__untar@
diff --git a/NEWS b/NEWS
index 8e0d0270a4ed1340af8ec4e694efc39e545f2202..e566172cdaebe37dd63a58716d7f51943134de8d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -127,6 +127,17 @@ New in 1.10a:
 
   - The `missing' script works better with versioned tool names.
 
+  - Automake's early configure-time sanity check now diagnoses an
+    unsafe absolute source directory name and makes configure fail.
+
+  - The Automake macros and rules cope better with whitespace in the
+    current directory name, as long as the relative path to `configure'
+    does not contain whitespace.  To this end, the values of `$(MISSING)'
+    and `$(install_sh)' may contain suitable quoting, and their expansion
+    might need `eval'uation if used outside of a makefile.  These
+    undocumented variables may be used in several documented macros such
+    as $(AUTOCONF) or $(MAKEINFO).
+
 Bugs fixed in 1.10a:
 
 * Long standing bugs:
index 73994bd03e235c3843485ab370814ee6c327de5d..8247805d1b9156e5760e67a0c81fa7e1f93c0fbe 100755 (executable)
--- a/configure
+++ b/configure
@@ -637,6 +637,7 @@ am__isrc
 INSTALL_DATA
 INSTALL_SCRIPT
 INSTALL_PROGRAM
+am_AUTOHEADER
 am_AUTOCONF
 build_os
 build_vendor
@@ -1839,9 +1840,11 @@ case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
 
 # Save the AUTOCONF setting before AM_INIT_AUTOMAKE overrides it; this
 # way we can run Autoconf tests from configure (or from the test
-# suite) without being bothered by `missing'.
+# suite) without being bothered by `missing'.  Likewise for autoheader.
 am_AUTOCONF="${AUTOCONF-autoconf}"
 
+am_AUTOHEADER="${AUTOHEADER-autoheader}"
+
 
 am__api_version='1.10a'
 
@@ -1943,16 +1946,33 @@ $as_echo_n "checking whether build environment is sane... " >&6; }
 # Just in case
 sleep 1
 echo timestamp > conftest.file
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name.  Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+  *[\\\"\#\$\&\'\`$am_lf]*)
+    { { $as_echo "$as_me:$LINENO: error: unsafe absolute working directory name" >&5
+$as_echo "$as_me: error: unsafe absolute working directory name" >&2;}
+   { (exit 1); exit 1; }; };;
+esac
+case $srcdir in
+  *[\\\"\#\$\&\'\`$am_lf\ \    ]*)
+    { { $as_echo "$as_me:$LINENO: error: unsafe srcdir value: \`$srcdir'" >&5
+$as_echo "$as_me: error: unsafe srcdir value: \`$srcdir'" >&2;}
+   { (exit 1); exit 1; }; };;
+esac
+
 # Do `set' in a subshell so we don't clobber the current shell's
 # arguments.  Must try -L first in case configure is actually a
 # symlink; some systems play weird games with the mod time of symlinks
 # (eg FreeBSD returns the mod time of the symlink's containing
 # directory).
 if (
-   set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
+   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
    if test "$*" = "X"; then
       # -L didn't work.
-      set X `ls -t $srcdir/configure conftest.file`
+      set X `ls -t "$srcdir/configure" conftest.file`
    fi
    rm -f conftest.file
    if test "$*" != "X $srcdir/configure conftest.file" \
@@ -1996,7 +2016,14 @@ program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
 # expand $ac_aux_dir to an absolute path
 am_aux_dir=`cd $ac_aux_dir && pwd`
 
-test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
+if test x"${MISSING+set}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+  *)
+    MISSING="\${SHELL} $am_aux_dir/missing" ;;
+  esac
+fi
 # Use eval to expand $SHELL
 if eval "$MISSING --run true"; then
   am_missing_run="$MISSING --run "
@@ -2188,7 +2215,14 @@ AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
 
 MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
 
-install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"}
+if test x"${install_sh}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+  *)
+    install_sh="\${SHELL} $am_aux_dir/install-sh"
+  esac
+fi
 
 # Installed binaries are usually stripped using `strip' when the user
 # run `make install-strip'.  However `strip' might not be the right
index 3ede8535dc7a6da0fc47e1a5a3d5c3bba9362b47..7073d6aa0acea601e28011c470d53656039c884c 100644 (file)
@@ -25,8 +25,9 @@ AC_CANONICAL_BUILD
 
 # Save the AUTOCONF setting before AM_INIT_AUTOMAKE overrides it; this
 # way we can run Autoconf tests from configure (or from the test
-# suite) without being bothered by `missing'.
+# suite) without being bothered by `missing'.  Likewise for autoheader.
 AC_SUBST([am_AUTOCONF], ["${AUTOCONF-autoconf}"])
+AC_SUBST([am_AUTOHEADER], ["${AUTOHEADER-autoheader}"])
 
 AM_INIT_AUTOMAKE([1.10a dist-bzip2 filename-length-max=99 color-tests])
 
index a64f13cdc1818ea6412c07e7cdc39a1a800342e2..e692797b0b7d8c53725f4139414534fe68ab6ce4 100644 (file)
@@ -143,6 +143,7 @@ abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
 abs_top_srcdir = @abs_top_srcdir@
 am_AUTOCONF = @am_AUTOCONF@
+am_AUTOHEADER = @am_AUTOHEADER@
 am__leading_dot = @am__leading_dot@
 am__tar = @am__tar@
 am__untar = @am__untar@
index d6498b38091b0d121abd922c144381c5339ec81d..0df41128ac664c328941f81b687a2a9c55fc76ea 100644 (file)
@@ -159,6 +159,7 @@ abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
 abs_top_srcdir = @abs_top_srcdir@
 am_AUTOCONF = @am_AUTOCONF@
+am_AUTOHEADER = @am_AUTOHEADER@
 am__leading_dot = @am__leading_dot@
 am__tar = @am__tar@
 am__untar = @am__untar@
index 9675112b8a8a926c17cd5b77b277c26b285be5f3..efe0811664712bb539f1215b455d3a9f0a6b8edd 100644 (file)
@@ -112,6 +112,7 @@ abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
 abs_top_srcdir = @abs_top_srcdir@
 am_AUTOCONF = @am_AUTOCONF@
+am_AUTOHEADER = @am_AUTOHEADER@
 am__leading_dot = @am__leading_dot@
 am__tar = @am__tar@
 am__untar = @am__untar@
index 173e13fdc1041bca5e8ca91185666abe91fe27f5..2e3c4d88207dea78efb8e325a280990de05f3b39 100644 (file)
@@ -162,6 +162,7 @@ abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
 abs_top_srcdir = @abs_top_srcdir@
 am_AUTOCONF = @am_AUTOCONF@
+am_AUTOHEADER = @am_AUTOHEADER@
 am__leading_dot = @am__leading_dot@
 am__tar = @am__tar@
 am__untar = @am__untar@
index ee54090faf8e13677437de2fdaac5782c1a343c6..dbaf398d3197ec774ad656e9ddf4d573b3d0c370 100644 (file)
@@ -122,6 +122,7 @@ abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
 abs_top_srcdir = @abs_top_srcdir@
 am_AUTOCONF = @am_AUTOCONF@
+am_AUTOHEADER = @am_AUTOHEADER@
 am__leading_dot = @am__leading_dot@
 am__tar = @am__tar@
 am__untar = @am__untar@
index 885ad0b9f6e882e7960274f6a5042a9fb501c135..c114fa59b4215aa662bac88a52919b5aa37c5ab7 100644 (file)
@@ -1,5 +1,5 @@
 ## automake - create Makefile.in from Makefile.am
-## Copyright (C) 2001, 2002, 2003, 2004, 2006  Free Software Foundation, Inc.
+## Copyright (C) 2001, 2002, 2003, 2004, 2006, 2008  Free Software Foundation, Inc.
 
 ## This program is free software; you can redistribute it and/or modify
 ## it under the terms of the GNU General Public License as published by
@@ -78,7 +78,7 @@ install-am: all-am
 ## directory.
 .MAKE .PHONY: install-strip
 install-strip:
-## Beware that they are two variables used to install programs:
+## Beware that there are two variables used to install programs:
 ##   INSTALL_PROGRAM is used for ordinary *_PROGRAMS
 ##   install_sh_PROGRAM is used for nobase_*_PROGRAMS (because install-sh
 ##                                                     creates directories)
index 1e2de16c47db6afbe03f29aca4b419a4ac3d7abc..a15fd1b3ff7b00b9c47df630cac6b8b47ac1eb6f 100644 (file)
@@ -122,6 +122,7 @@ abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
 abs_top_srcdir = @abs_top_srcdir@
 am_AUTOCONF = @am_AUTOCONF@
+am_AUTOHEADER = @am_AUTOHEADER@
 am__leading_dot = @am__leading_dot@
 am__tar = @am__tar@
 am__untar = @am__untar@
index 32c2ebb2b2313601122f4432b17c100835126d74..b15371521c091ebc7fe64a6c345191adf9add76c 100644 (file)
@@ -1,5 +1,5 @@
 ##                                                          -*- Autoconf -*-
-# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
+# Copyright (C) 2001, 2003, 2005, 2008  Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # Define $install_sh.
 AC_DEFUN([AM_PROG_INSTALL_SH],
 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
-install_sh=${install_sh-"\$(SHELL) $am_aux_dir/install-sh"}
+if test x"${install_sh}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+  *)
+    install_sh="\${SHELL} $am_aux_dir/install-sh"
+  esac
+fi
 AC_SUBST(install_sh)])
index 26fab2aab02231beeb97b23b95b828878a93e001..136399cd51c55f0e1ee24ee596b51e96dc0f041b 100644 (file)
@@ -1,13 +1,13 @@
 # Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
 
-# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005
+# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008
 # Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 5
+# serial 6
 
 # AM_MISSING_PROG(NAME, PROGRAM)
 # ------------------------------
@@ -24,7 +24,14 @@ AC_SUBST($1)])
 AC_DEFUN([AM_MISSING_HAS_RUN],
 [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
 AC_REQUIRE_AUX_FILE([missing])dnl
-test x"${MISSING+set}" = xset || MISSING="\${SHELL} $am_aux_dir/missing"
+if test x"${MISSING+set}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+  *)
+    MISSING="\${SHELL} $am_aux_dir/missing" ;;
+  esac
+fi
 # Use eval to expand $SHELL
 if eval "$MISSING --run true"; then
   am_missing_run="$MISSING --run "
index 2e76b10d727e98bc921a49df2aef98939109f49b..3d2f304326b5a1c4860d623b37b6382e064985e1 100644 (file)
@@ -1,13 +1,13 @@
 # Check to make sure that the build environment is sane.    -*- Autoconf -*-
 
-# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008
 # Free Software Foundation, Inc.
 #
 # This file is free software; the Free Software Foundation
 # gives unlimited permission to copy and/or distribute it,
 # with or without modifications, as long as this notice is preserved.
 
-# serial 4
+# serial 5
 
 # AM_SANITY_CHECK
 # ---------------
@@ -16,16 +16,29 @@ AC_DEFUN([AM_SANITY_CHECK],
 # Just in case
 sleep 1
 echo timestamp > conftest.file
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name.  Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+  *[[\\\"\#\$\&\'\`$am_lf]]*)
+    AC_MSG_ERROR([unsafe absolute working directory name]);;
+esac
+case $srcdir in
+  *[[\\\"\#\$\&\'\`$am_lf\ \   ]]*)
+    AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);;
+esac
+
 # Do `set' in a subshell so we don't clobber the current shell's
 # arguments.  Must try -L first in case configure is actually a
 # symlink; some systems play weird games with the mod time of symlinks
 # (eg FreeBSD returns the mod time of the symlink's containing
 # directory).
 if (
-   set X `ls -Lt $srcdir/configure conftest.file 2> /dev/null`
+   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
    if test "$[*]" = "X"; then
       # -L didn't work.
-      set X `ls -t $srcdir/configure conftest.file`
+      set X `ls -t "$srcdir/configure" conftest.file`
    fi
    rm -f conftest.file
    if test "$[*]" != "X $srcdir/configure conftest.file" \
index 9f9dc32d3007b0d9e9a42f327ce9630149871d5c..2a8e847e3bf9acfb6217d253d952249ee0049db4 100644 (file)
@@ -522,6 +522,7 @@ req.test \
 reqd.test \
 reqd2.test \
 rulepat.test \
+sanity.test \
 scripts.test \
 seenc.test \
 sinclude.test \
index 64668e09a29272811bad9beae52ca4f929f51586..c1c67a65e4558e55a102b69418929e3c72270b44 100644 (file)
@@ -113,6 +113,7 @@ abs_srcdir = @abs_srcdir@
 abs_top_builddir = @abs_top_builddir@
 abs_top_srcdir = @abs_top_srcdir@
 am_AUTOCONF = @am_AUTOCONF@
+am_AUTOHEADER = @am_AUTOHEADER@
 am__leading_dot = @am__leading_dot@
 am__tar = @am__tar@
 am__untar = @am__untar@
@@ -675,6 +676,7 @@ req.test \
 reqd.test \
 reqd2.test \
 rulepat.test \
+sanity.test \
 scripts.test \
 seenc.test \
 sinclude.test \
index e7d9d3935ce374290085dadb5490960efcf98337..de0c6824839805bbb1feed64ebbf90852899d5ab 100644 (file)
@@ -69,7 +69,7 @@ export SHELL
 test -z "$PERL" && PERL='@PERL@'
 test -z "$MAKE" && MAKE=make
 test -z "$AUTOCONF" && AUTOCONF="@am_AUTOCONF@"
-test -z "$AUTOHEADER" && AUTOHEADER="@AUTOHEADER@"
+test -z "$AUTOHEADER" && AUTOHEADER="@am_AUTOHEADER@"
 test -z "$AUTOUPDATE" && AUTOUPDATE=autoupdate
 test -z "$MISSING" && MISSING=`pwd`/../lib/missing
 # Use -Werror because this also turns some Perl warnings into error.
diff --git a/tests/sanity.test b/tests/sanity.test
new file mode 100755 (executable)
index 0000000..0d3830d
--- /dev/null
@@ -0,0 +1,49 @@
+#! /bin/sh
+# Copyright (C) 2008 Free Software Foundation, Inc.
+#
+# This program 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 3, or (at your option)
+# any later version.
+#
+# This program 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 this program.  If not, see <http://www.gnu.org/licenses/>.
+
+# Unsafe absolute directory names should be diagnosed.
+
+. ./defs || Exit 1
+
+set -e
+
+mkdir 'unsafe$'
+cd 'unsafe$'
+
+cat > configure.in << 'END'
+AC_INIT([sanity], [1.0])
+AM_INIT_AUTOMAKE([foreign])
+AC_OUTPUT(Makefile)
+END
+
+cp ../install-sh ../missing .
+
+: > Makefile.am
+
+$ACLOCAL
+$AUTOCONF
+$AUTOMAKE
+./configure 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr
+grep 'unsafe absolute working directory' stderr
+
+cd ..
+mkdir build
+cd build
+../unsafe$/configure 2>stderr && { cat stderr >&2; Exit 1; }
+cat stderr
+grep 'unsafe srcdir' stderr
+: