diff options
author | Jesse Wolfe <jes5199@gmail.com> | 2009-10-16 23:45:02 -0700 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-10-19 19:47:07 +1100 |
commit | f59f8054dc0d1c86169b954fab96df650f38dd23 (patch) | |
tree | a2de2de0a2c784b6b889b038724a9a05858ee1be /lib/puppet | |
parent | 6ba122f62bf22c955a6923604a46a8ab22d8770b (diff) | |
download | puppet-f59f8054dc0d1c86169b954fab96df650f38dd23.tar.gz puppet-f59f8054dc0d1c86169b954fab96df650f38dd23.tar.xz puppet-f59f8054dc0d1c86169b954fab96df650f38dd23.zip |
Bug #1900 Parsing of quoted $ in stdin
When code comes in via STDIN or --code ,
Puppet::Util::Settings interpolates $values in the code,
which is probably never the intended behavior.
This is the least destructive fix I could think of:
have Puppet::Parser::Interpreter ask for the uninterpolated value.
More general fixes could be to:
a) Add an escape character to Settings's interpolator, and escape STDIN
b) Add a mechanism to Settings to mark some values as uninterpolated
Signed-off-by: Jesse Wolfe <jes5199@gmail.com>
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/parser/interpreter.rb | 2 | ||||
-rw-r--r-- | lib/puppet/util/settings.rb | 41 |
2 files changed, 26 insertions, 17 deletions
diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb index 2e8924090..bc0ae4fdf 100644 --- a/lib/puppet/parser/interpreter.rb +++ b/lib/puppet/parser/interpreter.rb @@ -62,7 +62,7 @@ class Puppet::Parser::Interpreter def create_parser(environment) begin parser = Puppet::Parser::Parser.new(:environment => environment) - if code = Puppet.settings.value(:code, environment) and code != "" + if code = Puppet.settings.uninterpolated_value(:code, environment) and code != "" parser.string = code else file = Puppet.settings.value(:manifest, environment) diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb index 3e3bc7f76..e80c7cc8f 100644 --- a/lib/puppet/util/settings.rb +++ b/lib/puppet/util/settings.rb @@ -653,6 +653,30 @@ Generated on #{Time.now}. @config.has_key?(param) end + def uninterpolated_value(param, environment = nil) + param = param.to_sym + environment = environment.to_sym if environment + + # See if we can find it within our searchable list of values + val = catch :foundval do + each_source(environment) do |source| + # Look for the value. We have to test the hash for whether + # it exists, because the value might be false. + @sync.synchronize do + if @values[source].include?(param) + throw :foundval, @values[source][param] + end + end + end + throw :foundval, nil + end + + # If we didn't get a value, use the default + val = @config[param].default if val.nil? + + return val + end + # Find the correct value using our search path. Optionally accept an environment # in which to search before the other configuration sections. def value(param, environment = nil) @@ -672,22 +696,7 @@ Generated on #{Time.now}. return cached end - # See if we can find it within our searchable list of values - val = catch :foundval do - each_source(environment) do |source| - # Look for the value. We have to test the hash for whether - # it exists, because the value might be false. - @sync.synchronize do - if @values[source].include?(param) - throw :foundval, @values[source][param] - end - end - end - throw :foundval, nil - end - - # If we didn't get a value, use the default - val = @config[param].default if val.nil? + val = uninterpolated_value(param, environment) # Convert it if necessary val = convert(val, environment) |