Looks like [2265] was not a complete solution -- it resulted in failures when the config set modes via integers. Everything is working now, and tested more completely.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2268 980ebf18-57e1-0310-9a29-db15c13687c0
This commit is contained in:
Родитель
0925fb0cd9
Коммит
b6df3369bc
|
@ -43,6 +43,7 @@ module Puppet
|
|||
raise Puppet::Error, "File modes can only be numbers, not %s" %
|
||||
value.inspect
|
||||
end
|
||||
# Make sure our number looks like octal.
|
||||
unless value =~ /^0/
|
||||
value = "0" + value
|
||||
end
|
||||
|
|
|
@ -281,7 +281,11 @@ class Puppet::Util::Config
|
|||
when /^\s*$/: next # Skip blanks
|
||||
when /^\s*(\w+)\s*=\s*(.+)$/: # settings
|
||||
var = $1.intern
|
||||
value = mungearg($2)
|
||||
if var == :mode
|
||||
value = $2
|
||||
else
|
||||
value = mungearg($2)
|
||||
end
|
||||
|
||||
# Only warn if we don't know what this config var is. This
|
||||
# prevents exceptions later on.
|
||||
|
@ -304,7 +308,6 @@ class Puppet::Util::Config
|
|||
if var == :group and section == Puppet[:name] and @config.include?(:group)
|
||||
@config[:group].value = value
|
||||
end
|
||||
next
|
||||
end
|
||||
|
||||
# Don't override set parameters, since the file is parsed
|
||||
|
@ -905,9 +908,9 @@ Generated on #{Time.now}.
|
|||
end
|
||||
[:mode].each { |var|
|
||||
if value = self.send(var)
|
||||
# Convert it to a string, and the object will correctly
|
||||
# convert it to octal.
|
||||
obj[var] = value.to_s
|
||||
# Don't both converting the mode, since the file type
|
||||
# can handle it any old way.
|
||||
obj[var] = value
|
||||
end
|
||||
}
|
||||
|
||||
|
|
|
@ -31,11 +31,11 @@ class TestFile < Test::Unit::TestCase
|
|||
super
|
||||
@file = Puppet::Type.type(:file)
|
||||
$method = @method_name
|
||||
begin
|
||||
initstorage
|
||||
rescue
|
||||
system("rm -rf %s" % Puppet[:statefile])
|
||||
end
|
||||
# begin
|
||||
# initstorage
|
||||
# rescue
|
||||
# system("rm -rf %s" % Puppet[:statefile])
|
||||
# end
|
||||
end
|
||||
|
||||
def teardown
|
||||
|
@ -1009,12 +1009,16 @@ class TestFile < Test::Unit::TestCase
|
|||
:ensure => "file",
|
||||
:mode => "0777"
|
||||
)
|
||||
assert_equal(0777, file.should(:mode),
|
||||
"Mode did not get set correctly")
|
||||
assert_apply(file)
|
||||
assert_equal(0777, File.stat(path).mode & 007777)
|
||||
assert_equal(0777, File.stat(path).mode & 007777,
|
||||
"file mode is incorrect")
|
||||
File.unlink(path)
|
||||
file[:ensure] = "directory"
|
||||
assert_apply(file)
|
||||
assert_equal(0777, File.stat(path).mode & 007777)
|
||||
assert_equal(0777, File.stat(path).mode & 007777,
|
||||
"directory mode is incorrect")
|
||||
end
|
||||
|
||||
def test_followlinks
|
||||
|
|
|
@ -981,22 +981,50 @@ inttest = 27
|
|||
# #489
|
||||
def test_modes
|
||||
Puppet[:name] = "puppet"
|
||||
file = tempfile
|
||||
config = tempfile()
|
||||
|
||||
check = Proc.new do |string, int|
|
||||
trans = @config.section_to_transportable(:puppet)
|
||||
ssldir = trans.find { |o| o.type == "file" }
|
||||
assert(ssldir, "could not find trans object")
|
||||
|
||||
if ssldir[:mode].is_a?(Fixnum)
|
||||
assert_equal(int, ssldir[:mode], "mode not set correctly")
|
||||
else
|
||||
assert_equal(string, ssldir[:mode], "mode not set correctly")
|
||||
end
|
||||
|
||||
obj = nil
|
||||
assert_nothing_raised { obj = ssldir.to_type }
|
||||
|
||||
assert(obj, "did not create object")
|
||||
assert_equal(int, obj.should(:mode),
|
||||
"did not pass mode correctly to file")
|
||||
|
||||
obj.class.clear
|
||||
end
|
||||
|
||||
file = tempfile
|
||||
@config.setdefaults(:puppet, :mode => ["644", "yay"])
|
||||
@config.setdefaults(:puppet, :ssldir => ["/some/file", "yay"])
|
||||
@config.setdefaults(:puppet, :ssldir => {
|
||||
:mode => 0644,
|
||||
:desc => "yay",
|
||||
:default => "/some/file"})
|
||||
|
||||
# Convert it first using the number
|
||||
check.call("644", 0644)
|
||||
|
||||
File.open(config, "w") { |f| f.puts "[puppet]
|
||||
mode = 755
|
||||
mode = 750
|
||||
ssldir = #{file}
|
||||
"}
|
||||
|
||||
@config.parse(config)
|
||||
|
||||
trans = @config.section_to_transportable(:puppet)
|
||||
ssldir = trans.find { |o| o.type == "file" and o.name == file }
|
||||
assert(ssldir, "could not find trans object")
|
||||
assert_equal("750", @config[:mode],
|
||||
"Did not parse mode correctly")
|
||||
|
||||
assert_equal("755", ssldir[:mode], "mode got munged in parsing")
|
||||
check.call("750", 0750)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче