diff options
author | Luke Kanies <luke@madstop.com> | 2008-10-01 00:07:24 -0500 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2008-10-02 07:32:03 +1000 |
commit | 862077513570c996e9124743369c9af92485151f (patch) | |
tree | 055d2e11ab95d2c9a6f85c31e046382f41126c99 /lib | |
parent | 63ad84587892e9cab851cf516f7a381c5ea51f90 (diff) | |
download | puppet-862077513570c996e9124743369c9af92485151f.tar.gz puppet-862077513570c996e9124743369c9af92485151f.tar.xz puppet-862077513570c996e9124743369c9af92485151f.zip |
Fixed #791 - You should now be able to create and find a user/group in one transaction.
The real problem was that the 'gid' and 'uid' methods didn't handle
the case where 'get_posix_field' didn't return a value, and
the subsequent 'get_posix_field' calls couldn't handle that.
This commit moves the tests for Posix to spec, and fixes the
specific bug.
Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib')
-rwxr-xr-x | lib/puppet/util/posix.rb | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/lib/puppet/util/posix.rb b/lib/puppet/util/posix.rb index 9281169ea..b969a041c 100755 --- a/lib/puppet/util/posix.rb +++ b/lib/puppet/util/posix.rb @@ -7,10 +7,8 @@ module Puppet::Util::POSIX # method search_posix_field in the gid and uid methods if a sanity check # fails def get_posix_field(space, field, id) - unless id - raise ArgumentError, "Did not get id" - end - prefix = "get" + space.to_s + raise Puppet::DevError, "Did not get id from caller" unless id + if id.is_a?(Integer) if id > Puppet[:maximum_uid].to_i Puppet.err "Tried to get %s field for silly id %s" % [field, id] @@ -132,16 +130,16 @@ module Puppet::Util::POSIX # Get the GID of a given group, provided either a GID or a name def gid(group) begin - group = Integer(group) + group = Integer(group) rescue ArgumentError - # pass + # pass end if group.is_a?(Integer) - name = get_posix_field(:group, :name, group) + return nil unless name = get_posix_field(:group, :name, group) gid = get_posix_field(:group, :gid, name) check_value = gid else - gid = get_posix_field(:group, :gid, group) + return nil unless gid = get_posix_field(:group, :gid, group) name = get_posix_field(:group, :name, gid) check_value = name end @@ -155,16 +153,16 @@ module Puppet::Util::POSIX # Get the UID of a given user, whether a UID or name is provided def uid(user) begin - user = Integer(user) + user = Integer(user) rescue ArgumentError - # pass + # pass end if user.is_a?(Integer) - name = get_posix_field(:passwd, :name, user) + return nil unless name = get_posix_field(:passwd, :name, user) uid = get_posix_field(:passwd, :uid, name) check_value = uid else - uid = get_posix_field(:passwd, :uid, user) + return nil unless uid = get_posix_field(:passwd, :uid, user) name = get_posix_field(:passwd, :name, uid) check_value = name end |