Restrict systems operations on OpenBSD
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Use pledge(2)[0] to limit jq(1) to reading files. It does not change files and only writes to standard output/error. It never deals with TTY, network, process management or other subsystems. This is to reduce jq's attack surface and potential damage. OpenBSD is carrying a local patch[1] in its official jq port/package since 2016. An improved version: - drop no longer needed "getpw" promise f1c4947 "Avoid getpwuid for static linking" removed getpwuid(3) usage - pledge before jq_init() to simplify the error path - use perror(3) to print errno(2) No behaviour change in tests or real world usage observed on OpenBSD/amd64 7.4. 0: https://man.openbsd.org/pledge.2 1: https://cvsweb.openbsd.org/cgi-bin/cvsweb/ports/textproc/jq/patches/patch-main_c
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Trailers
- 0: https://man.openbsd.org/pledge.2
- 1: https://cvsweb.openbsd.org/cgi-bin/cvsweb/ports/textproc/jq/patches/patch-main_c
Diff stats
1 file+7 added−0 removed
- other:+7 added−0 removed