From 964085f701a58c9a612e1230961fe3c22fede7ba Mon Sep 17 00:00:00 2001 From: Chris Larson Date: Wed, 24 Mar 2010 18:58:59 -0700 Subject: data_smart: be explicit about what we make available to eval'd python code (Bitbake rev: 6a73dda60f50e9b3e5513795d1ec7207d1446de2) Signed-off-by: Chris Larson Signed-off-by: Richard Purdie --- bitbake/lib/bb/data_smart.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'bitbake') diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py index dac7fb705e..9067d54bfa 100644 --- a/bitbake/lib/bb/data_smart.py +++ b/bitbake/lib/bb/data_smart.py @@ -39,6 +39,11 @@ __setvar_keyword__ = ["_append","_prepend"] __setvar_regexp__ = re.compile('(?P.*?)(?P_append|_prepend)(_(?P.*))?') __expand_var_regexp__ = re.compile(r"\${[^{}]+}") __expand_python_regexp__ = re.compile(r"\${@.+?}") +_expand_globals = { + "os": os, + "bb": bb, + "time": time, +} class DataSmart: @@ -50,6 +55,7 @@ class DataSmart: self._seen_overrides = seen self.expand_cache = {} + self.expand_locals = {"d": self} def expand(self,s, varname): def var_sub(match): @@ -66,8 +72,7 @@ class DataSmart: def python_sub(match): import bb code = match.group()[3:-1] - locals()['d'] = self - s = eval(code) + s = eval(code, _expand_globals, self.expand_locals) if type(s) == types.IntType: s = str(s) return s -- cgit v1.2.3-54-g00ecf