summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordsmith <dsmith>2007-06-20 18:00:39 +0000
committerdsmith <dsmith>2007-06-20 18:00:39 +0000
commit861c2f286ff7e68cbe93f7bc8e43b60638f52848 (patch)
tree51b1370cb4656a8263c9c480dcdedbdb0e4f8216
parentcb53a4f46d192cd6870d873a1c8b2586eb6bd3b4 (diff)
downloadsystemtap-steved-861c2f286ff7e68cbe93f7bc8e43b60638f52848.tar.gz
systemtap-steved-861c2f286ff7e68cbe93f7bc8e43b60638f52848.tar.xz
systemtap-steved-861c2f286ff7e68cbe93f7bc8e43b60638f52848.zip
2007-06-20 David Smith <dsmith@redhat.com>
* buildrun.cxx (compile_pass): Unset environment variables that could interfere with building the kernel module. Fixes PR 4664. * main.cxx (main): Unsets a few standard environment variables for safety.
-rw-r--r--ChangeLog7
-rw-r--r--buildrun.cxx12
-rw-r--r--main.cxx10
3 files changed, 29 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index c9b84f09..a5f3611e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2007-06-20 David Smith <dsmith@redhat.com>
+
+ * buildrun.cxx (compile_pass): Unset environment variables that
+ could interfere with building the kernel module. Fixes PR 4664.
+ * main.cxx (main): Unsets a few standard environment variables for
+ safety.
+
2007-06-18 David Smith <dsmith@redhat.com>
* staprun.8.in: Fixed a couple of typos.
diff --git a/buildrun.cxx b/buildrun.cxx
index 13aa9da7..2e6d18d7 100644
--- a/buildrun.cxx
+++ b/buildrun.cxx
@@ -93,6 +93,18 @@ compile_pass (systemtap_session& s)
return rc;
}
+ // Before running make, fix up the environment a bit. PATH should
+ // already be overridden. Clean out a few variables that
+ // /lib/modules/${KVER}/build/Makefile uses.
+ rc = unsetenv("ARCH") || unsetenv("KBUILD_EXTMOD")
+ || unsetenv("CROSS_COMPILE") || unsetenv("KBUILD_IMAGE")
+ || unsetenv("KCONFIG_CONFIG") || unsetenv("INSTALL_PATH");
+ if (rc)
+ {
+ const char* e = strerror (errno);
+ cerr << "unsetenv failed: " << e << endl;
+ }
+
// Run make
string make_cmd = string("make")
+ string (" -C \"") + module_dir + string("\"");
diff --git a/main.cxx b/main.cxx
index 6c28b25e..f5740aa9 100644
--- a/main.cxx
+++ b/main.cxx
@@ -461,6 +461,16 @@ main (int argc, char * const argv [])
<< e << endl;
}
+ // Get rid of a few standard environment variables (which might
+ // cause us to do unintended things).
+ rc = unsetenv("IFS") || unsetenv("CDPATH") || unsetenv("ENV")
+ || unsetenv("BASH_ENV");
+ if (rc)
+ {
+ const char* e = strerror (errno);
+ cerr << "unsetenv failed: " << e << endl;
+ }
+
s.kernel_base_release.assign(s.kernel_release, 0, s.kernel_release.find('-'));
// arguments parsed; get down to business