Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use plugin executable for utility process on macOS #161102

Merged
merged 1 commit into from Sep 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 14 additions & 0 deletions build/azure-pipelines/darwin/helper-plugin-entitlements.plist
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
</dict>
</plist>
11 changes: 10 additions & 1 deletion build/darwin/sign.js
Expand Up @@ -26,6 +26,7 @@ async function main() {
const helperAppBaseName = product.nameShort;
const gpuHelperAppName = helperAppBaseName + ' Helper (GPU).app';
const rendererHelperAppName = helperAppBaseName + ' Helper (Renderer).app';
const pluginHelperAppName = helperAppBaseName + ' Helper (Plugin).app';
const infoPlistPath = path.resolve(appRoot, appName, 'Contents', 'Info.plist');
const defaultOpts = {
app: path.join(appRoot, appName),
Expand All @@ -45,7 +46,8 @@ async function main() {
// TODO(deepak1556): Incorrectly declared type in electron-osx-sign
ignore: (filePath) => {
return filePath.includes(gpuHelperAppName) ||
filePath.includes(rendererHelperAppName);
filePath.includes(rendererHelperAppName) ||
filePath.includes(pluginHelperAppName);
}
};
const gpuHelperOpts = {
Expand All @@ -60,6 +62,12 @@ async function main() {
entitlements: path.join(baseDir, 'azure-pipelines', 'darwin', 'helper-renderer-entitlements.plist'),
'entitlements-inherit': path.join(baseDir, 'azure-pipelines', 'darwin', 'helper-renderer-entitlements.plist'),
};
const pluginHelperOpts = {
...defaultOpts,
app: path.join(appFrameworkPath, pluginHelperAppName),
entitlements: path.join(baseDir, 'azure-pipelines', 'darwin', 'helper-plugin-entitlements.plist'),
'entitlements-inherit': path.join(baseDir, 'azure-pipelines', 'darwin', 'helper-plugin-entitlements.plist'),
};
// Only overwrite plist entries for x64 and arm64 builds,
// universal will get its copy from the x64 build.
if (arch !== 'universal') {
Expand Down Expand Up @@ -87,6 +95,7 @@ async function main() {
}
await codesign.signAsync(gpuHelperOpts);
await codesign.signAsync(rendererHelperOpts);
await codesign.signAsync(pluginHelperOpts);
await codesign.signAsync(appOpts);
}
if (require.main === module) {
Expand Down
12 changes: 11 additions & 1 deletion build/darwin/sign.ts
Expand Up @@ -29,6 +29,7 @@ async function main(): Promise<void> {
const helperAppBaseName = product.nameShort;
const gpuHelperAppName = helperAppBaseName + ' Helper (GPU).app';
const rendererHelperAppName = helperAppBaseName + ' Helper (Renderer).app';
const pluginHelperAppName = helperAppBaseName + ' Helper (Plugin).app';
const infoPlistPath = path.resolve(appRoot, appName, 'Contents', 'Info.plist');

const defaultOpts: codesign.SignOptions = {
Expand All @@ -50,7 +51,8 @@ async function main(): Promise<void> {
// TODO(deepak1556): Incorrectly declared type in electron-osx-sign
ignore: (filePath: string) => {
return filePath.includes(gpuHelperAppName) ||
filePath.includes(rendererHelperAppName);
filePath.includes(rendererHelperAppName) ||
filePath.includes(pluginHelperAppName);
}
};

Expand All @@ -68,6 +70,13 @@ async function main(): Promise<void> {
'entitlements-inherit': path.join(baseDir, 'azure-pipelines', 'darwin', 'helper-renderer-entitlements.plist'),
};

const pluginHelperOpts: codesign.SignOptions = {
...defaultOpts,
app: path.join(appFrameworkPath, pluginHelperAppName),
entitlements: path.join(baseDir, 'azure-pipelines', 'darwin', 'helper-plugin-entitlements.plist'),
'entitlements-inherit': path.join(baseDir, 'azure-pipelines', 'darwin', 'helper-plugin-entitlements.plist'),
};

// Only overwrite plist entries for x64 and arm64 builds,
// universal will get its copy from the x64 build.
if (arch !== 'universal') {
Expand Down Expand Up @@ -96,6 +105,7 @@ async function main(): Promise<void> {

await codesign.signAsync(gpuHelperOpts);
await codesign.signAsync(rendererHelperOpts);
await codesign.signAsync(pluginHelperOpts);
await codesign.signAsync(appOpts as any);
}

Expand Down
Expand Up @@ -424,6 +424,7 @@ class UtilityExtensionHostProcess extends Disposable {
const args: string[] = ['--type=extensionHost', '--skipWorkspaceStorageLock'];
const execArgv: string[] = opts.execArgv || [];
const env: { [key: string]: any } = { ...opts.env };
const allowLoadingUnsignedLibraries: boolean = true;

// Make sure all values are strings, otherwise the process will not start
for (const key of Object.keys(env)) {
Expand All @@ -432,7 +433,7 @@ class UtilityExtensionHostProcess extends Disposable {

this._logService.info(`UtilityProcess<${this.id}>: Creating new...`);

this._process = new UtilityProcess(modulePath, args, { serviceName, env, execArgv });
this._process = new UtilityProcess(modulePath, args, { serviceName, env, execArgv, allowLoadingUnsignedLibraries });

const stdoutDecoder = new StringDecoder('utf-8');
this._process.stdout?.on('data', (chunk) => {
Expand Down