electron/patches/node/feat_initialize_asar_support.patch
electron-roller[bot] ef5d5f888d
chore: bump node to v18.17.1 (main) (#39457)
* chore: bump node in DEPS to v18.17.1

* chore: update patches

* policy: disable process.binding() when enabled

d4570fae35

---------

Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com>
Co-authored-by: PatchUp <73610968+patchup[bot]@users.noreply.github.com>
Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
2023-08-15 10:06:55 +02:00

54 lines
2.1 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shelley Vohr <shelley.vohr@gmail.com>
Date: Thu, 13 Sep 2018 08:56:07 -0700
Subject: feat: initialize asar support
This patch initializes asar support in Node.js.
diff --git a/lib/internal/process/policy.js b/lib/internal/process/policy.js
index 8e07cb92118c84b2bc1156532cae8b033b9a48f4..2073a024ad548fe80e84cafee012b003454d6c93 100644
--- a/lib/internal/process/policy.js
+++ b/lib/internal/process/policy.js
@@ -39,9 +39,6 @@ module.exports = ObjectFreeze({
process.binding = function binding(_module) {
throw new ERR_ACCESS_DENIED('process.binding');
};
- process._linkedBinding = function _linkedBinding(_module) {
- throw new ERR_ACCESS_DENIED('process._linkedBinding');
- };
},
get manifest() {
diff --git a/lib/internal/process/pre_execution.js b/lib/internal/process/pre_execution.js
index 250a43c5455b4f9ff72dd3a34d5b0aa270f43cc6..2e35cbba2ac02494c44821af395fe0195b1ab6b5 100644
--- a/lib/internal/process/pre_execution.js
+++ b/lib/internal/process/pre_execution.js
@@ -117,12 +117,17 @@ function setupUserModules() {
loadPreloadModules();
// Need to be done after --require setup.
initializeFrozenIntrinsics();
+ setupAsarSupport();
}
function refreshRuntimeOptions() {
refreshOptions();
}
+function setupAsarSupport() {
+ process._linkedBinding('electron_common_asar').initAsarSupport(require);
+}
+
function patchProcessObject(expandArgv1) {
const binding = internalBinding('process_methods');
binding.patchProcessObject(process);
diff --git a/test/fixtures/policy/process-binding/app.js b/test/fixtures/policy/process-binding/app.js
index 16e26d12a160286b1b6aaeb64b15668b05b9865b..a287d0a2363acbf24077eec040116f96ef18a7b3 100644
--- a/test/fixtures/policy/process-binding/app.js
+++ b/test/fixtures/policy/process-binding/app.js
@@ -5,6 +5,3 @@ const assert = require('assert');
assert.throws(() => { process.binding(); }, {
code: 'ERR_ACCESS_DENIED'
});
-assert.throws(() => { process._linkedBinding(); }, {
- code: 'ERR_ACCESS_DENIED'
-});