From d640bf899a36d5e82de823c1fb46f2e2c7a4a6bc Mon Sep 17 00:00:00 2001 From: Diego Magdaleno <38844659+DiegoMagdaleno@users.noreply.github.com> Date: Sat, 18 Apr 2020 16:25:19 -0500 Subject: autotools: set FORCE_UNSAFE_CONFIGURE to 1 in autotools.py (#16132) This commit sets the `FORCE_UNSAFE_CONFIGURE` environment variable to 1 in autotools builds. We see a lot of builds popping up and complaining about `FORCE_UNSAFE_CONFIGURE`. This behavior is not actually part of `autoconf` per se. It comes from this patch to `mknod.m4`, which is used by a lot of autoconf builds: * https://lists.gnu.org/archive/html/bug-gnulib/2010-07/msg00282.html Which originated from this problem that someone had on AIX: * https://lists.gnu.org/archive/html/bug-gnulib/2010-07/msg00279.html The gist of the problem seems to be that they want to check whether `mknod` can do something as root, but instead of checking whether they're running as root and using `su` or something to test this, they just made it harder to run `configure` as root. This seems very ad hoc and this is one of many checks that are run as root in `configure`. Many of them run before this check, so it's not clear that the `FORCE_UNSAFE_CONFIGURE` thing is even preventing bad things from happening. So: 1. This only happens in `autotools` builds, so we should go ahead and put it into `autotools.py` instead of in the global build environment, and 2. The variable does too little and provides a false sense of security in the first place, so we'll just disable it and avoid the nuisance. If we really feel strongly about this we can put some warnings in Spack about running as root, but at the top level, not in the middle of an already running script like `configure`. --- lib/spack/spack/build_systems/autotools.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib') diff --git a/lib/spack/spack/build_systems/autotools.py b/lib/spack/spack/build_systems/autotools.py index df17d2ddf1..6fc77bee6a 100644 --- a/lib/spack/spack/build_systems/autotools.py +++ b/lib/spack/spack/build_systems/autotools.py @@ -153,6 +153,21 @@ class AutotoolsPackage(PackageBase): raise RuntimeError('Failed to find suitable config.guess') + @run_before('configure') + def _set_autotools_environment_varoables(self): + """Many autotools builds use a version of mknod.m4 that fails when + running as root unless FORCE_UNSAFE_CONFIGURE is set to 1. + + We set this to 1 and expect the user to take responsibiltiy if + they are running as root. They have to anyway, as this variable + doesn't actually prevent configure from doing bad things as root. + Without it, configure just fails halfway through, but it can + still run things *before* this check. Forcing this just removes a + nuisance -- this is not circumventing any real protection. + + """ + os.environ["FORCE_UNSAFE_CONFIGURE"] = "1" + @run_after('configure') def _do_patch_libtool(self): """If configure generates a "libtool" script that does not correctly -- cgit v1.2.3-60-g2f50