From 67da21ccfc14b29506710ad1133de8a9d42fdef8 Mon Sep 17 00:00:00 2001 From: osy86 <50960678+osy86@users.noreply.github.com> Date: Tue, 3 Nov 2020 14:02:19 -0800 Subject: [PATCH] Hide private entitlements on >= iOS 13.5 (#415) iOS 13.5 fixes the psychic paper hack so showing the private entitlement warning popup is confusing to the user. Additionally iOS 14 checks the entitlements on installation, so we should not copy the private entitlements on iOS 14. Depends on https://github.com/rileytestut/AltSign/pull/15 Co-authored-by: osy --- AltStore/Operations/VerifyAppOperation.swift | 61 ++++++++++++-------- 1 file changed, 37 insertions(+), 24 deletions(-) diff --git a/AltStore/Operations/VerifyAppOperation.swift b/AltStore/Operations/VerifyAppOperation.swift index 1bce9d1e..701adfef 100644 --- a/AltStore/Operations/VerifyAppOperation.swift +++ b/AltStore/Operations/VerifyAppOperation.swift @@ -70,32 +70,45 @@ class VerifyAppOperation: ResultOperation throw VerificationError.mismatchedBundleIdentifiers(app, sourceBundleID: self.context.bundleIdentifier) } - // Make sure this goes last, since once user responds to alert we don't do any more app verification. - if let commentStart = app.entitlementsString.range(of: ""), let commentEnd = app.entitlementsString.range(of: "") + if #available(iOS 13.5, *) { - // Psychic Paper private entitlements. - - let entitlementsStart = app.entitlementsString.index(after: commentStart.upperBound) - let rawEntitlements = String(app.entitlementsString[entitlementsStart ..< commentEnd.lowerBound]) - - let plistTemplate = """ - - - - - %@ - - - """ - let entitlementsPlist = String(format: plistTemplate, rawEntitlements) - let entitlements = try PropertyListSerialization.propertyList(from: entitlementsPlist.data(using: .utf8)!, options: [], format: nil) as! [String: Any] - - let error = VerificationError.privateEntitlements(app, entitlements: entitlements) - self.process(error) { (result) in - self.finish(result.mapError { $0 as Error }) + // No psychic paper, so we can ignore private entitlements + app.hasPrivateEntitlements = false + } + else + { + // Make sure this goes last, since once user responds to alert we don't do any more app verification. + if let commentStart = app.entitlementsString.range(of: ""), let commentEnd = app.entitlementsString.range(of: "") + { + // Psychic Paper private entitlements. + + let entitlementsStart = app.entitlementsString.index(after: commentStart.upperBound) + let rawEntitlements = String(app.entitlementsString[entitlementsStart ..< commentEnd.lowerBound]) + + let plistTemplate = """ + + + + + %@ + + + """ + let entitlementsPlist = String(format: plistTemplate, rawEntitlements) + let entitlements = try PropertyListSerialization.propertyList(from: entitlementsPlist.data(using: .utf8)!, options: [], format: nil) as! [String: Any] + + app.hasPrivateEntitlements = true + let error = VerificationError.privateEntitlements(app, entitlements: entitlements) + self.process(error) { (result) in + self.finish(result.mapError { $0 as Error }) + } + + return + } + else + { + app.hasPrivateEntitlements = false } - - return } self.finish(.success(()))