diff options
-rw-r--r-- | lib/puppet/config.rb | 3 | ||||
-rwxr-xr-x | test/other/config.rb | 42 |
2 files changed, 45 insertions, 0 deletions
diff --git a/lib/puppet/config.rb b/lib/puppet/config.rb index 5725bcd93..9a381585a 100644 --- a/lib/puppet/config.rb +++ b/lib/puppet/config.rb @@ -411,6 +411,9 @@ class Config # If a user and/or group is set, then make sure we're # managing that object if obj.respond_to? attr and name = obj.send(attr) + # Skip root or wheel + next if %w{root wheel}.include?(name.to_s) + # Skip owners and groups we've already done, but tag # them with our section if necessary if done[type].include?(name) diff --git a/test/other/config.rb b/test/other/config.rb index 3b8c08ff8..1ce82c19d 100755 --- a/test/other/config.rb +++ b/test/other/config.rb @@ -853,6 +853,48 @@ inttest = 27 assert_equal("footest", config[:blocktest2]) assert_equal("footest", testing) end + + def test_no_modify_root + config = mkconfig + config.setdefaults(:yay, + :mydir => {:default => tempfile(), + :mode => 0644, + :owner => "root", + :group => "root", + :desc => "yay" + }, + :mkusers => [false, "yay"] + ) + + assert_nothing_raised do + config.use(:yay) + end + + # Now enable it so they'll be added + config[:mkusers] = true + + comp = config.to_component + comp.each do |c| + puts c.ref + end + + Puppet::Type.type(:user).each do |u| + assert(u.name != "root", "Tried to manage root user") + end + Puppet::Type.type(:group).each do |u| + assert(u.name != "root", "Tried to manage root group") + assert(u.name != "wheel", "Tried to manage wheel group") + end + +# assert(yay, "Did not find yay component") +# yay.each do |c| +# puts c.ref +# end +# assert(! yay.find { |o| o.class.name == :user and o.name == "root" }, +# "Found root user") +# assert(! yay.find { |o| o.class.name == :group and o.name == "root" }, +# "Found root group") + end end # $Id$ |