Files
orca/native/windows-security/index.js
T
Neil b6ffc2079b fix(windows): keep Orca's std handles out of every spawned child (#35678)
* fix(windows): keep Orca's std handles out of every spawned child

libuv spawns with bInheritHandles=TRUE, so an inheritable std handle reached
long-lived children such as the WSL holder and the daemon and held a
launcher's pipe open after Orca exited. Clear HANDLE_FLAG_INHERIT on the std
handles at the top of main startup; stdio 'inherit' still works because
libuv hands the child its own inheritable duplicate.

* test(windows): model Orca's Electron main, which keeps std handles inheritable

Plain Node clears its std handles' inherit flag at startup, so a Node child
never reproduced the leak. Electron main opts out of that, which is why Orca
leaks and why the control arm now runs Electron; a plain-Node arm pins the
difference.

* test(windows): say why the std-handle tests need longer timeouts
2026-10-29 00:08:27 -07:00

23 lines
894 B
JavaScript

'use strict'
// Load lazily because non-Windows installs have no addon, including during test collection.
let addon = null
function getAddon() {
if (!addon) {
addon = require('./build/Release/orca_windows_security.node')
}
return addon
}
module.exports = {
currentUserSid: () => getAddon().currentUserSid(),
getDaclAces: (path) => getAddon().getDaclAces(path),
setDaclSddl: (path, sddl) => getAddon().setDaclSddl(path, sddl),
setDaclSddlAsync: (path, sddl) => getAddon().setDaclSddlAsync(path, sddl),
createFileWithDacl: (path, sddl, data) => getAddon().createFileWithDacl(path, sddl, data),
grantAccess: (path, sid, mask, options) => getAddon().grantAccess(path, sid, mask, options),
grantAccessAsync: (path, sid, mask, options) =>
getAddon().grantAccessAsync(path, sid, mask, options),
clearStdHandleInheritance: () => getAddon().clearStdHandleInheritance()
}