mirror of
https://github.com/tiann/KernelSU.git
synced 2025-02-20 11:43:32 +08:00
Use rustix for setgroups
(#1334)
This commit is contained in:
parent
f80769a82a
commit
f80d0764b5
@ -1,4 +1,5 @@
|
||||
use anyhow::{Ok, Result};
|
||||
use core::slice::SlicePattern;
|
||||
use getopts::Options;
|
||||
use std::env;
|
||||
#[cfg(unix)]
|
||||
@ -38,14 +39,15 @@ fn print_usage(program: &str, opts: Options) {
|
||||
}
|
||||
|
||||
fn set_identity(uid: u32, gid: u32, groups: &[u32]) {
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
unsafe {
|
||||
if !groups.is_empty() {
|
||||
libc::setgroups(groups.len(), groups.as_ptr());
|
||||
}
|
||||
}
|
||||
#[cfg(any(target_os = "linux", target_os = "android"))]
|
||||
{
|
||||
rustix::process::set_groups(
|
||||
groups
|
||||
.iter()
|
||||
.map(|g| unsafe { Gid::from_raw(*g) })
|
||||
.collect::<Vec<_>>()
|
||||
.as_slice(),
|
||||
);
|
||||
let gid = unsafe { Gid::from_raw(gid) };
|
||||
let uid = unsafe { Uid::from_raw(uid) };
|
||||
set_thread_res_gid(gid, gid, gid).ok();
|
||||
|
Loading…
x
Reference in New Issue
Block a user