mirror of
https://github.com/denoland/deno.git
synced 2024-11-21 15:04:11 -05:00
fix: Add sys permission kinds for node compat (#24242)
Fixes #24241 * Support "statfs", "username", "getPriority" and "setPriority" kinds for `--allow-sys`. * Check individual permissions in `node:os.userInfo()` instead of a single "userInfo" permission. * Check for "uid" permission in `node:process.geteuid()` instead of "geteuid". * Add missing "homedir" to `SysPermissionDescriptor.kind` union Co-authored-by: Bartek Iwańczuk <biwanczuk@gmail.com>
This commit is contained in:
parent
9a0d59d95d
commit
82f9216610
3 changed files with 10 additions and 6 deletions
7
cli/tsc/dts/lib.deno.ns.d.ts
vendored
7
cli/tsc/dts/lib.deno.ns.d.ts
vendored
|
@ -4969,7 +4969,12 @@ declare namespace Deno {
|
|||
| "osUptime"
|
||||
| "uid"
|
||||
| "gid"
|
||||
| "cpus";
|
||||
| "username"
|
||||
| "cpus"
|
||||
| "homedir"
|
||||
| "statfs"
|
||||
| "getPriority"
|
||||
| "setPriority";
|
||||
}
|
||||
|
||||
/** The permission descriptor for the `allow-ffi` and `deny-ffi` permissions, which controls
|
||||
|
|
|
@ -50,7 +50,7 @@ where
|
|||
{
|
||||
{
|
||||
let permissions = state.borrow_mut::<P>();
|
||||
permissions.check_sys("userInfo", "node:os.userInfo()")?;
|
||||
permissions.check_sys("username", "node:os.userInfo()")?;
|
||||
}
|
||||
|
||||
Ok(deno_whoami::username())
|
||||
|
@ -63,7 +63,7 @@ where
|
|||
{
|
||||
{
|
||||
let permissions = state.borrow_mut::<P>();
|
||||
permissions.check_sys("geteuid", "node:os.geteuid()")?;
|
||||
permissions.check_sys("uid", "node:os.geteuid()")?;
|
||||
}
|
||||
|
||||
#[cfg(windows)]
|
||||
|
|
|
@ -997,9 +997,8 @@ impl Descriptor for SysDescriptor {
|
|||
pub fn parse_sys_kind(kind: &str) -> Result<&str, AnyError> {
|
||||
match kind {
|
||||
"hostname" | "osRelease" | "osUptime" | "loadavg" | "networkInterfaces"
|
||||
| "systemMemoryInfo" | "uid" | "gid" | "cpus" | "homedir" | "getegid" => {
|
||||
Ok(kind)
|
||||
}
|
||||
| "systemMemoryInfo" | "uid" | "gid" | "cpus" | "homedir" | "getegid"
|
||||
| "username" | "statfs" | "getPriority" | "setPriority" => Ok(kind),
|
||||
_ => Err(type_error(format!("unknown system info kind \"{kind}\""))),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue