summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/puppet/type/pfile/uid.rb26
-rw-r--r--lib/puppet/type/state.rb25
2 files changed, 33 insertions, 18 deletions
diff --git a/lib/puppet/type/pfile/uid.rb b/lib/puppet/type/pfile/uid.rb
index ce91bdea6..8a2f7ec79 100755
--- a/lib/puppet/type/pfile/uid.rb
+++ b/lib/puppet/type/pfile/uid.rb
@@ -8,6 +8,9 @@ module Puppet
@event = :inode_changed
def id2name(id)
+ if id.is_a?(Symbol)
+ return id.to_s
+ end
begin
user = Etc.getpwuid(id)
rescue TypeError
@@ -23,6 +26,9 @@ module Puppet
end
def name2id(value)
+ if value.is_a?(Symbol)
+ return value.to_s
+ end
begin
user = Etc.getpwnam(value)
if user.uid == ""
@@ -63,6 +69,8 @@ module Puppet
def should_to_s
case self.should
+ when Symbol
+ self.should.to_s
when Integer
id2name(self.should) || self.should
when String
@@ -80,13 +88,21 @@ module Puppet
end
self.is = stat.uid
+
+ # On OS X, files that are owned by -2 get returned as really
+ # large UIDs instead of negative ones. This isn't a Ruby bug,
+ # it's an OS X bug, since it shows up in perl, too.
+ if @is > 120000
+ self.warning "current state is silly: %s" % @is
+ @is = :notfound
+ end
end
- # If we're not root, we can check the values but we cannot change them.
- # We can't really do any processing here, because users might
- # not exist yet. FIXME There's still a bit of a problem here if
- # the user's UID changes at run time, but we're just going to have
- # to be okay with that for now, unfortunately.
+ # If we're not root, we can check the values but we cannot change
+ # them. We can't really do any processing here, because users
+ # might not exist yet. FIXME There's still a bit of a problem here
+ # if the user's UID changes at run time, but we're just going to
+ # have to be okay with that for now, unfortunately.
def shouldprocess(value)
if tmp = self.validuser?(value)
return tmp
diff --git a/lib/puppet/type/state.rb b/lib/puppet/type/state.rb
index 05f127a9c..fdc54ffcc 100644
--- a/lib/puppet/type/state.rb
+++ b/lib/puppet/type/state.rb
@@ -143,22 +143,21 @@ class State < Puppet::Element
# How should a state change be printed as a string?
def change_to_s
begin
- if @is == :notfound
- return "defined '%s' as '%s'" %
- [self.name, self.should_to_s]
- elsif self.should == :notfound
- return "undefined %s from '%s'" %
- [self.name, self.is_to_s]
- else
- self.should_to_s
- return "%s changed '%s' to '%s'" %
- [self.name, self.is_to_s, self.should_to_s]
- end
+ if @is == :notfound
+ return "defined '%s' as '%s'" %
+ [self.name, self.should_to_s]
+ elsif self.should == :notfound
+ return "undefined %s from '%s'" %
+ [self.name, self.is_to_s]
+ else
+ return "%s changed '%s' to '%s'" %
+ [self.name, self.is_to_s, self.should_to_s]
+ end
rescue Puppet::Error, Puppet::DevError
raise
rescue => detail
- raise Puppet::DevError, "Could not convert change to string: %s" %
- change_to_s
+ raise Puppet::DevError, "Could not convert change %s to string: %s" %
+ [self.name, detail]
end
end