cli: fix genpolicy crash on Darwin #2133
Open
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.
/dev/stdin is passed to genpolicy when called from contrast cli as a way to both a) silence genpolicy from outputting to stdout and b) retrieve genpolicy's output back through stdin. This causes a crash on Darwin like so:
time=2026-01-21T11:56:10.495+02:00 level=DEBUG msg="called
Result::unwrap()on anErrvalue: Os { code: 13, kind: PermissionDenied, message: "Permission denied" }"This is due to architectural differences between Linux and Darwin when attempting to write to /dev/stdin when passed via a pipe. Minimal reproducer to run on Darwin and Linux:
echo "test" | python3 -c 'open("/dev/stdin", "w")'