Skip to content

facts.server.Port: fix ss command for Alpine/BusyBox compatibility#1586

Open
wowi42 wants to merge 2 commits intopyinfra-dev:3.xfrom
KalvadTech:fix-port-fact-alpine
Open

facts.server.Port: fix ss command for Alpine/BusyBox compatibility#1586
wowi42 wants to merge 2 commits intopyinfra-dev:3.xfrom
KalvadTech:fix-port-fact-alpine

Conversation

@wowi42
Copy link
Contributor

@wowi42 wowi42 commented Mar 5, 2026

BusyBox ss (used sometimes on Alpine) does not support the -H flag or filter expressions like 'src :port'. Replace with pipe to grep which works on both iproute2 and BusyBox ss. Append || true so grep returning no matches does not cause a command failure.

On Alpine, netstat outputs program names like "sshd [listener" which contain spaces. The parser was taking the last whitespace-delimited field, missing the PID/program column. Now scans fields for the one containing "/" to reliably find the PID/program pair.

  • Pull request is based on the default branch (3.x at this time)
  • Pull request includes tests for any new/updated operations/facts
  • Pull request includes documentation for any new/updated operations/facts
  • Tests pass (see scripts/dev-test.sh)
  • Type checking & code style passes (see scripts/dev-lint.sh)

wowi42 added 2 commits March 5, 2026 14:47
BusyBox ss (used on Alpine) does not support the -H flag or filter
expressions like 'src :port'. Replace with pipe to grep which works
on both iproute2 and BusyBox ss. Append || true so grep returning
no matches does not cause a command failure.
On Alpine, netstat outputs program names like "sshd [listener" which
contain spaces. The parser was taking the last whitespace-delimited
field, missing the PID/program column. Now scans fields for the one
containing "/" to reliably find the PID/program pair.
@wowi42 wowi42 changed the title Fix port fact alpine facts.server.Port: fix ss command for Alpine/BusyBox compatibility Mar 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant