mirror of
https://github.com/inspec/inspec
synced 2025-02-16 22:18:38 +00:00
CFINSPEC-94: encrypted_password works with getent utility on BSD/Solaris
Signed-off-by: Sonu Saha <sonu.saha@progress.com>
This commit is contained in:
parent
96103a8785
commit
6dfa1e23db
1 changed files with 11 additions and 3 deletions
|
@ -374,10 +374,10 @@ module Inspec::Resources
|
|||
# Helper method for encrypted_password property
|
||||
def encrypted_password_info
|
||||
# Todo:
|
||||
# [-] Linux
|
||||
# [-] BSD
|
||||
# [+] Linux
|
||||
# [+] BSD: works same as linux; using getent
|
||||
# [-] Check if feasible on: Darwin, hpux, and aix
|
||||
bin = 'getent'
|
||||
bin = find_getent_or_equiv_utility
|
||||
cmd = inspec.command("#{bin} passwd #{@username}")
|
||||
|
||||
raise Inspec::Exceptions::ResourceSkipped, "Cannot view encrypted_password information" if cmd.exit_status != 0
|
||||
|
@ -385,6 +385,14 @@ module Inspec::Resources
|
|||
shadow_info = cmd.stdout.split(":").map(&:strip)
|
||||
shadow_info[1]
|
||||
end
|
||||
|
||||
def find_getent_or_equiv_utility
|
||||
%w{/usr/bin/getent /bin/getent getent}.each do |cmd|
|
||||
return cmd if inspec.command(cmd).exist?
|
||||
end
|
||||
|
||||
raise Inspec::Exceptions::ResourceFailed, "Could not find `getent`"
|
||||
end
|
||||
end
|
||||
|
||||
# Class defined to compare for groups without case-sensitivity
|
||||
|
|
Loading…
Add table
Reference in a new issue