2
Puppet.type(:file).newstate(:owner) do
4
desc "To whom the file should belong. Argument can be user name or
13
user = Etc.getpwuid(id)
27
if value.is_a?(Symbol)
31
user = Etc.getpwnam(value)
36
rescue ArgumentError => detail
41
# Determine if the user is valid, and if so, return the UID
47
if value.is_a?(Integer)
48
# verify the user is a valid user
49
if tmp = id2name(value)
55
if tmp = name2id(value)
63
# We want to print names, not numbers
73
id2name(self.should) || self.should
77
raise Puppet::DevError, "Invalid uid type %s(%s)" %
78
[self.should.class, self.should]
83
unless stat = @parent.stat(false)
88
# Set our method appropriately, depending on links.
89
if stat.ftype == "link" and @parent[:links] != :follow
97
# On OS X, files that are owned by -2 get returned as really
98
# large UIDs instead of negative ones. This isn't a Ruby bug,
99
# it's an OS X bug, since it shows up in perl, too.
101
self.warning "current state is silly: %s" % @is
106
# If we're not root, we can check the values but we cannot change
107
# them. We can't really do any processing here, because users
108
# might not exist yet. FIXME There's still a bit of a problem here
109
# if the user's UID changes at run time, but we're just going to
110
# have to be okay with that for now, unfortunately.
112
if tmp = self.validuser?(value)
120
unless Puppet::SUIDManager.uid == 0
121
unless defined? @@notifieduid
122
self.notice "Cannot manage ownership unless running as root"
123
#@parent.delete(self.name)
130
unless user = self.validuser?(self.should)
132
unless defined? @@usermissing
136
if @@usermissing.include?(tmp)
137
@@usermissing[tmp] += 1
139
self.notice "user %s does not exist" % tmp
140
@@usermissing[tmp] = 1
149
self.debug "File does not exist; cannot set owner"
155
#self.debug "%s: after refresh, is '%s'" % [self.class.name,@is]
159
File.send(@method, user, nil, @parent[:path])
161
raise Puppet::Error, "Failed to set owner to '%s': %s" %
170
# $Id: uid.rb 1666 2006-09-22 17:19:02Z erikh $