Method: LinuxStat::User.home_by_gid
- Defined in:
- lib/linux_stat/user.rb
.home_by_gid(id = get_gid) ⇒ Object
home_by_gid(id = get_uid)
Gets the home of the user corresponding to the GID.
It returns a String in this format:
Assuming both the users share same UID.
If the info isn’t available, it will return an empty frozen String.
317 318 319 320 321 322 323 324 325 326 327 328 329 330 |
# File 'lib/linux_stat/user.rb', line 317 def home_by_gid(id = get_gid) return ''.freeze unless passwd_readable? home = ''.freeze passwd.each do |x| splitted = x.split(?:.freeze) if splitted[3].to_i == id home = splitted[5] break end end home end |