12 releases

0.1.0 Jun 6, 2019
0.0.6 Dec 25, 2018
0.0.5 Jul 4, 2018
0.0.4 Jun 21, 2018
0.0.1 May 28, 2018

#32 in Unix APIs

Download history 3/week @ 2019-02-22 23/week @ 2019-03-01 3/week @ 2019-03-08 12/week @ 2019-03-15 41/week @ 2019-03-22 9/week @ 2019-03-29 16/week @ 2019-04-05 8/week @ 2019-04-12 2/week @ 2019-04-19 13/week @ 2019-04-26 15/week @ 2019-05-03 34/week @ 2019-05-10 26/week @ 2019-05-17 29/week @ 2019-05-24 17/week @ 2019-05-31

75 downloads per month
Used in 2 crates

BSD-3-Clause

83KB
1.5K SLoC

libjail-rs

Crates.io GitHub last commit Gitter Libraries.io for releases Crates.io Crates.io BuildBot Travis Docs: x86_64-unknown-freebsd Docs: i686-unknown-freebsd FOSSA Status

libjail-rs aims to be a rust implementation of the FreeBSD jail(3) library. While feature parity is a goal, a one-to-one implementation of all functions in jail(3) is not.

Is it any good?

Yes.

Can I use it?

This library is still under heavy development, but seems to work so far. No stability guarantees are made.

How do I use it?

jail = "*"

Execute a command in a jail:

use jail::process::Jailed;
use jail::StoppedJail;
use std::process::Command;

fn main() {
    let stopped = StoppedJail::new("/path/to/root")
        .name("alcatraz")
        .ip("127.0.1.2".parse().unwrap())
        .ip("fe80::2".parse().unwrap * ())
        .param("allow.raw_sockets", param::Value::Int(1));

    let running = stopped.start().expect("Couldn't start Jail");

    let output = Command::new("hostname")
        .jail(&running)
        .output()
        .expect("Failed to execute command");

    println!("output: {:?}", output.stdout);

    running.kill();
}

Is it fast?

There are a few benchmarks included. Run them with sudo cargo bench (yes, starting a jail requires being root).

These are some results on my laptop, on slow, spinning disks:

test echo_helloworld_free       ... bench:     271,418 ns/iter (+/- 17,522)
test echo_helloworld_jailed     ... bench:     461,749 ns/iter (+/- 26,267)
test get_ips                    ... bench:      29,591 ns/iter (+/- 3,315)
test start_echo_helloworld_stop ... bench:     504,978 ns/iter (+/- 23,717)
test start_stop_ipjail          ... bench:      27,220 ns/iter (+/- 2,141)
test start_stop_ipv4jail        ... bench:      26,307 ns/iter (+/- 2,159)
test start_stop_ipv6jail        ... bench:      26,988 ns/iter (+/- 2,486)
test start_stop_jail            ... bench:      25,760 ns/iter (+/- 2,244)

License

FOSSA Status

Dependencies

~4MB
~56K SLoC