mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-08 14:16:47 +00:00
* refactor(process):迁移geteuid系统调用 * refactor(process):迁移getegid系统调用 * refactor(process):迁移getgid系统调用 * refactor(process):迁移getpgid系统调用 * refactor(process):迁移getpid系统调用 * refactor(process):迁移getppid系统调用 * refactor(process):迁移getsid系统调用 * refactor(process):迁移gettid系统调用 * refactor(process):迁移getuid系统调用 * refactor(process):迁移set_tid_address系统调用 * refactor(process):迁移setfsgid系统调用 * refactor(process):迁移setfsuid系统调用 * refactor(process):迁移setgid系统调用 * refactor(process):迁移setpgid系统调用 * refactor(process):迁移setresgid系统调用 * refactor(process):迁移setresuid系统调用 * refactor(process):迁移setsid系统调用 * refactor(process):迁移setuid系统调用 * refactor(process):删除部分已迁移的syscall(id相关)的原有部分 * refactor(process):make fmt * refactor(process):迁移sys_get_rusage系统调用 * refactor(process):迁移exit exit_group 系统调用 * refactor(process):删除重构syscall下的mod中的全架构条件编译 * refactor(process):迁移sys_wait4系统调用 * refactor(process):迁移sys_getrlimit sys_prlimit64 系统调用 * make fmt * refactor(process):迁移sys_uname系统调用 * fix(ipc):修复rebase时的错误冲突 * refactor(process):修改已迁移的系统调用的handle参数from_user-->frame * refactor(process):迁移execve系统调用 * refactor(process):迁移clone系统调用 * refactor(process):迁移fork、vfork系统调用 * refactor(process):删除原有syscall文件,将迁移后的文件夹重命名为syscall * refactor(process):修复条件编译错误
51 lines
1.3 KiB
Rust
51 lines
1.3 KiB
Rust
use crate::arch::interrupt::TrapFrame;
|
|
use crate::arch::syscall::nr::SYS_SETGID;
|
|
use crate::process::ProcessManager;
|
|
use crate::syscall::table::FormattedSyscallParam;
|
|
use crate::syscall::table::Syscall;
|
|
use alloc::vec::Vec;
|
|
use system_error::SystemError;
|
|
|
|
pub struct SysSetGid;
|
|
|
|
impl SysSetGid {
|
|
fn gid(args: &[usize]) -> usize {
|
|
args[0]
|
|
}
|
|
}
|
|
|
|
impl Syscall for SysSetGid {
|
|
fn num_args(&self) -> usize {
|
|
1
|
|
}
|
|
|
|
fn handle(&self, args: &[usize], _frame: &mut TrapFrame) -> Result<usize, SystemError> {
|
|
let gid = Self::gid(args);
|
|
let pcb = ProcessManager::current_pcb();
|
|
let mut guard = pcb.cred.lock();
|
|
|
|
if guard.egid.data() == 0 {
|
|
guard.setgid(gid);
|
|
guard.setegid(gid);
|
|
guard.setsgid(gid);
|
|
guard.setfsgid(gid);
|
|
} else if guard.gid.data() == gid || guard.sgid.data() == gid {
|
|
guard.setegid(gid);
|
|
guard.setfsgid(gid);
|
|
} else {
|
|
return Err(SystemError::EPERM);
|
|
}
|
|
|
|
return Ok(0);
|
|
}
|
|
|
|
fn entry_format(&self, args: &[usize]) -> Vec<FormattedSyscallParam> {
|
|
vec![FormattedSyscallParam::new(
|
|
"gid",
|
|
format!("{:#x}", Self::gid(args)),
|
|
)]
|
|
}
|
|
}
|
|
|
|
syscall_table_macros::declare_syscall!(SYS_SETGID, SysSetGid);
|