From 61d83c6d6b23ea0fa3f99dfb53bf47c727c5a1c6 Mon Sep 17 00:00:00 2001 From: Joshua Lock Date: Fri, 12 Aug 2011 17:58:11 -0700 Subject: 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 CC: Chris Larson (Bitbake rev: cb6c07054e8baf94614713ec257c643b22266d75) Signed-off-by: Joshua Lock Signed-off-by: Richard Purdie --- bitbake/lib/bb/utils.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'bitbake/lib/bb/utils.py') diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 1cf1a8da44..1f5540716a 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/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(): -- cgit v1.2.3-54-g00ecf