4

std::os::unix::fs

 2 years ago
source link: https://doc.rust-lang.org/stable/std/os/unix/fs/fn.chroot.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

Function std::os::unix::fs::chroot1.56.0[−][src]

pub fn chroot<P: AsRef<Path>>(dir: P) -> Result<()>
This is supported on Unix only.

Change the root directory of the current process to the specified path.

This typically requires privileges, such as root or a specific capability.

This does not change the current working directory; you should call std::env::set_current_dir afterwards.

Examples

use std::os::unix::fs;

fn main() -> std::io::Result<()> {
    fs::chroot("/sandbox")?;
    std::env::set_current_dir("/")?;
    // continue working in sandbox
    Ok(())
}
Run

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK