Skip to content

Commit

Permalink
feat(mac): add loginhelper entitlement option (#5023)
Browse files Browse the repository at this point in the history
* Initial commit

Port of changes from electron/osx-sign#210, plus changes to macPackager

* Update logic in sign.js
  • Loading branch information
jack-arms authored Jul 9, 2020
1 parent 11874be commit 7109e88
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/app-builder-lib/electron-osx-sign/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface SignOptions extends BaseSignOptions {
binaries?: string[];
entitlements?: string;
'entitlements-inherit'?: string;
'entitlements-loginhelper'?: string;
'gatekeeper-assess'?: boolean;
hardenedRuntime?: boolean;
'identity-validation'?: boolean;
Expand Down
13 changes: 12 additions & 1 deletion packages/app-builder-lib/electron-osx-sign/sign.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,12 @@ function signApplicationAsync (opts) {
continue
}
debuglog('Signing... ' + filePath)
await execFileAsync('codesign', args.concat('--entitlements', opts['entitlements-inherit'], filePath))
let entitlementsFile = opts['entitlements-inherit']
if (filePath.includes('Library/LoginItems')) {
entitlementsFile = opts['entitlements-loginhelper']
}

await execFileAsync('codesign', args.concat('--entitlements', entitlementsFile, filePath))
}
debuglog('Signing... ' + opts.app)
await execFileAsync('codesign', args.concat('--entitlements', opts.entitlements, opts.app))
Expand Down Expand Up @@ -335,6 +340,12 @@ const signAsync = module.exports.signAsync = function (opts) {
}
}
}
if (!opts['entitlements-loginhelper']) {
filePath = opts.entitlements
debugwarn('No `entitlements-loginhelper` passed in arguments:', '\n',
'* Sandbox entitlements file for login helper is default to:', filePath)
opts['entitlements-loginhelper'] = filePath
}
})
.then(async function () {
// Pre-sign operations
Expand Down
16 changes: 15 additions & 1 deletion packages/app-builder-lib/scheme.json
Original file line number Diff line number Diff line change
Expand Up @@ -1982,6 +1982,13 @@
"string"
]
},
"entitlementsLoginHelper": {
"desciption": "Path to login helper entitlement file. When using App Sandbox, the the `com.apple.security.inherit` key that is normally in the inheritted entitlements cannot be inherited since the login helper is a standalone executable. Defaults to the value provided for `entitlements`.\n\nThis option only applies when signing with `entitlements` provided.",
"type": [
"null",
"string"
]
},
"extendInfo": {
"description": "The extra entries for `Info.plist`."
},
Expand Down Expand Up @@ -2522,6 +2529,13 @@
"string"
]
},
"entitlementsLoginHelper": {
"desciption": "Path to login helper entitlement file. When using App Sandbox, the the `com.apple.security.inherit` key that is normally in the inheritted entitlements cannot be inherited since the login helper is a standalone executable. Defaults to the value provided for `entitlements`.\n\nThis option only applies when signing with `entitlements` provided.",
"type": [
"null",
"string"
]
},
"extendInfo": {
"description": "The extra entries for `Info.plist`."
},
Expand Down Expand Up @@ -6102,4 +6116,4 @@
}
},
"type": "object"
}
}
1 change: 1 addition & 0 deletions packages/app-builder-lib/src/macPackager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ export default class MacPackager extends PlatformPackager<MacConfiguration> {
if (customSignOptions.provisioningProfile != null) {
signOptions["provisioning-profile"] = customSignOptions.provisioningProfile
}
signOptions['entitlements-loginhelper'] = customSignOptions.entitlementsLoginHelper
}

//noinspection JSMethodCanBeStatic
Expand Down
2 changes: 2 additions & 0 deletions packages/app-builder-lib/src/options/macOptions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ export interface MacConfiguration extends PlatformSpecificBuildOptions {
*/
readonly entitlementsInherit?: string | null

readonly entitlementsLoginHelper?: string | null

/**
* The path to the provisioning profile to use when signing, absolute or relative to the app root.
*/
Expand Down

0 comments on commit 7109e88

Please sign in to comment.