summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb
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:49:37 +0100
commit61d83c6d6b23ea0fa3f99dfb53bf47c727c5a1c6 (patch)
treecbddb0ea6bd9505fc99eb8500b27980d65b9bd59 /bitbake/lib/bb
parenta6c48298b17e6a5844b3638b422fe226e3b67b89 (diff)
downloadpoky-61d83c6d6b23ea0fa3f99dfb53bf47c727c5a1c6.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> (Bitbake rev: cb6c07054e8baf94614713ec257c643b22266d75) Signed-off-by: Joshua Lock <josh@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r--bitbake/lib/bb/cooker.py3
-rw-r--r--bitbake/lib/bb/data.py15
-rw-r--r--bitbake/lib/bb/utils.py23
3 files changed, 26 insertions, 15 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index f7d9923f19..ff508f6b5e 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -169,7 +169,8 @@ class BBCooker:
169 if not self.server_registration_cb: 169 if not self.server_registration_cb:
170 bb.data.setVar("BB_WORKERCONTEXT", "1", self.configuration.data) 170 bb.data.setVar("BB_WORKERCONTEXT", "1", self.configuration.data)
171 171
172 bb.data.inheritFromOS(self.configuration.data, self.savedenv) 172 filtered_keys = bb.utils.approved_variables()
173 bb.data.inheritFromOS(self.configuration.data, self.savedenv, filtered_keys)
173 174
174 try: 175 try:
175 self.parseConfigurationFiles(self.configuration.prefile, 176 self.parseConfigurationFiles(self.configuration.prefile,
diff --git a/bitbake/lib/bb/data.py b/bitbake/lib/bb/data.py
index 65144bfe52..ac0d8809cc 100644
--- a/bitbake/lib/bb/data.py
+++ b/bitbake/lib/bb/data.py
@@ -159,16 +159,17 @@ def expandKeys(alterdata, readdata = None):
159 ekey = todolist[key] 159 ekey = todolist[key]
160 renameVar(key, ekey, alterdata) 160 renameVar(key, ekey, alterdata)
161 161
162def inheritFromOS(d, savedenv): 162def inheritFromOS(d, savedenv, permitted):
163 """Inherit variables from the initial environment.""" 163 """Inherit variables from the initial environment."""
164 exportlist = bb.utils.preserved_envvars_exported() 164 exportlist = bb.utils.preserved_envvars_exported()
165 for s in savedenv.keys(): 165 for s in savedenv.keys():
166 try: 166 if s in permitted:
167 setVar(s, getVar(s, savedenv, True), d) 167 try:
168 if s in exportlist: 168 setVar(s, getVar(s, savedenv, True), d)
169 setVarFlag(s, "export", True, d) 169 if s in exportlist:
170 except TypeError: 170 setVarFlag(s, "export", True, d)
171 pass 171 except TypeError:
172 pass
172 173
173def emit_var(var, o=sys.__stdout__, d = init(), all=False): 174def emit_var(var, o=sys.__stdout__, d = init(), all=False):
174 """Emit a variable to be sourced by a shell.""" 175 """Emit a variable to be sourced by a shell."""
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):
565 for k in preserved_envvars_exported_interactive(): 565 for k in preserved_envvars_exported_interactive():
566 os.setenv(k, bb.data.getVar(k, d, True)) 566 os.setenv(k, bb.data.getVar(k, d, True))
567 567
568def approved_variables():
569 """
570 Determine and return the list of whitelisted variables which are approved
571 to remain in the envrionment.
572 """
573 approved = []
574 if 'BB_ENV_WHITELIST' in os.environ:
575 approved = os.environ['BB_ENV_WHITELIST'].split()
576 else:
577 approved = preserved_envvars()
578 if 'BB_ENV_EXTRAWHITE' in os.environ:
579 approved.extend(os.environ['BB_ENV_EXTRAWHITE'].split())
580 return approved
581
568def clean_environment(): 582def clean_environment():
569 """ 583 """
570 Clean up any spurious environment variables. This will remove any 584 Clean up any spurious environment variables. This will remove any
571 variables the user hasn't chose to preserve. 585 variables the user hasn't chosen to preserve.
572 """ 586 """
573 if 'BB_PRESERVE_ENV' not in os.environ: 587 if 'BB_PRESERVE_ENV' not in os.environ:
574 if 'BB_ENV_WHITELIST' in os.environ: 588 good_vars = approved_variables()
575 good_vars = os.environ['BB_ENV_WHITELIST'].split()
576 else:
577 good_vars = preserved_envvars()
578 if 'BB_ENV_EXTRAWHITE' in os.environ:
579 good_vars.extend(os.environ['BB_ENV_EXTRAWHITE'].split())
580 filter_environment(good_vars) 589 filter_environment(good_vars)
581 590
582def empty_environment(): 591def empty_environment():