diff options
author | Nathan Whitaker <17734409+nathanwhit@users.noreply.github.com> | 2024-10-31 22:18:33 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-31 22:18:33 -0700 |
commit | 6c6bbeb97495e8c3e8eac7bea27bf836f02b575f (patch) | |
tree | c64933f984e01d3aacae6ee03a13a1a78db45392 /runtime | |
parent | 6d44952d4daaaab8ed9ec82212d2256c058eb05d (diff) |
fix(node): Implement `os.userInfo` properly, add missing `toPrimitive` (#24702)
Fixes the implementation of `os.userInfo`, and adds a missing
`toPrimitive` for `tmpdir`. This allows us to enable the corresponding
node_compat test.
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/errors.rs | 1 | ||||
-rw-r--r-- | runtime/permissions/lib.rs | 8 |
2 files changed, 7 insertions, 2 deletions
diff --git a/runtime/errors.rs b/runtime/errors.rs index 07bf694dc..a5c436e75 100644 --- a/runtime/errors.rs +++ b/runtime/errors.rs @@ -1086,6 +1086,7 @@ mod node { }, OsError::Permission(e) => get_error_class_name(e).unwrap_or("Error"), OsError::FailedToGetCpuInfo => "TypeError", + OsError::FailedToGetUserInfo(e) => get_io_error_class(e), } } diff --git a/runtime/permissions/lib.rs b/runtime/permissions/lib.rs index 1e1321bb2..84503f025 100644 --- a/runtime/permissions/lib.rs +++ b/runtime/permissions/lib.rs @@ -1368,8 +1368,12 @@ impl SysDescriptor { match kind.as_str() { "hostname" | "osRelease" | "osUptime" | "loadavg" | "networkInterfaces" | "systemMemoryInfo" | "uid" | "gid" | "cpus" - | "homedir" | "getegid" | "username" | "statfs" | "getPriority" - | "setPriority" => Ok(Self(kind)), + | "homedir" | "getegid" | "statfs" | "getPriority" | "setPriority" + | "userInfo" => Ok(Self(kind)), + + // the underlying permission check changed to `userInfo` to better match the API, + // alias this to avoid breaking existing projects with `--allow-sys=username` + "username" => Ok(Self("userInfo".into())), _ => Err(type_error(format!("unknown system info kind \"{kind}\""))), } } |