Method: Inspec::Resources::LinuxUser#credentials

Defined in:
lib/resources/users.rb

#credentials(username) ⇒ Object



415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
# File 'lib/resources/users.rb', line 415

def credentials(username)
  cmd = inspec.command("chage -l #{username}")
  return nil if cmd.exit_status != 0

  params = SimpleConfig.new(
    cmd.stdout.chomp,
    assignment_re: /^\s*([^:]*?)\s*:\s*(.*?)\s*$/,
    group_re: nil,
    multiple_values: false,
  ).params

  {
    mindays: convert_to_i(params['Minimum number of days between password change']),
    maxdays: convert_to_i(params['Maximum number of days between password change']),
    warndays: convert_to_i(params['Number of days of warning before password expires']),
  }
end