class Inspec::Resources::DarwinUser

we do not use 'finger' for MacOS, because it is harder to parse data with it @see developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man8/fingerd.8.html instead we use 'dscl' to request user data @see developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/dscl.1.html @see superuser.com/questions/592921/mac-osx-users-vs-dscl-command-to-list-user

Public Class Methods

new(inspec) click to toggle source
Calls superclass method Inspec::Resources::UnixUser::new
# File lib/inspec/resources/users.rb, line 560
def initialize(inspec)
  @list_users_cmd ||= "dscl . list /Users"
  super
end

Public Instance Methods

meta_info(username) click to toggle source
# File lib/inspec/resources/users.rb, line 565
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_regex: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
    group_re: nil,
    multiple_values: false
  ).params

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