mirror of
https://github.com/termux/termux-packages.git
synced 2025-08-15 20:33:10 +00:00
Co-authored-by: Chongyun Lee <45286352+licy183@users.noreply.github.com> Co-authored-by: Jia Yuan Lo <jylo06g@gmail.com>
29 lines
702 B
Diff
29 lines
702 B
Diff
`setgroups` are only allowed when user is root, i.e. `getuid() == 0`
|
|
|
|
https://github.com/denoland/deno/issues/19759#issuecomment-2914426954
|
|
|
|
--- a/ext/process/lib.rs
|
|
+++ b/ext/process/lib.rs
|
|
@@ -520,7 +520,9 @@
|
|
libc::close(src);
|
|
}
|
|
}
|
|
- libc::setgroups(0, std::ptr::null());
|
|
+ if libc::getuid() == 0 {
|
|
+ libc::setgroups(0, std::ptr::null());
|
|
+ }
|
|
Ok(())
|
|
});
|
|
|
|
@@ -1068,7 +1070,9 @@
|
|
#[allow(clippy::undocumented_unsafe_blocks)]
|
|
unsafe {
|
|
c.pre_exec(|| {
|
|
- libc::setgroups(0, std::ptr::null());
|
|
+ if libc::getuid() == 0 {
|
|
+ libc::setgroups(0, std::ptr::null());
|
|
+ }
|
|
Ok(())
|
|
});
|
|
}
|