Class: Inspec::Resources::AixUser

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

Instance Attribute Summary

Attributes inherited from UnixUser

#id_cmd, #inspec, #list_users_cmd

Attributes inherited from UserInfo

#inspec

Instance Method Summary collapse

Methods inherited from UnixUser

#initialize, #list_users, #parse_id_entries, #parse_value

Methods inherited from UserInfo

#collect_user_details, #initialize, #list_users, #user_details

Methods included from Converter

#convert_to_i, to_boolean

Constructor Details

This class inherits a constructor from Inspec::Resources::UnixUser

Instance Method Details

#credentials(username) ⇒ Object



606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
# File 'lib/inspec/resources/users.rb', line 606

def credentials(username)
  cmd = inspec.command(
    "lssec -c -f /etc/security/user -s #{username} -a minage -a maxage -a pwdwarntime"
  )
  return nil if cmd.exit_status != 0

  user_sec = cmd.stdout.chomp.split("\n").last.split(":")

  {
    mindays: user_sec[1].to_i * 7,
    maxdays: user_sec[2].to_i * 7,
    warndays: user_sec[3].to_i,
    passwordage: nil,
    badpasswordattempts: nil,
  }
end

#identity(username) ⇒ Object



579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
# File 'lib/inspec/resources/users.rb', line 579

def identity(username)
  id = super(username)
  return nil if id.nil?

  # AIX 'id' command doesn't include the primary group in the supplementary
  # yet it can be somewhere in the supplementary list if someone added root
  # to a groups list in /etc/group
  # we rearrange to expected list if that is the case
  if id[:groups].first != id[:group]
    id[:groups].reject! { |i| i == id[:group] } if id[:groups].include?(id[:group])
    id[:groups].unshift(id[:group])
  end

  id
end

#meta_info(username) ⇒ Object



595
596
597
598
599
600
601
602
603
604
# File 'lib/inspec/resources/users.rb', line 595

def meta_info(username)
  lsuser = inspec.command("lsuser -C -a home shell #{username}")
  return nil if lsuser.exit_status != 0

  user = lsuser.stdout.chomp.split("\n").last.split(":")
  {
    home: user[1],
    shell: user[2],
  }
end