diff --git a/tuned/profiles/variables.py b/tuned/profiles/variables.py index 58919e1..9ff0a84 100644 --- a/tuned/profiles/variables.py +++ b/tuned/profiles/variables.py @@ -22,12 +22,20 @@ class Variables(): return s return prefix + s + def _check_var(self, variable): + return re.match(r'\w+$',variable) + def add_variable(self, variable, value): if value is None: return s = str(variable) + if not self._check_var(variable): + log.error("variable definition '%s' contains unallowed characters" % variable) + return v = self.expand(value) - self._lookup_re[r'\${' + re.escape(s) + r'}'] = v + # variables referenced by ${VAR}, $ can be escaped by two $, + # i.e. the following will not expand: $${VAR} + self._lookup_re[r'(?