* lib/autoconf/general.m4 (AC_SITE_LOAD): Avoid leading - and path search, and check for failure to load. * tests/base.at (AC_CACHE_CHECK): Enhance test. * doc/autoconf.texi (Site Defaults): Mention that CONFIG_SITE works best as an absolute path. * NEWS: Document the semantic change.
Signed-off-by: Eric Blake <ebl...@redhat.com> --- > > Should I squash these patches into one before pushing? > However you like. > > Does the manual and NEWS need an update that $PATH-findable $CONFIG_SITE > are not allowed any more? I'm not actually sure whether this is used in > practice now, but it could be construed as a feature, no? Here's what I finally pushed; squashing all three proposals into one patch and incorporating your comment. ChangeLog | 10 ++++++++++ NEWS | 3 +++ doc/autoconf.texi | 3 ++- lib/autoconf/general.m4 | 10 ++++++++-- tests/base.at | 18 ++++++++++++++++-- 5 files changed, 39 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index c0c4bc0..ce07880 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2010-06-10 Eric Blake <ebl...@redhat.com> + + Make CONFIG_SITE handling more robust. + * lib/autoconf/general.m4 (AC_SITE_LOAD): Avoid leading - and path + search, and check for failure to load. + * tests/base.at (AC_CACHE_CHECK): Enhance test. + * doc/autoconf.texi (Site Defaults): Mention that CONFIG_SITE + works best as an absolute path. + * NEWS: Document the semantic change. + 2010-03-13 Bruno Haible <br...@clisp.org> and Ralf Wildenhues <ralf.wildenh...@gmx.de> diff --git a/NEWS b/NEWS index 5c0d130..3e1155c 100644 --- a/NEWS +++ b/NEWS @@ -28,6 +28,9 @@ GNU Autoconf NEWS - User visible changes. and `--with-*' arguments, converting them to underscores for the variable names. +** In configure scripts, loading CONFIG_SITE no longer searches PATH, + and problems in loading the configuration site files are diagnosed. + * Major changes in Autoconf 2.65 (2009-11-21) [stable] Released by Eric Blake, based on git versions 2.64.*. diff --git a/doc/autoconf.texi b/doc/autoconf.texi index 519158c..42469db 100644 --- a/doc/autoconf.texi +++ b/doc/autoconf.texi @@ -20980,7 +20980,8 @@ Site Defaults @evindex CONFIG_SITE If the environment variable @code{CONFIG_SITE} is set, @command{configure} -uses its value as the name of a shell script to read. Otherwise, it +uses its value as the name of a shell script to read; it is recommended +that this be an absolute file name. Otherwise, it reads the shell script @fi...@var{prefix}/share/config.site} if it exists, then @fi...@var{prefix}/etc/config.site} if it exists. Thus, settings in machine-specific files override those in machine-independent diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4 index e764b16..cadec67 100644 --- a/lib/autoconf/general.m4 +++ b/lib/autoconf/general.m4 @@ -1870,7 +1870,12 @@ m4_define([AC_SITE_LOAD], ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then - ac_site_file1=$CONFIG_SITE + # We do not want a PATH search for config.site. + case $CONFIG_SITE in @%:@(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site @@ -1884,7 +1889,8 @@ do if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then AC_MSG_NOTICE([loading site script $ac_site_file]) sed 's/^/| /' "$ac_site_file" >&AS_MESSAGE_LOG_FD - . "$ac_site_file" + . "$ac_site_file" \ + || AC_MSG_FAILURE([failed to load site script $ac_site_file]) fi done ]) diff --git a/tests/base.at b/tests/base.at index 54ccd8a..8f6e30f 100644 --- a/tests/base.at +++ b/tests/base.at @@ -258,6 +258,7 @@ AT_CLEANUP # Also make sure we warn about cache id's not named with `_cv_'. AT_SETUP([AC_CACHE_CHECK]) +AT_KEYWORDS([CONFIG_SITE]) # Don't let a config.site file affect this test. AS_UNSET([CONFIG_SITE]) @@ -395,13 +396,14 @@ AT_CHECK([grep cache stdout], [1]) AT_CHECK([LC_ALL=C ls -t config.cache a-stamp-file | sed 1q | grep config.cache], [1]) # config.site can specify a site-wide cache, accumulating information. -AT_DATA([config.site], +# Also test that we don't run afoul of sourcing a file with leading -. +AT_DATA([-config.site], [[cache_file=sitecache ]]) AT_DATA([sitecache], [[my_cv_some_preset_cache_var=yes ]]) -CONFIG_SITE=config.site +CONFIG_SITE=-config.site export CONFIG_SITE AT_CHECK_CONFIGURE AT_CHECK([grep my_cv_some_preset_cache_var sitecache], [], [ignore]) @@ -409,6 +411,18 @@ AT_CHECK([grep my_cv_shell_true_works sitecache], [], [ignore]) AT_CHECK_CONFIGURE([], [], [stdout]) AT_CHECK([grep 'whether true.*works.*cached' stdout], [], [ignore]) +# Check that config cache scripts must be well-formed. +AT_DATA([bad.site], +[[fi +]]) +CONFIG_SITE=$PWD/bad.site +AT_CHECK_CONFIGURE([], [1], [ignore], [stderr]) +AT_CHECK([grep 'failed to load site script' stderr], [], [ignore]) + +# However, a missing file is ignored. +CONFIG_SITE=./no-such-file +AT_CHECK_CONFIGURE + AT_CLEANUP -- 1.7.0.1