summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xlib/puppet/type/pfile/mode.rb5
-rwxr-xr-xtest/util/config.rb13
2 files changed, 14 insertions, 4 deletions
diff --git a/lib/puppet/type/pfile/mode.rb b/lib/puppet/type/pfile/mode.rb
index 96e29aabb..e29e74235 100755
--- a/lib/puppet/type/pfile/mode.rb
+++ b/lib/puppet/type/pfile/mode.rb
@@ -39,7 +39,7 @@ module Puppet
# octal, yet the number can only be specified as a string right now
value = should
if value.is_a?(String)
- unless value =~ /^[0-9]+$/
+ unless value =~ /^\d+$/
raise Puppet::Error, "File modes can only be numbers, not %s" %
value.inspect
end
@@ -47,11 +47,12 @@ module Puppet
unless value =~ /^0/
value = "0" + value
end
+ old = value
begin
value = Integer(value)
rescue ArgumentError => detail
raise Puppet::DevError, "Could not convert %s to integer" %
- value.inspect
+ old.inspect
end
end
diff --git a/test/util/config.rb b/test/util/config.rb
index 742b15b7b..924d73709 100755
--- a/test/util/config.rb
+++ b/test/util/config.rb
@@ -1037,7 +1037,7 @@ inttest = 27
:default => "/some/file"})
File.open(config, "w") { |f| f.puts "[#{Puppet[:name]}]
- mode = 750
+ mode = 755
group = foo
ssldir = #{file}
"}
@@ -1055,7 +1055,16 @@ inttest = 27
# Now make them valid params
@config.setdefaults(Puppet[:name], :group => ["blah", "yay"])
- @config.setdefaults(Puppet[:name], :mode => ["755", "yay"])
+ @config.setdefaults(Puppet[:name], :mode => ["750", "yay"])
+
+ assert_nothing_raised do
+ @config.parse(config)
+ end
+
+ assert_equal("foo", @config[:group],
+ "Did not store group when it is a valid config")
+ assert_equal("755", @config[:mode],
+ "Did not store mode when it is a valid config")
end
end