ksud: fix compile err in x86_64

This commit is contained in:
tiann
2023-04-04 14:12:37 +08:00
parent c1b30458d6
commit 8d12f96d8b

View File

@@ -161,11 +161,15 @@ pub fn root_shell() -> Result<()> {
}
let mut uid = 0; // default uid = 0(root)
#[cfg(any(target_os = "linux", target_os = "android"))]
if free_idx < matches.free.len() {
let name = &matches.free[free_idx];
uid = unsafe {
match libc::getpwnam(name.as_ptr() as *const u8).as_ref() {
#[cfg(target_arch = "aarch64")]
let pw = libc::getpwnam(name.as_ptr() as *const u8).as_ref();
#[cfg(target_arch = "x86_64")]
let pw = libc::getpwnam(name.as_ptr() as *const i8).as_ref();
match pw {
Some(pw) => pw.pw_uid,
None => name.parse::<u32>().unwrap_or(0),
}