Вот пример моего кода:
Код: Выделить всё
let mut stack = [0u8; 1024 * 1024];
let flags = CloneFlags::empty()
.union(CloneFlags::CLONE_NEWUSER)
.union(CloneFlags::CLONE_NEWNET)
.union(CloneFlags::CLONE_NEWPID)
.union(CloneFlags::CLONE_NEWNS);
let pid = unsafe {
nix::sched::clone(
Box::new(|| match run_container(cxt.clone(), container.clone()) {
Ok(()) => 0,
Err(e) => {
tracing::error!("Failed to run container: {e}");
-1
}
}),
&mut stack,
flags,
// The SIGCHLD signal is required for wait/waitpid;
// otherwise, ECHILD will be reported.
Some(libc::SIGCHLD),
)?
};
...
fn run_container(cxt: cfg::Context, container: Container) -> ChariotResult {
tracing::debug!("Run sandbox in as .", container.name, getpid(), getuid());
...
}
Код: Выделить всё
...
2024-10-15T14:55:47.267206Z DEBUG chariot::cmd::runc: Run sandbox in as .
...
Подробнее здесь: https://stackoverflow.com/questions/790 ... ne-newuser