How can I use the function `std::os::unix::fs::chroot` if I'm not a root user?

I'm trying to build a program in my Linux, the following is the content of

fn main() {
    println!("Hello, world!");

But I'm not the root user, so I got the error:

called `Result::unwrap()` on an `Err` value: Os { code: 1, kind: PermissionDenied, message: "Operation not permitted" }

How can Imake the user inside which I'm running the program has the permission to use the chroot function? Is there a way I can do something like this (assumming the username is brian): sudo brian capacity --add-CAP_SYS_CHROOT?

No, not really. See eg. this answer for the rationale.


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.