#53528: refactor: look up internalBinding and linked bindings without patching Node
Merged
Description of Change
Two Node patches existed only to hand Electron things it can reach on its own:
refactor_allow_embedder_overriding_of_internal_fs_callsstashedinternalBindingonprocessduring bootstrap solib/node/asar-fs-wrapper.tscould grab (and delete) it. The wrapper runs as a builtin with Node's internalrequire, andrequire('internal/bootstrap/realm')already returns the loader exports includinginternalBinding, so it takes it from there andprocess.internalBindingnever exists.expose_get_builtin_module_functionexportednode::binding::get_linked_module()so sandboxed preloads (nonode::Environment) could find a linked binding by name inshell/renderer/preload_utils.cc. Electron's ownNODE_LINKED_BINDING_CONTEXT_AWAREmacro now also emits aget_linked_module_<name>()accessor next to each binding, andNodeBindings::GetLinkedBinding()resolves a name against the same per-process binding listsRegisterBuiltinBindings()uses;preload_utils.cccalls that instead. This also retires theTODO(codebytere)in the patch.
Verified on Linux: asar reads/stat in the browser, renderer and ELECTRON_RUN_AS_NODE, process.internalBinding absent everywhere, a sandboxed preload using ipcRenderer, and the asar, ipcRenderer and process spec files pass.
Checklist
- I have built and tested this change
- I have filled out the PR description
- I have reviewed and verified the changes
-
npm testpasses
Release Notes
Notes: none
Backports
45-x-y
In-flightSemver Impact
Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.
Semantic Versioning helps users understand the impact of updates:
- Major (X.y.z): Breaking changes that may require code modifications
- Minor (x.Y.z): New features that maintain backward compatibility
- Patch (x.y.Z): Bug fixes that don't change the API
- None: Changes that don't affect using facing parts of Electron