diff options
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::*; |