summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-09-30 17:49:18 -0500
committerLuke Kanies <luke@madstop.com>2008-09-30 17:49:18 -0500
commit4c998fe67d7e82c91d5fefd3c0239cb132e9a16d (patch)
treee090b61bd6513597d1e1a33cbfe9113a3620669f /lib/puppet
parent6bc56aecdb08b894961563035551480a01e93d53 (diff)
downloadpuppet-4c998fe67d7e82c91d5fefd3c0239cb132e9a16d.tar.gz
puppet-4c998fe67d7e82c91d5fefd3c0239cb132e9a16d.tar.xz
puppet-4c998fe67d7e82c91d5fefd3c0239cb132e9a16d.zip
Fixing #1622 - The user type only looks up groups when necessary.
Also added a bunch of tests to the user type, and refactored as necessary for this to work. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib/puppet')
-rwxr-xr-xlib/puppet/type/user.rb71
1 files changed, 14 insertions, 57 deletions
diff --git a/lib/puppet/type/user.rb b/lib/puppet/type/user.rb
index 039bcb7cb..79cd5ff26 100755
--- a/lib/puppet/type/user.rb
+++ b/lib/puppet/type/user.rb
@@ -49,25 +49,6 @@ module Puppet
return :absent
end
end
-
- # The default 'sync' method only selects among a list of registered
- # values.
- def sync
-# if self.insync?
-# self.info "already in sync"
-# return nil
- #else
- #self.info "%s vs %s" % [self.is.inspect, self.should.inspect]
-# end
- unless self.class.values
- self.devfail "No values defined for %s" %
- self.class.name
- end
-
- # Set ourselves to whatever our should value is.
- self.set(self.should)
- end
-
end
newproperty(:uid) do
@@ -95,50 +76,26 @@ module Puppet
newproperty(:gid) do
desc "The user's primary group. Can be specified numerically or
by name."
-
- def found?
- defined? @found and @found
- end
-
- munge do |gid|
- method = :getgrgid
- case gid
- when String
- if gid =~ /^[-0-9]+$/
- gid = Integer(gid)
- else
- method = :getgrnam
- end
- when Symbol
- unless gid == :auto or gid == :absent
- self.devfail "Invalid GID %s" % gid
- end
- # these are treated specially by sync()
- return gid
- end
- if group = Puppet::Util.gid(gid)
- @found = true
- return group
+ munge do |value|
+ if value.is_a?(String) and value =~ /^[-0-9]+$/
+ Integer(value)
else
- @found = false
- return gid
+ value
end
end
- # *shudder* Make sure that we've looked up the group and gotten
- # an ID for it. Yuck-o.
- def should
- unless defined? @should
- return super
- end
- unless found?
- @should = @should.each { |val|
- next unless val
- Puppet::Util.gid(val)
- }
+ def sync
+ found = false
+ @should.each do |value|
+ if number = Puppet::Util.gid(value)
+ provider.gid = number
+ found = true
+ break
+ end
end
- super
+
+ fail "Could not find group(s) %s" % @should.join(",") unless found
end
end