diff options
| author | Max Martin <max@puppetlabs.com> | 2011-07-06 15:04:27 -0700 |
|---|---|---|
| committer | Matt Robinson <matt@puppetlabs.com> | 2011-07-14 13:01:02 -0700 |
| commit | b268fb3d4cca79bdce0adc7da8b4d47f20769521 (patch) | |
| tree | 8f23e45cc52d2040ade181487a601bca84f4c9aa | |
| parent | b8e67ba44f7605260bc3141250d746ae748df2a2 (diff) | |
| download | puppet-b268fb3d4cca79bdce0adc7da8b4d47f20769521.tar.gz puppet-b268fb3d4cca79bdce0adc7da8b4d47f20769521.tar.xz puppet-b268fb3d4cca79bdce0adc7da8b4d47f20769521.zip | |
(#7144) Update Settings#writesub to convert mode to Fixnum
Settings#writesub was not checking the type of the mode value passed in
from the defaults, causing it to pass a string for mode to File.open,
leading to failures. This commit resolves that issue.
Paired-with: Matt Robinson <matt@puppetlabs.com>
| -rw-r--r-- | lib/puppet/util.rb | 1 | ||||
| -rw-r--r-- | lib/puppet/util/settings.rb | 2 | ||||
| -rwxr-xr-x | spec/unit/util/settings_spec.rb | 11 |
3 files changed, 12 insertions, 2 deletions
diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb index d06f44808..34c6ec1ed 100644 --- a/lib/puppet/util.rb +++ b/lib/puppet/util.rb @@ -29,7 +29,6 @@ module Util end end - def self.synchronize_on(x,type) sync_object,users = 0,1 begin diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb index f243b8691..4559e9af3 100644 --- a/lib/puppet/util/settings.rb +++ b/lib/puppet/util/settings.rb @@ -721,7 +721,7 @@ if @config.include?(:run_mode) end Puppet::Util::SUIDManager.asuser(*chown) do - mode = obj.mode || 0640 + mode = obj.mode ? obj.mode.to_i : 0640 args << "w" if args.empty? args << mode diff --git a/spec/unit/util/settings_spec.rb b/spec/unit/util/settings_spec.rb index 07b712c08..888de156b 100755 --- a/spec/unit/util/settings_spec.rb +++ b/spec/unit/util/settings_spec.rb @@ -1,6 +1,7 @@ #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../../spec_helper' +require 'ostruct' describe Puppet::Util::Settings do describe "when specifying defaults" do @@ -1105,4 +1106,14 @@ describe Puppet::Util::Settings do it "should cache the result" end + + describe "#writesub" do + it "should only pass valid arguments to File.open" do + settings = Puppet::Util::Settings.new + settings.stubs(:get_config_file_default).with(:privatekeydir).returns(OpenStruct.new(:mode => "750")) + + File.expects(:open).with("/path/to/keydir", "w", 750).returns true + settings.writesub(:privatekeydir, "/path/to/keydir") + end + end end |
