[Sandbox] Add Sandbox grants to places missing it

The subdirectory parser, the CUEsheet reader, and the legacy XML
playlist reader were missing grants for Sandbox access.

Signed-off-by: Christopher Snowhill <kode54@gmail.com>
main
Christopher Snowhill 2022-07-25 19:33:51 -07:00
parent 9752cb725e
commit 59ac5769ad
4 changed files with 16 additions and 0 deletions

View File

@ -245,7 +245,9 @@ NSMutableDictionary *dictionaryWithPropertiesOfObject(id obj, NSArray *filterLis
NSMutableArray *urls = [NSMutableArray array]; NSMutableArray *urls = [NSMutableArray array];
const void *sbHandle = [[SandboxBroker sharedSandboxBroker] beginFolderAccess:[NSURL fileURLWithPath:path]];
NSArray *subpaths = [manager subpathsAtPath:path]; NSArray *subpaths = [manager subpathsAtPath:path];
[[SandboxBroker sharedSandboxBroker] endFolderAccess:sbHandle];
for(NSString *subpath in subpaths) { for(NSString *subpath in subpaths) {
NSString *absoluteSubpath = [NSString pathWithComponents:@[path, subpath]]; NSString *absoluteSubpath = [NSString pathWithComponents:@[path, subpath]];

View File

@ -10,6 +10,8 @@
#import "Logging.h" #import "Logging.h"
#import "SandboxBroker.h"
@implementation XmlContainer @implementation XmlContainer
+ (NSURL *)urlForPath:(NSString *)path relativeTo:(NSString *)baseFilename { + (NSURL *)urlForPath:(NSString *)path relativeTo:(NSString *)baseFilename {
@ -58,9 +60,14 @@
NSString *filename = [url path]; NSString *filename = [url path];
const void *sbHandle = [[SandboxBroker sharedSandboxBroker] beginFolderAccess:url];
NSString *contents = [NSString stringWithContentsOfFile:filename NSString *contents = [NSString stringWithContentsOfFile:filename
encoding:NSUTF8StringEncoding encoding:NSUTF8StringEncoding
error:&error]; error:&error];
[[SandboxBroker sharedSandboxBroker] endFolderAccess:sbHandle];
if(!contents) { if(!contents) {
ALog(@"Error: %@", error); ALog(@"Error: %@", error);
return nil; return nil;

View File

@ -13,6 +13,8 @@
#import "Logging.h" #import "Logging.h"
#import "SandboxBroker.h"
@implementation CueSheet @implementation CueSheet
+ (id)cueSheetWithFile:(NSString *)filename { + (id)cueSheetWithFile:(NSString *)filename {
@ -63,6 +65,8 @@
- (void)parseFile:(NSString *)filename { - (void)parseFile:(NSString *)filename {
NSStringEncoding encoding; NSStringEncoding encoding;
NSError *error = nil; NSError *error = nil;
id sandboxBrokerClass = NSClassFromString(@"SandboxBroker");
const void *sbHandle = [[sandboxBrokerClass sharedSandboxBroker] beginFolderAccess:[NSURL fileURLWithPath:filename]];
NSString *contents = [NSString stringWithContentsOfFile:filename usedEncoding:&encoding error:&error]; NSString *contents = [NSString stringWithContentsOfFile:filename usedEncoding:&encoding error:&error];
if(error) { if(error) {
error = nil; error = nil;
@ -80,6 +84,7 @@
error = nil; error = nil;
contents = [NSString stringWithContentsOfFile:filename encoding:NSISOLatin1StringEncoding error:&error]; contents = [NSString stringWithContentsOfFile:filename encoding:NSISOLatin1StringEncoding error:&error];
} }
[[sandboxBrokerClass sharedSandboxBroker] endFolderAccess:sbHandle];
if(error || !contents) { if(error || !contents) {
ALog(@"Could not open file...%@ %@ %@", filename, contents, error); ALog(@"Could not open file...%@ %@ %@", filename, contents, error);
return; return;

View File

@ -23,6 +23,7 @@
17DA346C0CC04FCD0003F6B2 /* CueSheetMetadataReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CueSheetMetadataReader.h; sourceTree = "<group>"; }; 17DA346C0CC04FCD0003F6B2 /* CueSheetMetadataReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CueSheetMetadataReader.h; sourceTree = "<group>"; };
17DA346D0CC04FCD0003F6B2 /* CueSheetMetadataReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CueSheetMetadataReader.m; sourceTree = "<group>"; }; 17DA346D0CC04FCD0003F6B2 /* CueSheetMetadataReader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CueSheetMetadataReader.m; sourceTree = "<group>"; };
32DBCF630370AF2F00C91783 /* CueSheet_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CueSheet_Prefix.pch; sourceTree = "<group>"; }; 32DBCF630370AF2F00C91783 /* CueSheet_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CueSheet_Prefix.pch; sourceTree = "<group>"; };
832EE93A288F888600B03467 /* SandboxBroker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SandboxBroker.h; path = ../../Utils/SandboxBroker.h; sourceTree = "<group>"; };
833F68371CDBCAB200AFB9F0 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/InfoPlist.strings; sourceTree = "<group>"; }; 833F68371CDBCAB200AFB9F0 /* es */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = es; path = es.lproj/InfoPlist.strings; sourceTree = "<group>"; };
834A42B2287AF59900EB9D9B /* AudioChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AudioChunk.h; path = ../../Audio/Chain/AudioChunk.h; sourceTree = "<group>"; }; 834A42B2287AF59900EB9D9B /* AudioChunk.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AudioChunk.h; path = ../../Audio/Chain/AudioChunk.h; sourceTree = "<group>"; };
835C888E22CC1883001B4B3F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; }; 835C888E22CC1883001B4B3F /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
@ -91,6 +92,7 @@
08FB77AFFE84173DC02AAC07 /* Classes */ = { 08FB77AFFE84173DC02AAC07 /* Classes */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
832EE93A288F888600B03467 /* SandboxBroker.h */,
834A42B2287AF59900EB9D9B /* AudioChunk.h */, 834A42B2287AF59900EB9D9B /* AudioChunk.h */,
839DA7D3274A2FD4001B18E5 /* NSDictionary+Merge.h */, 839DA7D3274A2FD4001B18E5 /* NSDictionary+Merge.h */,
839DA7D0274A2EA9001B18E5 /* AudioMetadataReader.h */, 839DA7D0274A2EA9001B18E5 /* AudioMetadataReader.h */,