summaryrefslogtreecommitdiffstats
path: root/lib/bb/utils.py
diff options
context:
space:
mode:
authorJoshua Lock <josh@linux.intel.com>2011-08-12 17:58:11 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-08-15 09:41:13 +0100
commitcb6c07054e8baf94614713ec257c643b22266d75 (patch)
treeec0cabe1dd58931bc7113a7d8ceda385a2121a39 /lib/bb/utils.py
parent7627b561cbcb1482b464d69db70f38ea663180f3 (diff)
downloadbitbake-contrib-cb6c07054e8baf94614713ec257c643b22266d75.tar.gz
Ensure only the filtered environment variables are inherited from the OS
The recent change which modified inheritFromOS to use the intial environment, rather than the current environment, introduced a bug such that variables which had been cleaned from the environment where still set in the data store. This patch changes things such that a list of approved environment variables is saved after the environment is cleaned and only the variables in this list are inherited in inheritFromOS. CC: James Limbouris <james.limbouris@gmail.com> CC: Chris Larson <clarson@kergoth.com> Signed-off-by: Joshua Lock <josh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/utils.py')
-rw-r--r--lib/bb/utils.py23
1 files changed, 16 insertions, 7 deletions
diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 1cf1a8da4..1f5540716 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -565,18 +565,27 @@ def create_interactive_env(d):
for k in preserved_envvars_exported_interactive():
os.setenv(k, bb.data.getVar(k, d, True))
+def approved_variables():
+ """
+ Determine and return the list of whitelisted variables which are approved
+ to remain in the envrionment.
+ """
+ approved = []
+ if 'BB_ENV_WHITELIST' in os.environ:
+ approved = os.environ['BB_ENV_WHITELIST'].split()
+ else:
+ approved = preserved_envvars()
+ if 'BB_ENV_EXTRAWHITE' in os.environ:
+ approved.extend(os.environ['BB_ENV_EXTRAWHITE'].split())
+ return approved
+
def clean_environment():
"""
Clean up any spurious environment variables. This will remove any
- variables the user hasn't chose to preserve.
+ variables the user hasn't chosen to preserve.
"""
if 'BB_PRESERVE_ENV' not in os.environ:
- if 'BB_ENV_WHITELIST' in os.environ:
- good_vars = os.environ['BB_ENV_WHITELIST'].split()
- else:
- good_vars = preserved_envvars()
- if 'BB_ENV_EXTRAWHITE' in os.environ:
- good_vars.extend(os.environ['BB_ENV_EXTRAWHITE'].split())
+ good_vars = approved_variables()
filter_environment(good_vars)
def empty_environment():