Class: DarwinUser

Inherits:
UnixUser show all
Defined in:
lib/resources/user.rb

Overview

we do not use ‘finger’ for MacOS, because it is harder to parse data with it instead we use ‘dscl’ to request user data

Instance Attribute Summary

Attributes inherited from UserInfo

#inspec

Instance Method Summary collapse

Methods inherited from UnixUser

#identity, #parse_id_entries, #parse_value

Methods inherited from UserInfo

#credentials, #initialize

Methods included from Converter

#convert_to_i

Constructor Details

This class inherits a constructor from UserInfo

Instance Method Details

#meta_info(username) ⇒ Object



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
# File 'lib/resources/user.rb', line 272

def meta_info(username)
  cmd = inspec.command("dscl -q . -read /Users/#{username} NFSHomeDirectory PrimaryGroupID RecordName UniqueID UserShell")
  return nil if cmd.exit_status != 0

  params = SimpleConfig.new(
    cmd.stdout.chomp,
    assignment_re: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
    group_re: nil,
    multiple_values: false,
  ).params

  {
    home: params['NFSHomeDirectory'],
    shell: params['UserShell'],
  }
end