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.
| 507 508 509 510 | # File 'lib/inspec/resources/users.rb', line 507 def initialize(inspec) @list_users_cmd ||= "dscl . list /Users" super end | 
Instance Method Details
#meta_info(username) ⇒ Object
| 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 | # File 'lib/inspec/resources/users.rb', line 512 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 |