diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2005-11-22 05:33:42 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2005-11-22 05:33:42 +0000 |
commit | 58c0df175ca94cd8bed38cbb76659bfa57e56fe5 (patch) | |
tree | 75a4a2e6db5ecaa2a61b940a20972f353af75cee | |
parent | 42c077fe97c5fc8814cc74ad1dd4f71023e883ea (diff) | |
download | puppet-58c0df175ca94cd8bed38cbb76659bfa57e56fe5.tar.gz puppet-58c0df175ca94cd8bed38cbb76659bfa57e56fe5.tar.xz puppet-58c0df175ca94cd8bed38cbb76659bfa57e56fe5.zip |
fixing incredibly annoying bug where os x returns stupidly large uid when uid is below 0
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@749 980ebf18-57e1-0310-9a29-db15c13687c0
-rwxr-xr-x | lib/puppet/type/pfile/uid.rb | 26 | ||||
-rw-r--r-- | lib/puppet/type/state.rb | 25 | ||||
-rw-r--r-- | test/puppettest.rb | 4 |
3 files changed, 35 insertions, 20 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 diff --git a/test/puppettest.rb b/test/puppettest.rb index 0bd7d80c5..2d291a91d 100644 --- a/test/puppettest.rb +++ b/test/puppettest.rb @@ -182,7 +182,7 @@ module TestPuppet def nonrootuser Etc.passwd { |user| - if user.uid != Process.uid + if user.uid != Process.uid and user.uid > 0 return user end } @@ -190,7 +190,7 @@ module TestPuppet def nonrootgroup Etc.group { |group| - if group.gid != Process.gid + if group.gid != Process.gid and group.gid > 0 return group end } |