Skip to content

Commit 6633481

Browse files
authored
Add -N, --add-entitlements flags to append entitlements from file
* Merge entitlements from file * Append entitlements when not pseudo-signing
1 parent 08a41c8 commit 6633481

2 files changed

Lines changed: 16 additions & 1 deletion

File tree

index.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,13 +316,24 @@ class Applesign {
316316
this.debugObject[f][key] = val;
317317
}
318318

319+
addEntitlementsSync (orig) {
320+
if (this.config.addEntitlements === undefined) {
321+
return orig;
322+
}
323+
this.emit('message', 'Adding entitlements from file');
324+
const addEnt = plist.readFileSync(this.config.addEntitlements);
325+
// TODO: deepmerge
326+
return Object.assign(orig, addEnt);
327+
}
328+
319329
adjustEntitlementsSync (file, entMobProv) {
320330
if (this.config.pseudoSign) {
321331
const ent = bin.entitlements(file);
322332
if (ent === null) {
323333
return;
324334
}
325-
const entMacho = plist.parse(ent.toString().trim());
335+
let entMacho = plist.parse(ent.toString().trim());
336+
entMacho = this.addEntitlementsSync(entMacho);
326337
// TODO: merge additional entitlements here
327338
const newEntitlements = plistBuild(entMacho).toString();
328339
const newEntitlementsFile = file + '.entitlements';
@@ -343,6 +354,7 @@ class Applesign {
343354
let entMacho;
344355
if (ent !== null) {
345356
entMacho = plist.parse(ent.toString().trim());
357+
entMacho = this.addEntitlementsSync(entMacho);
346358
this.debugInfo(file, 'fullPath', file);
347359
this.debugInfo(file, 'oldEntitlements', entMacho || 'TODO');
348360
if (this.config.selfSignedProvision) {

lib/config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ const helpMessage = `Usage:
7878
-c, --clone-entitlements Clone the entitlements from the provisioning to the bin
7979
-e, --entitlements [ENTITL] Specify entitlements file (EXPERIMENTAL)
8080
-E, --entry-entitlement Use generic entitlement (EXPERIMENTAL)
81+
-N, --add-entitlements [FILE] Append entitlements from file (EXPERIMENTAL)
8182
-M, --massage-entitlements Massage entitlements to remove privileged ones
8283
-t, --without-get-task-allow Do not set the get-task-allow entitlement (EXPERIMENTAL)
8384
-C, --no-entitlements-file Do not create .entitlements file in the IPA
@@ -150,6 +151,7 @@ const fromOptions = function (opt) {
150151
all: opt.all || false,
151152
allDirs: opt.allDirs || true,
152153
allowHttp: opt.allowHttp || false,
154+
addEntitlements: opt.addEntitlements || undefined,
153155
bundleIdKeychainGroup: opt.bundleIdKeychainGroup || false,
154156
bundleid: opt.bundleid || undefined,
155157
cloneEntitlements: opt.cloneEntitlements || false,
@@ -245,6 +247,7 @@ function compile (conf) {
245247
all: conf.a || conf.all || false,
246248
allDirs: conf['all-dirs'] || conf.A,
247249
allowHttp: conf['allow-http'] || conf.H,
250+
addEntitlements: conf['add-entitlements'] || conf.N,
248251
bundleIdKeychainGroup: conf.B || conf['bundleid-access-group'],
249252
bundleid: conf.bundleid || conf.b,
250253
cloneEntitlements: conf.c || conf['clone-entitlements'],

0 commit comments

Comments
 (0)