mirror of https://github.com/opa334/TrollStore.git
Sync uicache with upstream
This commit is contained in:
parent
1699abd9ab
commit
accf995dfc
|
@ -11,33 +11,27 @@
|
||||||
extern NSSet<NSString*>* immutableAppBundleIdentifiers(void);
|
extern NSSet<NSString*>* immutableAppBundleIdentifiers(void);
|
||||||
extern NSDictionary* dumpEntitlementsFromBinaryAtPath(NSString* binaryPath);
|
extern NSDictionary* dumpEntitlementsFromBinaryAtPath(NSString* binaryPath);
|
||||||
|
|
||||||
NSDictionary* constructGroupsContainersForEntitlements(NSDictionary* entitlements, BOOL systemGroups)
|
NSDictionary *constructGroupsContainersForEntitlements(NSDictionary *entitlements, BOOL systemGroups) {
|
||||||
{
|
|
||||||
if (!entitlements) return nil;
|
if (!entitlements) return nil;
|
||||||
|
|
||||||
NSString *entitlementForGroups;
|
NSString *entitlementForGroups;
|
||||||
Class mcmClass;
|
Class mcmClass;
|
||||||
if(systemGroups)
|
if (systemGroups) {
|
||||||
{
|
|
||||||
entitlementForGroups = @"com.apple.security.system-groups";
|
entitlementForGroups = @"com.apple.security.system-groups";
|
||||||
mcmClass = [MCMSystemDataContainer class];
|
mcmClass = [MCMSystemDataContainer class];
|
||||||
}
|
}
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
entitlementForGroups = @"com.apple.security.application-groups";
|
entitlementForGroups = @"com.apple.security.application-groups";
|
||||||
mcmClass = [MCMSharedDataContainer class];
|
mcmClass = [MCMSharedDataContainer class];
|
||||||
}
|
}
|
||||||
|
|
||||||
NSArray *groupIDs = entitlements[entitlementForGroups];
|
NSArray *groupIDs = entitlements[entitlementForGroups];
|
||||||
if(groupIDs && [groupIDs isKindOfClass:[NSArray class]])
|
if (groupIDs && [groupIDs isKindOfClass:[NSArray class]]) {
|
||||||
{
|
|
||||||
NSMutableDictionary *groupContainers = [NSMutableDictionary new];
|
NSMutableDictionary *groupContainers = [NSMutableDictionary new];
|
||||||
|
|
||||||
for(NSString* groupID in groupIDs)
|
for (NSString *groupID in groupIDs) {
|
||||||
{
|
|
||||||
MCMContainer *container = [mcmClass containerWithIdentifier:groupID createIfNecessary:YES existed:nil error:nil];
|
MCMContainer *container = [mcmClass containerWithIdentifier:groupID createIfNecessary:YES existed:nil error:nil];
|
||||||
if(container.url)
|
if (container.url) {
|
||||||
{
|
|
||||||
groupContainers[groupID] = container.url.path;
|
groupContainers[groupID] = container.url.path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -48,22 +42,17 @@ NSDictionary* constructGroupsContainersForEntitlements(NSDictionary* entitlement
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL constructContainerizationForEntitlements(NSDictionary* entitlements)
|
BOOL constructContainerizationForEntitlements(NSDictionary *entitlements) {
|
||||||
{
|
|
||||||
NSNumber *noContainer = entitlements[@"com.apple.private.security.no-container"];
|
NSNumber *noContainer = entitlements[@"com.apple.private.security.no-container"];
|
||||||
if(noContainer && [noContainer isKindOfClass:[NSNumber class]])
|
if (noContainer && [noContainer isKindOfClass:[NSNumber class]]) {
|
||||||
{
|
if (noContainer.boolValue) {
|
||||||
if(noContainer.boolValue)
|
|
||||||
{
|
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NSNumber *containerRequired = entitlements[@"com.apple.private.security.container-required"];
|
NSNumber *containerRequired = entitlements[@"com.apple.private.security.container-required"];
|
||||||
if(containerRequired && [containerRequired isKindOfClass:[NSNumber class]])
|
if (containerRequired && [containerRequired isKindOfClass:[NSNumber class]]) {
|
||||||
{
|
if (!containerRequired.boolValue) {
|
||||||
if(!containerRequired.boolValue)
|
|
||||||
{
|
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,77 +60,75 @@ BOOL constructContainerizationForEntitlements(NSDictionary* entitlements)
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSString* constructTeamIdentifierForEntitlements(NSDictionary* entitlements)
|
NSString *constructTeamIdentifierForEntitlements(NSDictionary *entitlements) {
|
||||||
{
|
|
||||||
NSString *teamIdentifier = entitlements[@"com.apple.developer.team-identifier"];
|
NSString *teamIdentifier = entitlements[@"com.apple.developer.team-identifier"];
|
||||||
if(teamIdentifier && [teamIdentifier isKindOfClass:[NSString class]])
|
if (teamIdentifier && [teamIdentifier isKindOfClass:[NSString class]]) {
|
||||||
{
|
|
||||||
return teamIdentifier;
|
return teamIdentifier;
|
||||||
}
|
}
|
||||||
return nil;
|
return nil;
|
||||||
}
|
}
|
||||||
|
|
||||||
NSDictionary* constructEnvironmentVariablesForContainerPath(NSString* containerPath)
|
NSDictionary *constructEnvironmentVariablesForContainerPath(NSString *containerPath, BOOL isContainerized) {
|
||||||
{
|
NSString *homeDir = isContainerized ? containerPath : @"/var/mobile";
|
||||||
NSString* tmpDir = [containerPath stringByAppendingPathComponent:@"tmp"];
|
NSString *tmpDir = isContainerized ? [containerPath stringByAppendingPathComponent:@"tmp"] : @"/var/tmp";
|
||||||
return @{
|
return @{
|
||||||
@"CFFIXED_USER_HOME" : containerPath,
|
@"CFFIXED_USER_HOME" : homeDir,
|
||||||
@"HOME" : containerPath,
|
@"HOME" : homeDir,
|
||||||
@"TMPDIR" : tmpDir
|
@"TMPDIR" : tmpDir
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
void registerPath(NSString* path, BOOL unregister, BOOL system)
|
void registerPath(NSString *path, BOOL unregister, BOOL forceSystem) {
|
||||||
{
|
|
||||||
if (!path) return;
|
if (!path) return;
|
||||||
|
|
||||||
LSApplicationWorkspace *workspace = [LSApplicationWorkspace defaultWorkspace];
|
LSApplicationWorkspace *workspace = [LSApplicationWorkspace defaultWorkspace];
|
||||||
if(unregister && ![[NSFileManager defaultManager] fileExistsAtPath:path])
|
if (unregister && ![[NSFileManager defaultManager] fileExistsAtPath:path]) {
|
||||||
{
|
|
||||||
LSApplicationProxy *app = [LSApplicationProxy applicationProxyForIdentifier:path];
|
LSApplicationProxy *app = [LSApplicationProxy applicationProxyForIdentifier:path];
|
||||||
if(app.bundleURL)
|
if (app.bundleURL) {
|
||||||
{
|
|
||||||
path = [app bundleURL].path;
|
path = [app bundleURL].path;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
path = [path stringByResolvingSymlinksInPath];
|
path = path.stringByResolvingSymlinksInPath.stringByStandardizingPath;
|
||||||
|
|
||||||
NSDictionary *appInfoPlist = [NSDictionary dictionaryWithContentsOfFile:[path stringByAppendingPathComponent:@"Info.plist"]];
|
NSDictionary *appInfoPlist = [NSDictionary dictionaryWithContentsOfFile:[path stringByAppendingPathComponent:@"Info.plist"]];
|
||||||
NSString *appBundleID = [appInfoPlist objectForKey:@"CFBundleIdentifier"];
|
NSString *appBundleID = [appInfoPlist objectForKey:@"CFBundleIdentifier"];
|
||||||
|
|
||||||
if([immutableAppBundleIdentifiers() containsObject:appBundleID.lowercaseString]) return;
|
if([immutableAppBundleIdentifiers() containsObject:appBundleID.lowercaseString]) return;
|
||||||
|
|
||||||
if(appBundleID && !unregister)
|
if (appBundleID && !unregister) {
|
||||||
{
|
|
||||||
MCMContainer *appContainer = [NSClassFromString(@"MCMAppDataContainer") containerWithIdentifier:appBundleID createIfNecessary:YES existed:nil error:nil];
|
MCMContainer *appContainer = [NSClassFromString(@"MCMAppDataContainer") containerWithIdentifier:appBundleID createIfNecessary:YES existed:nil error:nil];
|
||||||
NSString *containerPath = [appContainer url].path;
|
NSString *containerPath = [appContainer url].path;
|
||||||
|
|
||||||
|
BOOL isRemovableSystemApp = [[NSFileManager defaultManager] fileExistsAtPath:[@"/System/Library/AppSignatures" stringByAppendingPathComponent:appBundleID]];
|
||||||
|
BOOL registerAsUser = [path hasPrefix:@"/var/containers"] && !isRemovableSystemApp && !forceSystem;
|
||||||
|
|
||||||
NSMutableDictionary *dictToRegister = [NSMutableDictionary dictionary];
|
NSMutableDictionary *dictToRegister = [NSMutableDictionary dictionary];
|
||||||
|
|
||||||
// Add entitlements
|
// Add entitlements
|
||||||
|
|
||||||
NSString *appExecutablePath = [path stringByAppendingPathComponent:appInfoPlist[@"CFBundleExecutable"]];
|
NSString *appExecutablePath = [path stringByAppendingPathComponent:appInfoPlist[@"CFBundleExecutable"]];
|
||||||
NSDictionary *entitlements = dumpEntitlementsFromBinaryAtPath(appExecutablePath);
|
NSDictionary *entitlements = dumpEntitlementsFromBinaryAtPath(appExecutablePath);
|
||||||
if(entitlements)
|
if (entitlements) {
|
||||||
{
|
|
||||||
dictToRegister[@"Entitlements"] = entitlements;
|
dictToRegister[@"Entitlements"] = entitlements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Misc
|
// Misc
|
||||||
|
|
||||||
dictToRegister[@"ApplicationType"] = system ? @"System" : @"User";
|
dictToRegister[@"ApplicationType"] = registerAsUser ? @"User" : @"System";
|
||||||
dictToRegister[@"CFBundleIdentifier"] = appBundleID;
|
dictToRegister[@"CFBundleIdentifier"] = appBundleID;
|
||||||
dictToRegister[@"CodeInfoIdentifier"] = appBundleID;
|
dictToRegister[@"CodeInfoIdentifier"] = appBundleID;
|
||||||
dictToRegister[@"CompatibilityState"] = @0;
|
dictToRegister[@"CompatibilityState"] = @0;
|
||||||
if(containerPath)
|
BOOL appContainerized = constructContainerizationForEntitlements(entitlements);
|
||||||
{
|
dictToRegister[@"IsContainerized"] = @(appContainerized);
|
||||||
|
if (containerPath) {
|
||||||
dictToRegister[@"Container"] = containerPath;
|
dictToRegister[@"Container"] = containerPath;
|
||||||
dictToRegister[@"EnvironmentVariables"] = constructEnvironmentVariablesForContainerPath(containerPath);
|
dictToRegister[@"EnvironmentVariables"] = constructEnvironmentVariablesForContainerPath(containerPath, appContainerized);
|
||||||
}
|
}
|
||||||
dictToRegister[@"IsDeletable"] = @(![appBundleID isEqualToString:@"com.opa334.TrollStore"] && kCFCoreFoundationVersionNumber >= kCFCoreFoundationVersionNumber_iOS_15_0);
|
dictToRegister[@"IsDeletable"] = @(registerAsUser || isRemovableSystemApp);
|
||||||
dictToRegister[@"Path"] = path;
|
dictToRegister[@"Path"] = path;
|
||||||
dictToRegister[@"IsContainerized"] = @(constructContainerizationForEntitlements(entitlements));
|
|
||||||
dictToRegister[@"SignerOrganization"] = @"Apple Inc.";
|
dictToRegister[@"SignerOrganization"] = @"Apple Inc.";
|
||||||
dictToRegister[@"SignatureVersion"] = @132352;
|
dictToRegister[@"SignatureVersion"] = @132352;
|
||||||
dictToRegister[@"SignerIdentity"] = @"Apple iPhone OS Application Signing";
|
dictToRegister[@"SignerIdentity"] = @"Apple iPhone OS Application Signing";
|
||||||
|
@ -162,14 +149,11 @@ void registerPath(NSString* path, BOOL unregister, BOOL system)
|
||||||
NSMutableDictionary *groupContainers = [NSMutableDictionary new];
|
NSMutableDictionary *groupContainers = [NSMutableDictionary new];
|
||||||
[groupContainers addEntriesFromDictionary:appGroupContainers];
|
[groupContainers addEntriesFromDictionary:appGroupContainers];
|
||||||
[groupContainers addEntriesFromDictionary:systemGroupContainers];
|
[groupContainers addEntriesFromDictionary:systemGroupContainers];
|
||||||
if(groupContainers.count)
|
if (groupContainers.count) {
|
||||||
{
|
if (appGroupContainers.count) {
|
||||||
if(appGroupContainers.count)
|
|
||||||
{
|
|
||||||
dictToRegister[@"HasAppGroupContainers"] = @YES;
|
dictToRegister[@"HasAppGroupContainers"] = @YES;
|
||||||
}
|
}
|
||||||
if(systemGroupContainers.count)
|
if (systemGroupContainers.count) {
|
||||||
{
|
|
||||||
dictToRegister[@"HasSystemGroupContainers"] = @YES;
|
dictToRegister[@"HasSystemGroupContainers"] = @YES;
|
||||||
}
|
}
|
||||||
dictToRegister[@"GroupContainers"] = groupContainers.copy;
|
dictToRegister[@"GroupContainers"] = groupContainers.copy;
|
||||||
|
@ -181,8 +165,7 @@ void registerPath(NSString* path, BOOL unregister, BOOL system)
|
||||||
NSArray *plugins = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:pluginsPath error:nil];
|
NSArray *plugins = [[NSFileManager defaultManager] contentsOfDirectoryAtPath:pluginsPath error:nil];
|
||||||
|
|
||||||
NSMutableDictionary *bundlePlugins = [NSMutableDictionary dictionary];
|
NSMutableDictionary *bundlePlugins = [NSMutableDictionary dictionary];
|
||||||
for (NSString* pluginName in plugins)
|
for (NSString *pluginName in plugins) {
|
||||||
{
|
|
||||||
NSString *pluginPath = [pluginsPath stringByAppendingPathComponent:pluginName];
|
NSString *pluginPath = [pluginsPath stringByAppendingPathComponent:pluginName];
|
||||||
|
|
||||||
NSDictionary *pluginInfoPlist = [NSDictionary dictionaryWithContentsOfFile:[pluginPath stringByAppendingPathComponent:@"Info.plist"]];
|
NSDictionary *pluginInfoPlist = [NSDictionary dictionaryWithContentsOfFile:[pluginPath stringByAppendingPathComponent:@"Info.plist"]];
|
||||||
|
@ -198,8 +181,7 @@ void registerPath(NSString* path, BOOL unregister, BOOL system)
|
||||||
|
|
||||||
NSString *pluginExecutablePath = [pluginPath stringByAppendingPathComponent:pluginInfoPlist[@"CFBundleExecutable"]];
|
NSString *pluginExecutablePath = [pluginPath stringByAppendingPathComponent:pluginInfoPlist[@"CFBundleExecutable"]];
|
||||||
NSDictionary *pluginEntitlements = dumpEntitlementsFromBinaryAtPath(pluginExecutablePath);
|
NSDictionary *pluginEntitlements = dumpEntitlementsFromBinaryAtPath(pluginExecutablePath);
|
||||||
if(pluginEntitlements)
|
if (pluginEntitlements) {
|
||||||
{
|
|
||||||
pluginDict[@"Entitlements"] = pluginEntitlements;
|
pluginDict[@"Entitlements"] = pluginEntitlements;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,14 +191,14 @@ void registerPath(NSString* path, BOOL unregister, BOOL system)
|
||||||
pluginDict[@"CFBundleIdentifier"] = pluginBundleID;
|
pluginDict[@"CFBundleIdentifier"] = pluginBundleID;
|
||||||
pluginDict[@"CodeInfoIdentifier"] = pluginBundleID;
|
pluginDict[@"CodeInfoIdentifier"] = pluginBundleID;
|
||||||
pluginDict[@"CompatibilityState"] = @0;
|
pluginDict[@"CompatibilityState"] = @0;
|
||||||
if(pluginContainerPath)
|
BOOL pluginContainerized = constructContainerizationForEntitlements(pluginEntitlements);
|
||||||
{
|
pluginDict[@"IsContainerized"] = @(pluginContainerized);
|
||||||
|
if (pluginContainerPath) {
|
||||||
pluginDict[@"Container"] = pluginContainerPath;
|
pluginDict[@"Container"] = pluginContainerPath;
|
||||||
pluginDict[@"EnvironmentVariables"] = constructEnvironmentVariablesForContainerPath(pluginContainerPath);
|
pluginDict[@"EnvironmentVariables"] = constructEnvironmentVariablesForContainerPath(pluginContainerPath, pluginContainerized);
|
||||||
}
|
}
|
||||||
pluginDict[@"Path"] = pluginPath;
|
pluginDict[@"Path"] = pluginPath;
|
||||||
pluginDict[@"PluginOwnerBundleID"] = appBundleID;
|
pluginDict[@"PluginOwnerBundleID"] = appBundleID;
|
||||||
pluginDict[@"IsContainerized"] = @(constructContainerizationForEntitlements(pluginEntitlements));
|
|
||||||
pluginDict[@"SignerOrganization"] = @"Apple Inc.";
|
pluginDict[@"SignerOrganization"] = @"Apple Inc.";
|
||||||
pluginDict[@"SignatureVersion"] = @132352;
|
pluginDict[@"SignatureVersion"] = @132352;
|
||||||
pluginDict[@"SignerIdentity"] = @"Apple iPhone OS Application Signing";
|
pluginDict[@"SignerIdentity"] = @"Apple iPhone OS Application Signing";
|
||||||
|
@ -231,14 +213,11 @@ void registerPath(NSString* path, BOOL unregister, BOOL system)
|
||||||
NSMutableDictionary *pluginGroupContainers = [NSMutableDictionary new];
|
NSMutableDictionary *pluginGroupContainers = [NSMutableDictionary new];
|
||||||
[pluginGroupContainers addEntriesFromDictionary:pluginAppGroupContainers];
|
[pluginGroupContainers addEntriesFromDictionary:pluginAppGroupContainers];
|
||||||
[pluginGroupContainers addEntriesFromDictionary:pluginSystemGroupContainers];
|
[pluginGroupContainers addEntriesFromDictionary:pluginSystemGroupContainers];
|
||||||
if(pluginGroupContainers.count)
|
if (pluginGroupContainers.count) {
|
||||||
{
|
if (pluginAppGroupContainers.count) {
|
||||||
if(pluginAppGroupContainers.count)
|
|
||||||
{
|
|
||||||
pluginDict[@"HasAppGroupContainers"] = @YES;
|
pluginDict[@"HasAppGroupContainers"] = @YES;
|
||||||
}
|
}
|
||||||
if(pluginSystemGroupContainers.count)
|
if (pluginSystemGroupContainers.count) {
|
||||||
{
|
|
||||||
pluginDict[@"HasSystemGroupContainers"] = @YES;
|
pluginDict[@"HasSystemGroupContainers"] = @YES;
|
||||||
}
|
}
|
||||||
pluginDict[@"GroupContainers"] = pluginGroupContainers.copy;
|
pluginDict[@"GroupContainers"] = pluginGroupContainers.copy;
|
||||||
|
@ -248,17 +227,13 @@ void registerPath(NSString* path, BOOL unregister, BOOL system)
|
||||||
}
|
}
|
||||||
[dictToRegister setObject:bundlePlugins forKey:@"_LSBundlePlugins"];
|
[dictToRegister setObject:bundlePlugins forKey:@"_LSBundlePlugins"];
|
||||||
|
|
||||||
if(![workspace registerApplicationDictionary:dictToRegister])
|
if (![workspace registerApplicationDictionary:dictToRegister]) {
|
||||||
{
|
NSLog(@"Error: Unable to register %@", path);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
NSURL *url = [NSURL fileURLWithPath:path];
|
||||||
|
if (![workspace unregisterApplication:url]) {
|
||||||
NSLog(@"Error: Unable to register %@", path);
|
NSLog(@"Error: Unable to register %@", path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
NSURL* url = [NSURL fileURLWithPath:path];
|
|
||||||
if(![workspace unregisterApplication:url])
|
|
||||||
{
|
|
||||||
NSLog(@"Error: Unable to unregister %@", path);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue