Class: Inspec::Resources::DarwinUser
- Defined in:
- lib/inspec/resources/users.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 UnixUser
#id_cmd, #inspec, #list_users_cmd
Attributes inherited from UserInfo
Instance Method Summary collapse
-
#initialize(inspec) ⇒ DarwinUser
constructor
A new instance of DarwinUser.
- #meta_info(username) ⇒ Object
Methods inherited from UnixUser
#identity, #list_users, #parse_id_entries, #parse_value
Methods inherited from UserInfo
#collect_user_details, #credentials, #identity, #list_users, #user_details
Methods included from Converter
Constructor Details
#initialize(inspec) ⇒ DarwinUser
Returns a new instance of DarwinUser.
643 644 645 646 |
# File 'lib/inspec/resources/users.rb', line 643 def initialize(inspec) @list_users_cmd ||= "dscl . list /Users" super end |
Instance Method Details
#meta_info(username) ⇒ Object
648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 |
# File 'lib/inspec/resources/users.rb', line 648 def (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 |