mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-24 18:03:25 +00:00
22 lines
490 B
Rust
22 lines
490 B
Rust
// SPDX-License-Identifier: MPL-2.0
|
|
|
|
use super::SyscallReturn;
|
|
use crate::{prelude::*, process::Uid};
|
|
|
|
pub fn sys_setfsuid(uid: i32, ctx: &Context) -> Result<SyscallReturn> {
|
|
debug!("uid = {}", uid);
|
|
|
|
let fsuid = if uid < 0 {
|
|
None
|
|
} else {
|
|
Some(Uid::new(uid as u32))
|
|
};
|
|
|
|
let old_fsuid = {
|
|
let credentials = ctx.posix_thread.credentials_mut();
|
|
credentials.set_fsuid(fsuid)?
|
|
};
|
|
|
|
Ok(SyscallReturn::Return(old_fsuid.as_u32() as _))
|
|
}
|