It seems like we should just allow "magic removal" ala \$ to get a literal 
dollar sign.

On Apr 11, 2012, at 1:08 PM, Jeff Weiss wrote:

> Community contribution to bypass variable interpolation.
> 
> Before I merge, I have a few concerns:
>  1. We're making a specific exemption for dbpassword.
>  2. Do we have a case to do this for other items?
>  3. Should we look for more general ways to handle this?
>  4. Should we provide a way to escape variable interpolation instead of just 
> turning it off wholesale for certain settings?
> 
> Thoughts? Objections?
> 
> Cheers,
> 
> Jeff
> 
> On Sat, Apr 7, 2012 at 4:15 PM, <[email protected]> wrote:
> Please review pull request #640: (#13679) Skip variable interpolation on 
> dbpassword setting opened by (stschulte)
> 
> Description:
> 
> when puppet reads /etc/puppet/puppet.conf it does variable interpolation
> when receiving a setting. The convert method that is involved here does
> not allow for escaping/quoting or any other mechanism to stop variable
> interpolation. While most settings do not allow a dollar-sign anyways
> the dbpassword may legally include one.
> 
> I'm not sure if we need a general escaping mechanism or if we should just 
> skip value interpolation for different settings. I'm afraid that introducing 
> quoting and esacping in /etc/puppet.conf would both make the parser and the 
> file itself needlessly complex for a single usecase. In my opinion dbpassword 
> is the only setting that may legally include a dollar sign and I cannot come 
> up with a usecase where you do want to have value interpolation on 
> dbpassword. So the fix attached in the branch field just skips validation on 
> dbpassword.
> 
> But I'm happy to hear different opinions.
> 
> 
> Opened: Sat Apr 07 23:06:04 UTC 2012
> Based on: puppetlabs:2.7.x (8ceaaf002a5562b6bd78541a25762e1e7740f933)
> Requested merge: stschulte:ticket/2.7.x/13679 
> (045be1c96692a5a4cc5420091932ce0a18329568)
> Diff follows:
> diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb
> index e57cc8c..3d1c804 100644
> --- a/lib/puppet/util/settings.rb
> +++ b/lib/puppet/util/settings.rb
> @@ -687,7 +687,9 @@ def value(param, environment = nil)
>      end
>  
>      # Convert it if necessary
> -    val = convert(val, environment)
> +    unless param == :dbpassword
> +      val = convert(val, environment)
> +    end
>  
>      # And cache it
>      @cache[environment||"none"][param] = val
> diff --git a/spec/unit/util/settings_spec.rb b/spec/unit/util/settings_spec.rb
> index 7af43c0..9d66f99 100755
> --- a/spec/unit/util/settings_spec.rb
> +++ b/spec/unit/util/settings_spec.rb
> @@ -235,7 +235,7 @@
>    describe "when returning values" do
>      before do
>        @settings = Puppet::Util::Settings.new
> -      @settings.setdefaults :section, :config => ["/my/file", "eh"], :one => 
> ["ONE", "a"], :two => ["$one TWO", "b"], :three => ["$one $two THREE", "c"], 
> :four => ["$two $three FOUR", "d"]
> +      @settings.setdefaults :section, :config => ["/my/file", "eh"], :one => 
> ["ONE", "a"], :two => ["$one TWO", "b"], :three => ["$one $two THREE", "c"], 
> :four => ["$two $three FOUR", "d"], :dbpassword => ["puppet", "e" ]
>        FileTest.stubs(:exist?).returns true
>      end
>  
> @@ -277,6 +277,11 @@
>        @settings[:two].should == "one TWO"
>      end
>  
> +    it "should not interpolate dbpassword" do
> +      @settings[:dbpassword] = "my$one"
> +      @settings[:dbpassword].should == "my$one"
> +    end
> +
>      it "should not cache values such that information from one environment 
> is returned for another environment" do
>        text = "[env1]\none = oneval\n[env2]\none = twoval\n"
>        @settings.stubs(:read_file).returns(text)
> 
>     
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Developers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/puppet-dev?hl=en.
> 
> 
> -- 
> You received this message because you are subscribed to the Google Groups 
> "Puppet Developers" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/puppet-dev?hl=en.

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to