diff options
-rwxr-xr-x | bitbake/bin/bitbake-layers | 6 | ||||
-rw-r--r-- | bitbake/lib/bb/cooker.py | 3 | ||||
-rw-r--r-- | bitbake/lib/bb/data.py | 15 | ||||
-rw-r--r-- | bitbake/lib/bb/utils.py | 23 |
4 files changed, 29 insertions, 18 deletions
diff --git a/bitbake/bin/bitbake-layers b/bitbake/bin/bitbake-layers index 88fb8ea939..119b15c172 100755 --- a/bitbake/bin/bitbake-layers +++ b/bitbake/bin/bitbake-layers | |||
@@ -31,9 +31,10 @@ def main(args): | |||
31 | console.setFormatter(format) | 31 | console.setFormatter(format) |
32 | logger.addHandler(console) | 32 | logger.addHandler(console) |
33 | 33 | ||
34 | initialenv = os.environ.copy() | ||
34 | bb.utils.clean_environment() | 35 | bb.utils.clean_environment() |
35 | 36 | ||
36 | cmds = Commands() | 37 | cmds = Commands(initialenv) |
37 | if args: | 38 | if args: |
38 | cmds.onecmd(' '.join(args)) | 39 | cmds.onecmd(' '.join(args)) |
39 | else: | 40 | else: |
@@ -42,9 +43,8 @@ def main(args): | |||
42 | 43 | ||
43 | 44 | ||
44 | class Commands(cmd.Cmd): | 45 | class Commands(cmd.Cmd): |
45 | def __init__(self): | 46 | def __init__(self, initialenv): |
46 | cmd.Cmd.__init__(self) | 47 | cmd.Cmd.__init__(self) |
47 | initialenv = os.environ.copy() | ||
48 | self.returncode = 0 | 48 | self.returncode = 0 |
49 | self.config = Config(parse_only=True) | 49 | self.config = Config(parse_only=True) |
50 | self.cooker = bb.cooker.BBCooker(self.config, | 50 | self.cooker = bb.cooker.BBCooker(self.config, |
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 | ||
162 | def inheritFromOS(d, savedenv): | 162 | def 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 | ||
173 | def emit_var(var, o=sys.__stdout__, d = init(), all=False): | 174 | def 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 | ||
568 | def 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 | |||
568 | def clean_environment(): | 582 | def 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 | ||
582 | def empty_environment(): | 591 | def empty_environment(): |