mirror of
https://github.com/denoland/deno.git
synced 2025-03-03 17:34:47 -05:00
parent
f2d94b6ef0
commit
6e4aa70335
4 changed files with 35 additions and 0 deletions
|
@ -728,6 +728,14 @@ Deno.test("process.getuid", () => {
|
|||
}
|
||||
});
|
||||
|
||||
Deno.test("process.geteuid", () => {
|
||||
if (Deno.build.os === "windows") {
|
||||
assertEquals(process.geteuid, undefined);
|
||||
} else {
|
||||
assert(typeof process.geteuid?.() === "number");
|
||||
}
|
||||
});
|
||||
|
||||
Deno.test({
|
||||
name: "process.exit",
|
||||
async fn() {
|
||||
|
|
|
@ -248,6 +248,7 @@ deno_core::extension!(deno_node,
|
|||
ops::os::op_node_os_get_priority<P>,
|
||||
ops::os::op_node_os_set_priority<P>,
|
||||
ops::os::op_node_os_username<P>,
|
||||
ops::os::op_geteuid<P>,
|
||||
op_node_build_os,
|
||||
op_is_any_arraybuffer,
|
||||
op_node_is_promise_rejected,
|
||||
|
|
|
@ -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::*;
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
const internals = globalThis.__bootstrap.internals;
|
||||
const { core } = globalThis.__bootstrap;
|
||||
const { ops } = core;
|
||||
import { notImplemented, warnNotImplemented } from "ext:deno_node/_utils.ts";
|
||||
import { EventEmitter } from "node:events";
|
||||
import Module from "node:module";
|
||||
|
@ -652,6 +653,11 @@ class Process extends EventEmitter {
|
|||
return Deno.uid()!;
|
||||
}
|
||||
|
||||
/** This method is removed on Windows */
|
||||
geteuid?(): number {
|
||||
return ops.op_geteuid();
|
||||
}
|
||||
|
||||
// TODO(kt3k): Implement this when we added -e option to node compat mode
|
||||
_eval: string | undefined = undefined;
|
||||
|
||||
|
@ -693,6 +699,7 @@ class Process extends EventEmitter {
|
|||
if (isWindows) {
|
||||
delete Process.prototype.getgid;
|
||||
delete Process.prototype.getuid;
|
||||
delete Process.prototype.geteuid;
|
||||
}
|
||||
|
||||
/** https://nodejs.org/api/process.html#process_process */
|
||||
|
|
Loading…
Add table
Reference in a new issue