Uses netstat to detect open ports on AIX #2210
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Related to Issue #1936 - The
lsof
command is only provided in the AIX expansion pack so not all systems may have it installed. However netstat is available, but in true AIX fashion the command line arguments and output is not consistent with the Linux flavor ofnetstat
.This PR creates a dedicated
AixPorts
implementation that defers to using netstat as the default port scanner for AIX and falls back tolsof
if necessary. The implementation of this differs from theLinuxPorts
netstat parser because:Disclaimer: I am by no means an AIX expert. I pieced this solution together based on this blog post. I am completely open to changing any of this to make it better. All feedback welcome.
I created some mocked unit tests for aix and the port resource. I have also tested this by using
bin/inspec exec
with aport
control pointing to a real AIX 7.1 server. Let me know if there is additional tests that need to be written to cover these changes.