Skip to content

Commit

Permalink
Organize set*id functions into their own todo module. (sunfishcode#117
Browse files Browse the repository at this point in the history
)

* Organize `set*id` functions into their own todo module.

* Leave `setuid` and `setgid` outside of the todo module.

They're depended on by libstd.
  • Loading branch information
sunfishcode authored Jan 11, 2024
1 parent 69c38ed commit 0569f8a
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 30 deletions.
8 changes: 1 addition & 7 deletions c-scape/src/process/egid.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
use libc::{c_int, gid_t};
use libc::gid_t;

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

#[no_mangle]
unsafe extern "C" fn setegid(_gid: gid_t) -> c_int {
libc!(libc::setegid(_gid));
todo!("setegid")
}
8 changes: 1 addition & 7 deletions c-scape/src/process/euid.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
use libc::{c_int, uid_t};
use libc::uid_t;

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

#[no_mangle]
unsafe extern "C" fn seteuid(_uid: uid_t) -> c_int {
libc!(libc::seteuid(_uid));
todo!("seteuid")
}
17 changes: 1 addition & 16 deletions c-scape/src/todo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ mod long_double;
mod long_double_complex;
mod pthread_cancel;
mod pthread_spin;
mod set_id;
mod sysv;
mod wchar;

Expand Down Expand Up @@ -838,14 +839,6 @@ unsafe extern "C" fn __isoc99_vsscanf() {
todo!("__isoc99_vsscanf")
}
#[no_mangle]
unsafe extern "C" fn setregid() {
todo!("setregid")
}
#[no_mangle]
unsafe extern "C" fn setreuid() {
todo!("setreuid")
}
#[no_mangle]
unsafe extern "C" fn times() {
todo!("times")
}
Expand Down Expand Up @@ -926,14 +919,6 @@ unsafe extern "C" fn setns() {
todo!("setns")
}
#[no_mangle]
unsafe extern "C" fn setresgid() {
todo!("setresgid")
}
#[no_mangle]
unsafe extern "C" fn setresuid() {
todo!("setresuid")
}
#[no_mangle]
unsafe extern "C" fn mq_close() {
todo!("mq_close")
}
Expand Down
32 changes: 32 additions & 0 deletions c-scape/src/todo/set_id.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
//! Linux's system calls for these functions only set the IDs for one thread,
//! and we need to set the IDs for all threads in a process.
//!
//! This would typically entail taking a lock that prevents thread creation,
//! setting the IDs for each thread manually by sending signals to them and
//! having signal handlers that perform the set operation, waitinig for all
//! the handlers to run, and then releasing the lock.
#[no_mangle]
unsafe extern "C" fn seteuid() {
todo!("seteuid")
}
#[no_mangle]
unsafe extern "C" fn setegid() {
todo!("setegid")
}
#[no_mangle]
unsafe extern "C" fn setreuid() {
todo!("setreuid")
}
#[no_mangle]
unsafe extern "C" fn setregid() {
todo!("setregid")
}
#[no_mangle]
unsafe extern "C" fn setresuid() {
todo!("setresuid")
}
#[no_mangle]
unsafe extern "C" fn setresgid() {
todo!("setresgid")
}

0 comments on commit 0569f8a

Please sign in to comment.