c-scape 0.22.3

A libc bottom-half implementation in Rust
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use libc::{c_int, uid_t};

#[no_mangle]
unsafe extern "C" fn getuid() -> uid_t {
    libc!(libc::getuid());
    rustix::process::getuid().as_raw()
}

#[no_mangle]
unsafe extern "C" fn setuid(uid: uid_t) -> c_int {
    libc!(libc::setuid(uid));

    // rustix has a `set_thread_uid` function, but it just wraps the Linux
    // syscall which sets a per-thread UID rather than the whole process UID.
    // Linux expects libc's to have logic to set the UID for all the threads.
    todo!("setuid")
}