Method: LinuxStat::User.home_by_username
- Defined in:
- lib/linux_stat/user.rb
.home_by_username(user = get_user) ⇒ Object
home_by_username(user = get_user)
Where user is the name of the user.
Returns the user’s home. By default it returns the home of the current user.
If the info isn’t available, it will return ENV.to_s.freeze
269 270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'lib/linux_stat/user.rb', line 269 def home_by_username(user = get_user) return ENV['HOME'].to_s.freeze unless passwd_readable? home = '' passwd.each { |x| splitted = x.split(?:) if splitted[0] == user home = splitted[5] break end } home end |