23 releases

0.7.0 May 4, 2021
0.6.0 Nov 24, 2020
0.5.1 Oct 11, 2018
0.4.0 Jul 23, 2018
0.1.4 Nov 12, 2015

#372 in Unix APIs

Download history 258/week @ 2023-10-22 257/week @ 2023-10-29 244/week @ 2023-11-05 210/week @ 2023-11-12 234/week @ 2023-11-19 260/week @ 2023-11-26 283/week @ 2023-12-03 270/week @ 2023-12-10 251/week @ 2023-12-17 266/week @ 2023-12-24 230/week @ 2023-12-31 334/week @ 2024-01-07 252/week @ 2024-01-14 225/week @ 2024-01-21 191/week @ 2024-01-28 150/week @ 2024-02-04

852 downloads per month
Used in 5 crates

MIT/Apache

96KB
2K SLoC

Rust Unshare

Status: 90% feature-complete, works in production in lithos and powers vagga

Github | Documentaion | Crate

Unshare is a low-level library to create linux containers.

It contains the following:

  • Process creation interface similar to std::process::Command
  • Unsharing arbitrary linux namespaces
  • Ability to change root (chroot/pivot_root), uid, gid, gid_map
  • Some signal mask handling (especially for new processes)
  • Forwarding file descriptors and other unixy stuff (sessions, terminals)
  • Setting few important prctl flags (PR_SET_PDEATHSIG)
  • Runs both as root user and as unprivileged user

Not implemeneted yet:

  • Fine grained capabilities control (currently you may change user or use user namespaces)

The following is considered:

  • Capture input (should be, because part of std::process interface)
  • Pseudo tty creation for child
  • The unshare and setns

The following is out of scope:

  • mounting file systems
  • setting up network
  • in-container and out of container supervision
  • handing child signals

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~1.5MB
~36K SLoC