Sandboxed Rust development on OpenBSD (example)
Files
README.md

This is a simple example of how to sandbox Rust development on OpenBSD.

To build it, cc -o rbox rbox.c, then place ./rbox somewhere in your $PATH.

Running rbox DIR, where DIR is an existing Rust project (possibly just created via cargo new), will put you into a sandboxed directory for Rust development. All dependencies pulled in via Cargo (via cargo build and the like) will be built in a sandboxed manner, isolated from the rest of your system. The contents of the local $CARGO_HOME will be stored in DIR/.cargo, and the local $TMPDIR in DIR/target.

This is intended merely as an example of how to use pledge for sandboxing. In real-world development, you'd likely want to generalize this code to suit your needs (e.g., by unveiling additional directories, or by using your preferred $SHELL instead of /bin/sh). Isolation could also be further improved (e.g., by clearing environment variables).