Initially published: 2021-11-19 - Last Modified: 2021-11-19

caps-rs: Rust-native Linux capabilities

caps is a Rust-native library for working with Linux capabilities. It is particularly suited for projects that want to avoid additional dependencies on system libraries just for inspecting and manipulating their runtime capabilities on Linux.

Linux capabilities are units of privileges originally pertaining to root and superusers. Starting with kernel 2.2, they can now be individually handled and inspected/manipulated at runtime.
This is usually done via C libraries such as libcap or libcap-ng, which can used in Rust through Foreign Fuction Interfaces (FFI). However, that means losing most guarantees on memory safety and requiring additional linkage too.

In order to fill a gap and enable directly handling capabilities from Rust, in February 2017 I started writing a library for that. This project lives at https://github.com/lucab/caps-rs.