Setting capabilities + building rust examples?

Hello, I’m developing an application which uses libpcap through the Rust pcap crate, as a result the binaries that use it need cap_net_raw,cap_net_admin=eip capabilities (usually set with sudo setcap cap_net_raw,cap_net_admin=eip path/to/bin).

I’m still getting used to using nix for building my project, is there a way I can build and run a specific example binary that one of the crates in my workspace has with these capabilities set?

For reference, I’m using naersk.buildPackage to build my program and the oxalica rust-overlay for pinning a specific Rust version.

If there isn’t a way to do this, no worries, just curious :slight_smile:

No way to do it in builds. On NixOS, you can use security.wrappers.

3 Likes