From a04a27c1e32718d1a4d4c182c67402535b36491b Mon Sep 17 00:00:00 2001 From: Riley Testut Date: Thu, 31 Mar 2022 12:50:50 -0700 Subject: [PATCH] Disables app group feature if app has no app groups MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We can’t remove all app groups from an App ID once one has been assigned, but we _can_ disable app groups completely for effectively the same result. This fixes some apps having permanant access to AltStore’s own app group after being (de-)activated. --- AltServer/Devices/ALTDeviceManager+Installation.swift | 11 +++++++++++ .../FetchProvisioningProfilesOperation.swift | 11 +++++++++++ 2 files changed, 22 insertions(+) diff --git a/AltServer/Devices/ALTDeviceManager+Installation.swift b/AltServer/Devices/ALTDeviceManager+Installation.swift index a0c70667..74fbe3ab 100644 --- a/AltServer/Devices/ALTDeviceManager+Installation.swift +++ b/AltServer/Devices/ALTDeviceManager+Installation.swift @@ -629,8 +629,14 @@ private extension ALTDeviceManager if let applicationGroups = app.entitlements[.appGroups] as? [String], !applicationGroups.isEmpty { + // App uses app groups, so assign `true` to enable the feature. features[.appGroups] = true } + else + { + // App has no app groups, so assign `false` to disable the feature. + features[.appGroups] = false + } var updateFeatures = false @@ -642,6 +648,11 @@ private extension ALTDeviceManager // AppID already has this feature enabled and the values are the same. continue } + else if appID.features[feature] == nil, let shouldEnableFeature = value as? Bool, !shouldEnableFeature + { + // AppID doesn't already have this feature enabled, but we want it disabled anyway. + continue + } else { // AppID either doesn't have this feature enabled or the value has changed, diff --git a/AltStore/Operations/FetchProvisioningProfilesOperation.swift b/AltStore/Operations/FetchProvisioningProfilesOperation.swift index 2a342dd3..d4f9bd8e 100644 --- a/AltStore/Operations/FetchProvisioningProfilesOperation.swift +++ b/AltStore/Operations/FetchProvisioningProfilesOperation.swift @@ -320,8 +320,14 @@ extension FetchProvisioningProfilesOperation if let applicationGroups = entitlements[.appGroups] as? [String], !applicationGroups.isEmpty { + // App uses app groups, so assign `true` to enable the feature. features[.appGroups] = true } + else + { + // App has no app groups, so assign `false` to disable the feature. + features[.appGroups] = false + } var updateFeatures = false @@ -333,6 +339,11 @@ extension FetchProvisioningProfilesOperation // AppID already has this feature enabled and the values are the same. continue } + else if appID.features[feature] == nil, let shouldEnableFeature = value as? Bool, !shouldEnableFeature + { + // AppID doesn't already have this feature enabled, but we want it disabled anyway. + continue + } else { // AppID either doesn't have this feature enabled or the value has changed,