From: Paul Eggert Date: Wed, 23 Mar 2005 01:01:58 +0000 (+0000) Subject: * NEWS: The configure command now warns you if you attempt to use X-Git-Tag: AUTOCONF-2.59c~427 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=789f0bf6ffcd3e9d29ac9102ec0b560be9bfa65e;p=thirdparty%2Fautoconf.git * NEWS: The configure command now warns you if you attempt to use a directory whose name contains a special character like space, newline, or "\". * doc/autoconf.texi (Installation Directory Variables): Allow "," in file names. Do not use \@; it's not a portable regexp. * bin/Makefile.am (edit): Likewise. * lib/Makefile.am (edit): Likewise. * tests/Makefile.am (edit): Likewise. * tests/semantics.at: Likewise. * tests/torture.at: Likewise. * lib/autoconf/general.m4 (AC_ARG_PROGRAM): Likewise. * lib/autoconf/status.m4 (_AC_SRCDIRS): Likewise. * doc/autoconf.texi (File System Conventions): Warn about unportable file names. * lib/autoconf/general.m4 (_AC_INIT_DIRCHECK): New macro. (AC_INIT): Use it. (_AC_INIT_SRCDIR): Use ac_pwd rather than invoking pwd. * lib/autoconf/status.m4 (_AC_OUTPUT_CONFIG_STATUS): Propagate ac_pwd, and quote srcdir. * lib/autotest/general.m4 (AT_INIT): Quote file name args. --- diff --git a/ChangeLog b/ChangeLog index bf8e1dba6..a1b7ecc88 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,26 @@ 2005-03-22 Paul Eggert + * NEWS: The configure command now warns you if you attempt to use + a directory whose name contains a special character like space, + newline, or "\". + * doc/autoconf.texi (Installation Directory Variables): Allow + "," in file names. Do not use \@; it's not a portable regexp. + * bin/Makefile.am (edit): Likewise. + * lib/Makefile.am (edit): Likewise. + * tests/Makefile.am (edit): Likewise. + * tests/semantics.at: Likewise. + * tests/torture.at: Likewise. + * lib/autoconf/general.m4 (AC_ARG_PROGRAM): Likewise. + * lib/autoconf/status.m4 (_AC_SRCDIRS): Likewise. + * doc/autoconf.texi (File System Conventions): Warn about + unportable file names. + * lib/autoconf/general.m4 (_AC_INIT_DIRCHECK): New macro. + (AC_INIT): Use it. + (_AC_INIT_SRCDIR): Use ac_pwd rather than invoking pwd. + * lib/autoconf/status.m4 (_AC_OUTPUT_CONFIG_STATUS): Propagate + ac_pwd, and quote srcdir. + * lib/autotest/general.m4 (AT_INIT): Quote file name args. + * doc/autoconf.texi: Fix some systematic formatting problems. ".)" needs a following @: if not at the end of a sentence, and similarly for "!)". "etc." should be preceded by a comma. diff --git a/NEWS b/NEWS index 911242205..697fb7fcc 100644 --- a/NEWS +++ b/NEWS @@ -1,5 +1,9 @@ * Major changes in Autoconf 2.59c +** The configure command now warns you if you attempt to use a directory + whose name contains a special character like space, newline, or "\". + Such names are not supported, and can cause "configure" to crash. + ** The configure command now redirects standard input from /dev/null, to help avoid problems with subsidiary commands that might mistakenly read standard input. AS_ORIGINAL_STDIN_FD points to the original diff --git a/bin/Makefile.am b/bin/Makefile.am index b1a0897a7..ff55e4548 100644 --- a/bin/Makefile.am +++ b/bin/Makefile.am @@ -2,7 +2,7 @@ ## Makefile for Autoconf. -## Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004 Free Software +## Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software ## Foundation, Inc. ## This program is free software; you can redistribute it and/or modify @@ -37,19 +37,19 @@ MOSTLYCLEANFILES = $(bin_SCRIPTS) autoconf.in *.tmp ## ------------- ## edit = sed \ - -e 's,@SHELL\@,$(SHELL),g' \ - -e 's,@PERL\@,$(PERL),g' \ - -e 's,@bindir\@,$(bindir),g' \ - -e 's,@datadir\@,$(pkgdatadir),g' \ - -e 's,@prefix\@,$(prefix),g' \ - -e 's,@autoconf-name\@,'`echo autoconf | sed '$(transform)'`',g' \ - -e 's,@autoheader-name\@,'`echo autoheader | sed '$(transform)'`',g' \ - -e 's,@autom4te-name\@,'`echo autom4te | sed '$(transform)'`',g' \ - -e 's,@M4\@,$(M4),g' \ - -e 's,@AWK\@,$(AWK),g' \ - -e 's,@VERSION\@,$(VERSION),g' \ - -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' \ - -e 's,@configure_input\@,Generated from $@.in; do not edit by hand.,g' + -e 's|@SHELL[@]|$(SHELL)|g' \ + -e 's|@PERL[@]|$(PERL)|g' \ + -e 's|@bindir[@]|$(bindir)|g' \ + -e 's|@datadir[@]|$(pkgdatadir)|g' \ + -e 's|@prefix[@]|$(prefix)|g' \ + -e 's|@autoconf-name[@]|'`echo autoconf | sed '$(transform)'`'|g' \ + -e 's|@autoheader-name[@]|'`echo autoheader | sed '$(transform)'`'|g' \ + -e 's|@autom4te-name[@]|'`echo autom4te | sed '$(transform)'`'|g' \ + -e 's|@M4[@]|$(M4)|g' \ + -e 's|@AWK[@]|$(AWK)|g' \ + -e 's|@VERSION[@]|$(VERSION)|g' \ + -e 's|@PACKAGE_NAME[@]|$(PACKAGE_NAME)|g' \ + -e 's|@configure_input[@]|Generated from $@.in; do not edit by hand.|g' # autoconf is written in M4sh. autoconf.in: $(srcdir)/autoconf.as $(m4sh_m4f_dependencies) diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 5fc1d75f0..58c737082 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -2437,8 +2437,8 @@ Makefile snippet similar to: @example @group edit = sed \ - -e 's,@@datadir\@@,$(pkgdatadir),g' \ - -e 's,@@prefix\@@,$(prefix),g' + -e 's|@@datadir[@@]|$(pkgdatadir)|g' \ + -e 's|@@prefix[@@]|$(prefix)|g' @end group @group @@ -2461,9 +2461,11 @@ autoheader: Makefile $(srcdir)/autoheader.in Some details are noteworthy: @table @samp -@item @@datadir\@@ -The backslash prevents @command{configure} from replacing +@item @@datadir[@@] +The brackets prevent @command{configure} from replacing @samp{@@datadir@@} in the sed expression itself. +Brackets are preferable to a backslash here, since +Posix says @samp{\@@} is not portable. @item $(pkgdatadir) Don't use @samp{@@pkgdatadir@@}! Use the matching makefile variable @@ -9945,6 +9947,26 @@ bar}; see @ref{Limitations of Builtins}, @command{mv} for more details. @section File System Conventions @cindex File system conventions +Autoconf uses shell-script processing extensively, so the file names +that it processes should not contain characters that are special to the +shell. Special characters include space, tab, newline, @sc{nul}, and +the following: + +@example +" # $ & ' ( ) * ; < = > ? [ \ ` | +@end example + +Also, file names should not begin with @samp{~} or @samp{-}, and should +not contain @samp{-} immediately after @samp{/}. + +These restrictions apply not only to the files that you distribute, but +also to the absolute file names of your source, build, and destination +directories. Autoconf-generated @command{configure} scripts warn of +violations to the above restrictions. + +On some Posix-like platforms, @samp{!} and @samp{^} are special too, so +they should be avoided. + While @command{autoconf} and friends will usually be run on some Posix variety, it can and will be used on other systems, most notably @acronym{DOS} variants. This impacts several assumptions regarding file names. diff --git a/lib/Makefile.am b/lib/Makefile.am index adbf7cb21..6503be560 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,6 +1,6 @@ ## Process this file with automake to create Makefile.in -## Copyright (C) 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +## Copyright (C) 2001, 2002, 2003, 2004, 2005 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 @@ -22,18 +22,18 @@ nodist_pkgdata_DATA = autom4te.cfg EXTRA_DIST = autom4te.in freeze.mk edit = sed \ - -e 's,@SHELL\@,$(SHELL),g' \ - -e 's,@PERL\@,$(PERL),g' \ - -e 's,@bindir\@,$(bindir),g' \ - -e 's,@datadir\@,$(pkgdatadir),g' \ - -e 's,@prefix\@,$(prefix),g' \ - -e 's,@autoconf-name\@,'`echo autoconf | sed '$(transform)'`',g' \ - -e 's,@autoheader-name\@,'`echo autoheader | sed '$(transform)'`',g' \ - -e 's,@autom4te-name\@,'`echo autom4te | sed '$(transform)'`',g' \ - -e 's,@M4\@,$(M4),g' \ - -e 's,@AWK\@,$(AWK),g' \ - -e 's,@VERSION\@,$(VERSION),g' \ - -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' + -e 's|@SHELL[@]|$(SHELL)|g' \ + -e 's|@PERL[@]|$(PERL)|g' \ + -e 's|@bindir[@]|$(bindir)|g' \ + -e 's|@datadir[@]|$(pkgdatadir)|g' \ + -e 's|@prefix[@]|$(prefix)|g' \ + -e 's|@autoconf-name[@]|'`echo autoconf | sed '$(transform)'`'|g' \ + -e 's|@autoheader-name[@]|'`echo autoheader | sed '$(transform)'`'|g' \ + -e 's|@autom4te-name[@]|'`echo autom4te | sed '$(transform)'`'|g' \ + -e 's|@M4[@]|$(M4)|g' \ + -e 's|@AWK[@]|$(AWK)|g' \ + -e 's|@VERSION[@]|$(VERSION)|g' \ + -e 's|@PACKAGE_NAME[@]|$(PACKAGE_NAME)|g' # All the files below depend on Makefile so that they are rebuilt # when the prefix, etc. changes. Unfortunately, suffix rules diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index f50c1967d..5292b2fe0 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -462,6 +462,49 @@ AC_DEFUN([AC_CONFIG_SRCDIR], [m4_divert_text([DEFAULTS], [ac_unique_file="$1"])]) +# _AC_INIT_DIRCHECK +# ----------------- +# Set ac_pwd, and sanity-check it and the source and installation directories. +m4_define([_AC_INIT_DIRCHECK], +[m4_divert_push([PARSE_ARGS])dnl + +ac_pwd=`pwd` && test -n "$ac_pwd" || + AC_MSG_ERROR([Working directory cannot be determined]) + +ac_pat="[[\$][{][_$as_cr_Letters][_$as_cr_alnum]*[}]]" + +for ac_dir in "$ac_pwd" "$srcdir" \ + "$bindir" "$sbindir" "$libexecdir" "$datarootdir" "$datadir" \ + "$sysconfdir" "$sharedstatedir" "$localstatedir" "$includedir" \ + "$oldincludedir" "$docdir" "$infodir" "$htmldir" "$dvidir" "$pdfdir" \ + "$psdir" "$libdir" "$localedir" "$mandir" +do + # Remove references to shell or make variables. + ac_dirx=$ac_dir + while : + do + case $ac_dirx in + *\${*}*) + ac_dirx=` + expr "X$ac_dirx" : "X\\(.*\\)$ac_pat"`X` + expr "X$ac_dirx" : "X.*$ac_pat\\(.*\\)"`;; + *) break;; + esac + done + + # Check for newline, tab, space, and other weird possibilities. + # Preserve that tab character below! + case $ac_dirx in + '' | -* | */-* | *' +'* | *' '* | *' '* | *\"* | *\#* | *\$* | *\&* | *\'* | *\(* | *\)* | \ + *\** | *\;* | *\<* | *\=* | *\>* | *\?* | *\@<:@* | *\\* | *\`* | \ + *\|* | \~*) + AC_MSG_WARN([Directory name `$ac_dir' contains special characters]);; + esac +done +m4_divert_pop([PARSE_ARGS])dnl +])# _AC_INIT_DIRCHECK + # _AC_INIT_SRCDIR # --------------- # Compute `srcdir' based on `$ac_unique_file'. @@ -1047,7 +1090,6 @@ fi if test "$ac_init_help" = "recursive"; then # If there are subdirs, report their specific --help. - ac_popdir=`pwd` for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue test -d $ac_dir || continue _AC_SRCDIRS(["$ac_dir"]) @@ -1066,7 +1108,7 @@ if test "$ac_init_help" = "recursive"; then else AC_MSG_WARN([no configuration information is in $ac_dir]) fi || ac_status=$? - cd "$ac_popdir" || { ac_status=$?; break; } + cd "$ac_pwd" || { ac_status=$?; break; } done fi @@ -1321,6 +1363,7 @@ m4_ifval([$2], [_AC_INIT_PACKAGE($@)]) _AC_INIT_DEFAULTS _AC_INIT_PARSE_ARGS _AC_INIT_SRCDIR +_AC_INIT_DIRCHECK _AC_INIT_HELP _AC_INIT_VERSION _AC_INIT_CONFIG_LOG @@ -1517,10 +1560,10 @@ Program names: --program-transform-name=PROGRAM run sed PROGRAM on installed program names m4_divert_pop([HELP_BEGIN])dnl test "$program_prefix" != NONE && - program_transform_name="s,^,$program_prefix,;$program_transform_name" + program_transform_name="s|^|$program_prefix|;$program_transform_name" # Use a double $ so make ignores it. test "$program_suffix" != NONE && - program_transform_name="s,\$,$program_suffix,;$program_transform_name" + program_transform_name="s|\$|$program_suffix|;$program_transform_name" # Double any \ or $. echo might interpret backslashes. # By default was `s,x,x', remove it if useless. cat <<\_ACEOF >conftest.sed diff --git a/lib/autoconf/status.m4 b/lib/autoconf/status.m4 index 151174488..aaafae31f 100644 --- a/lib/autoconf/status.m4 +++ b/lib/autoconf/status.m4 @@ -163,7 +163,7 @@ esac # Do not use `cd foo && pwd` to compute absolute names, because # the directories may not exist. -AS_SET_CATFILE([ac_abs_builddir], [`pwd`], [$1]) +AS_SET_CATFILE([ac_abs_builddir], [$ac_pwd], [$1]) AS_SET_CATFILE([ac_abs_top_builddir], [$ac_abs_builddir], [${ac_top_builddir}.]) AS_SET_CATFILE([ac_abs_srcdir], [$ac_abs_builddir], [$ac_srcdir]) @@ -1007,15 +1007,15 @@ _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF :t [/@[a-zA-Z_][a-zA-Z_0-9]*@/!b] -s,@configure_input@,$configure_input,;t t -s,@srcdir@,$ac_srcdir,;t t -s,@abs_srcdir@,$ac_abs_srcdir,;t t -s,@top_srcdir@,$ac_top_srcdir,;t t -s,@abs_top_srcdir@,$ac_abs_top_srcdir,;t t -s,@builddir@,$ac_builddir,;t t -s,@abs_builddir@,$ac_abs_builddir,;t t -s,@top_builddir@,$ac_top_builddir,;t t -s,@abs_top_builddir@,$ac_abs_top_builddir,;t t +s|@configure_input@|$configure_input|;t t +s|@srcdir@|$ac_srcdir|;t t +s|@abs_srcdir@|$ac_abs_srcdir|;t t +s|@top_srcdir@|$ac_top_srcdir|;t t +s|@abs_top_srcdir@|$ac_abs_top_srcdir|;t t +s|@builddir@|$ac_builddir|;t t +s|@abs_builddir@|$ac_abs_builddir|;t t +s|@top_builddir@|$ac_top_builddir|;t t +s|@abs_top_builddir@|$ac_abs_top_builddir|;t t AC_PROVIDE_IFELSE([AC_PROG_INSTALL], [s,@INSTALL@,$ac_INSTALL,;t t ])dnl dnl The parens around the eval prevent an "illegal io" in Ultrix sh. @@ -1393,7 +1393,8 @@ configured by $[0], generated by m4_PACKAGE_STRING, Copyright (C) 2005 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." -srcdir=$srcdir +ac_pwd='$ac_pwd' +srcdir='$srcdir' AC_PROVIDE_IFELSE([AC_PROG_INSTALL], [dnl Leave those double quotes here: this $INSTALL is evaluated in a dnl here document, which might result in `INSTALL=/bin/install -c'. diff --git a/lib/autotest/general.m4 b/lib/autotest/general.m4 index 64a707583..a78943a68 100644 --- a/lib/autotest/general.m4 +++ b/lib/autotest/general.m4 @@ -698,12 +698,12 @@ _ATEOF at_errexit=false ;; yes:*) - at_msg='expected failure ('`cat $at_check_line_file`')' + at_msg='expected failure ('`cat "$at_check_line_file"`')' at_xfail_list="$at_xfail_list $at_group" at_errexit=false ;; no:*) - at_msg='FAILED ('`cat $at_check_line_file`')' + at_msg='FAILED ('`cat "$at_check_line_file"`')' at_fail_list="$at_fail_list $at_group" at_errexit=$at_errexit_p ;; diff --git a/tests/Makefile.am b/tests/Makefile.am index 059b99d89..d97f1f2bc 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -1,7 +1,8 @@ ## Process this file with automake to create Makefile.in. -*-Makefile-*- ## Makefile for Autoconf testsuite. -## Copyright (C) 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +## Copyright (C) 2000, 2001, 2002, 2003, 2004, 2005 +## 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 @@ -27,7 +28,7 @@ EXTRA_DIST = $(TESTSUITE_AT) local.at mktests.sh \ check_SCRIPTS = autoconf autoheader autoreconf autom4te autoscan autoupdate ifnames DISTCLEANFILES = atconfig atlocal $(TESTSUITE) $(check_SCRIPTS) -MAINTAINERCLEANFILES = Makefile.in +MAINTAINERCLEANFILES = Makefile.in # Import the dependencies on Autotest and M4sh. include ../lib/freeze.mk @@ -60,10 +61,10 @@ wrapper.in: $(srcdir)/wrapper.as $(m4sh_m4f_dependencies) $(MY_AUTOM4TE) --language=M4sh $(srcdir)/wrapper.as -o $@ edit = sed \ - -e 's,@wrap_program\@,$@,g' \ - -e 's,@abs_top_srcdir\@,@abs_top_srcdir@,g' \ - -e 's,@abs_top_builddir\@,@abs_top_builddir@,g' \ - -e 's,@configure_input\@,Generated from $<.,g' + -e 's|@wrap_program[@]|$@|g' \ + -e 's|@abs_top_srcdir[@]|@abs_top_srcdir@|g' \ + -e 's|@abs_top_builddir[@]|@abs_top_builddir@|g' \ + -e 's|@configure_input[@]|Generated from $<.|g' $(wrappers): wrapper.in rm -f $@ $@.tmp diff --git a/tests/semantics.at b/tests/semantics.at index b71f74b18..cfbfe1c87 100644 --- a/tests/semantics.at +++ b/tests/semantics.at @@ -415,7 +415,7 @@ AT_DATA([configure.ac], [[AC_INIT pwd=`pwd` p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6" -path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'` +path=`echo $p | sed -e 's|\([[0-9]]\)|'"$pwd"'/path/\1|g'` fail=false AC_CHECK_PROG(TOOL1, tool, found, not-found, $path) @@ -426,7 +426,7 @@ AC_CHECK_PROG(TOOL2, tool,, not-found, $path) test "$TOOL2" = not-found || fail=: AC_CHECK_PROG(TOOL3, tool, tool, not-found, $path, $pwd/path/1/tool) -test "$TOOL3" = $pwd/path/2/tool || fail=: +test "$TOOL3" = "$pwd/path/2/tool" || fail=: AC_CHECK_PROG(TOOL4, better, better, not-found, $path, $pwd/path/1/tool) test "$TOOL4" = better || fail=: @@ -501,14 +501,14 @@ AT_DATA([configure.ac], [[AC_INIT pwd=`pwd` p="1${PATH_SEPARATOR}2${PATH_SEPARATOR}3${PATH_SEPARATOR}4${PATH_SEPARATOR}5${PATH_SEPARATOR}6" -path=`echo $p | sed -e 's,\([[0-9]]\),'"$pwd"'/path/\1,g'` +path=`echo $p | sed -e 's|\([[0-9]]\)|'"$pwd"'/path/\1|g'` fail=false AC_PATH_PROG(TOOL1, tool, not-found, $path) -test "$TOOL1" = $pwd/path/1/tool || fail=: +test "$TOOL1" = "$pwd/path/1/tool" || fail=: AC_PATH_PROG(TOOL2, better, not-found, $path) -test "$TOOL2" = $pwd/path/6/better || fail=: +test "$TOOL2" = "$pwd/path/6/better" || fail=: # When a tool is not found, and no value is given for not-found, # the variable is left empty. @@ -516,7 +516,7 @@ AC_PATH_PROGS(TOOL3, missing,, $path) test -z "$TOOL3" || fail=: AC_PATH_PROGS(TOOL4, missing tool better,, $path) -test "$TOOL4" = $pwd/path/1/tool || fail=: +test "$TOOL4" = "$pwd/path/1/tool" || fail=: # No AC-OUTPUT, we don't need config.status. $fail && diff --git a/tests/torture.at b/tests/torture.at index 512c02677..02daaf7a2 100644 --- a/tests/torture.at +++ b/tests/torture.at @@ -633,7 +633,7 @@ AT_CHECK([cd at-dir && ../configure], [], [ignore]) # Absolute name. at_here=`pwd` -AT_CHECK([cd at-dir && $at_here/configure], [], [ignore]) +AT_CHECK([cd at-dir && "$at_here/configure"], [], [ignore]) AT_CLEANUP