mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 20:29:11 +00:00
fix(ext/node): export geteuid from node:process (#23840)
Fixes https://github.com/denoland/deno/issues/23827
This commit is contained in:
parent
f6c6e768c8
commit
a31b81394b
2 changed files with 15 additions and 9 deletions
|
@ -301,6 +301,16 @@ export function kill(pid: number, sig: string | number = "SIGTERM") {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let getgid, getuid, geteuid;
|
||||||
|
|
||||||
|
if (!isWindows) {
|
||||||
|
getgid = () => Deno.gid();
|
||||||
|
getuid = () => Deno.uid();
|
||||||
|
geteuid = () => op_geteuid();
|
||||||
|
}
|
||||||
|
|
||||||
|
export { geteuid, getgid, getuid };
|
||||||
|
|
||||||
// deno-lint-ignore no-explicit-any
|
// deno-lint-ignore no-explicit-any
|
||||||
function uncaughtExceptionHandler(err: any, origin: string) {
|
function uncaughtExceptionHandler(err: any, origin: string) {
|
||||||
// The origin parameter can be 'unhandledRejection' or 'uncaughtException'
|
// The origin parameter can be 'unhandledRejection' or 'uncaughtException'
|
||||||
|
@ -638,19 +648,13 @@ class Process extends EventEmitter {
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method is removed on Windows */
|
/** This method is removed on Windows */
|
||||||
getgid?(): number {
|
getgid = getgid;
|
||||||
return Deno.gid()!;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** This method is removed on Windows */
|
/** This method is removed on Windows */
|
||||||
getuid?(): number {
|
getuid = getuid;
|
||||||
return Deno.uid()!;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** This method is removed on Windows */
|
/** This method is removed on Windows */
|
||||||
geteuid?(): number {
|
geteuid = geteuid;
|
||||||
return op_geteuid();
|
|
||||||
}
|
|
||||||
|
|
||||||
// TODO(kt3k): Implement this when we added -e option to node compat mode
|
// TODO(kt3k): Implement this when we added -e option to node compat mode
|
||||||
_eval: string | undefined = undefined;
|
_eval: string | undefined = undefined;
|
||||||
|
|
|
@ -6,6 +6,7 @@ import process, {
|
||||||
argv,
|
argv,
|
||||||
argv0 as importedArgv0,
|
argv0 as importedArgv0,
|
||||||
env,
|
env,
|
||||||
|
geteuid,
|
||||||
pid as importedPid,
|
pid as importedPid,
|
||||||
platform as importedPlatform,
|
platform as importedPlatform,
|
||||||
} from "node:process";
|
} from "node:process";
|
||||||
|
@ -879,6 +880,7 @@ Deno.test("process.geteuid", () => {
|
||||||
if (Deno.build.os === "windows") {
|
if (Deno.build.os === "windows") {
|
||||||
assertEquals(process.geteuid, undefined);
|
assertEquals(process.geteuid, undefined);
|
||||||
} else {
|
} else {
|
||||||
|
assert(geteuid);
|
||||||
assert(typeof process.geteuid?.() === "number");
|
assert(typeof process.geteuid?.() === "number");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue