]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
Make CONFIG_SITE handling more robust.
authorEric Blake <eblake@redhat.com>
Tue, 8 Jun 2010 12:25:35 +0000 (06:25 -0600)
committerEric Blake <eblake@redhat.com>
Mon, 14 Jun 2010 20:40:49 +0000 (14:40 -0600)
* 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 <eblake@redhat.com>
ChangeLog
NEWS
doc/autoconf.texi
lib/autoconf/general.m4
tests/base.at

index c0c4bc0f44aa9cc34fe00e9e9a7d2998325f627d..4e75a7657df73d6dd888f61a9b450e4121419beb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2010-06-14  Eric Blake  <eblake@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  <bruno@clisp.org>
        and Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
diff --git a/NEWS b/NEWS
index 5c0d1309f20cf472f2175b073fb33c0e960c2c8f..3e1155ce53c332314ae88ff5f0afab45d8917f01 100644 (file)
--- 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.*.
 
index 519158c2eacd6670c71b60f23adde8ce82fdf045..42469db6de8f37310b174558b227e4ff10f8d9e0 100644 (file)
@@ -20980,7 +20980,8 @@ site- and system-wide initialization files.
 
 @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 @file{@var{prefix}/share/config.site} if it exists,
 then @file{@var{prefix}/etc/config.site} if it exists.  Thus,
 settings in machine-specific files override those in machine-independent
index e764b160bb31abba3235e89eeb3d5bd0084a038e..cadec67a5c627ed64e7dfee018218ef142d6ce43 100644 (file)
@@ -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
 ])
index 54ccd8ad256830a49af303a82f18e0255f286339..8f6e30fac0f6efc48784c92da3f652b85a8fc33e 100644 (file)
@@ -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