port: Correctly detect FreeBSD (#3579)

* Fixing #3563; freebsd is not a substring of 'bsd'
* Actually, this is better.
* Change coditional for FreeBSD from a string match to a call to os.bsd?

Signed-off-by: Clinton Wolfe <clintoncwolfe@gmail.com>
This commit is contained in:
Clinton Wolfe 2018-11-08 13:51:45 -05:00 committed by Jared Quick
parent 9d4510451e
commit b12aa82361

View file

@ -63,10 +63,12 @@ module Inspec::Resources
AixPorts.new(inspec) AixPorts.new(inspec)
elsif os.darwin? elsif os.darwin?
# Darwin: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man8/lsof.8.html # Darwin: https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man8/lsof.8.html
# Careful: make sure darwin comes before BSD, below
LsofPorts.new(inspec) LsofPorts.new(inspec)
elsif os.windows? elsif os.windows?
WindowsPorts.new(inspec) WindowsPorts.new(inspec)
elsif ['freebsd'].include?(os[:family]) elsif os.bsd?
# Relies on sockstat, usually present on FreeBSD and NetBSD (but not MacOS X)
FreeBsdPorts.new(inspec) FreeBsdPorts.new(inspec)
elsif os.solaris? elsif os.solaris?
SolarisPorts.new(inspec) SolarisPorts.new(inspec)