diff options
author | Divy Srivastava <dj.srivastava23@gmail.com> | 2023-11-10 10:49:57 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-10 11:49:57 -0700 |
commit | df14835b83085017e9cf9ae66a71cd523385c5c4 (patch) | |
tree | d258e907a9f94ebf0cd895b3fcf4441aa6a9f54a /ext/node/ops/os.rs | |
parent | b78c7130e9986ce41284f33a0803ecdf6dd6affd (diff) |
fix(ext/node): implement process.geteuid (#21151)
Fixes #21097
Diffstat (limited to 'ext/node/ops/os.rs')
-rw-r--r-- | ext/node/ops/os.rs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/ext/node/ops/os.rs b/ext/node/ops/os.rs index 9fb0b44e1..4f6f56f31 100644 --- a/ext/node/ops/os.rs +++ b/ext/node/ops/os.rs @@ -52,6 +52,25 @@ where Ok(deno_whoami::username()) } +#[op2(fast)] +pub fn op_geteuid<P>(state: &mut OpState) -> Result<u32, AnyError> +where + P: NodePermissions + 'static, +{ + { + let permissions = state.borrow_mut::<P>(); + permissions.check_sys("geteuid", "node:os.geteuid()")?; + } + + #[cfg(windows)] + let euid = 0; + #[cfg(unix)] + // SAFETY: Call to libc geteuid. + let euid = unsafe { libc::geteuid() }; + + Ok(euid) +} + #[cfg(unix)] mod priority { use super::*; |