Class: Inspec::Resources::DarwinUser
- Defined in:
- lib/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.
500 501 502 503 |
# File 'lib/resources/users.rb', line 500 def initialize(inspec) @list_users_cmd ||= 'dscl . list /Users' super end |
Instance Method Details
#meta_info(username) ⇒ Object
505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 |
# File 'lib/resources/users.rb', line 505 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 |