+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>
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.*.
@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
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
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
])
# 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])
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])
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