Method: Puppet::Util::POSIX#get_posix_field
- Defined in:
- lib/vendor/puppet/util/posix.rb
#get_posix_field(space, field, id) ⇒ Object
Retrieve a field from a POSIX Etc object. The id can be either an integer or a name. This only works for users and groups. It’s also broken on some platforms, unfortunately, which is why we fall back to the other method search_posix_field in the gid and uid methods if a sanity check fails
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/vendor/puppet/util/posix.rb', line 9 def get_posix_field(space, field, id) 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 #{field} field for silly id #{id}" return nil end method = methodbyid(space) else method = methodbyname(space) end begin return Etc.send(method, id).send(field) rescue ArgumentError => detail # ignore it; we couldn't find the object return nil end end |