Skip to content

Commit 38661b3

Browse files
committed
fix(macOS): Relocated socket files into sandboxed containers.
Content of sandboxed apps must not be created on the root level of a container but lower in the hierarchy of it. Signed-off-by: Iva Horn <[email protected]>
1 parent 39dfefd commit 38661b3

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

shell_integration/MacOSX/NextcloudIntegration/FinderSyncExt/FinderSync.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ - (instancetype)init
5757
// https://developer.apple.com/library/mac/documentation/Security/Conceptual/AppSandboxDesignGuide/AppSandboxInDepth/AppSandboxInDepth.html#//apple_ref/doc/uid/TP40011183-CH3-SW24
5858

5959
NSURL *container = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:socketApiPrefix];
60-
NSURL *socketPath = [container URLByAppendingPathComponent:@".socket" isDirectory:NO];
60+
NSURL *library = [container URLByAppendingPathComponent:@"Library" isDirectory:true];
61+
NSURL *applicationSupport = [library URLByAppendingPathComponent:@"Application Support" isDirectory:true];
62+
NSURL *socketPath = [applicationSupport URLByAppendingPathComponent:@".socket" isDirectory:NO];
6163

6264
NSLog(@"Socket path: %@", socketPath.path);
6365

src/gui/macOS/fileprovidersocketserver_mac.mm

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,13 @@
1616

1717
QString fileProviderSocketPath()
1818
{
19-
// This must match the code signing Team setting of the extension
20-
// Example for developer builds (with ad-hoc signing identity): "" "com.owncloud.desktopclient" ".fileprovidersocket"
21-
// Example for official signed packages: "9B5WD74GWJ." "com.owncloud.desktopclient" ".fileprovidersocket"
22-
NSString *appGroupId = @SOCKETAPI_TEAM_IDENTIFIER_PREFIX APPLICATION_REV_DOMAIN;
23-
19+
NSString *appGroupId = [NSString stringWithFormat:@"group.%@", @APPLICATION_REV_DOMAIN];
2420
NSURL *container = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:appGroupId];
25-
NSURL *socketPath = [container URLByAppendingPathComponent:@".fileprovidersocket" isDirectory:false];
26-
return QString::fromNSString(socketPath.path);
21+
NSURL *library = [container URLByAppendingPathComponent:@"Library" isDirectory:true];
22+
NSURL *applicationSupport = [library URLByAppendingPathComponent:@"Application Support" isDirectory:true];
23+
NSURL *socket = [applicationSupport URLByAppendingPathComponent:@".fileprovidersocket" isDirectory:false];
24+
25+
return QString::fromNSString(socket.path);
2726
}
2827

2928
} // namespace Mac

src/gui/macOS/fileproviderutils_mac.mm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,10 +209,12 @@ QDir fileProviderDomainSupportDirectory(const QString domainIdentifier)
209209
QString groupContainerPath()
210210
{
211211
NSString *const groupId = (NSString *)[NSBundle.mainBundle objectForInfoDictionaryKey:@"NCFPKAppGroupIdentifier"];
212+
212213
if (groupId == nil) {
213214
qCWarning(lcMacFileProviderUtils) << "No app group identifier found in Info.plist, cannot determine group container path.";
214215
return QString();
215216
}
217+
216218
return QString::fromNSString([NSFileManager.defaultManager containerURLForSecurityApplicationGroupIdentifier:groupId].path);
217219
}
218220

src/gui/socketapi/socketapi_mac.mm

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,13 @@
1313

1414
QString socketApiSocketPath()
1515
{
16-
// This must match the code signing Team setting of the extension
17-
// Example for developer builds (with ad-hoc signing identity): "" "com.owncloud.desktopclient" ".socket"
18-
// Example for official signed packages: "9B5WD74GWJ." "com.owncloud.desktopclient" ".socket"
19-
NSString *appGroupId = @SOCKETAPI_TEAM_IDENTIFIER_PREFIX APPLICATION_REV_DOMAIN;
20-
16+
NSString *appGroupId = [NSString stringWithFormat:@"group.%@", @APPLICATION_REV_DOMAIN];
2117
NSURL *container = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:appGroupId];
22-
NSURL *socketPath = [container URLByAppendingPathComponent:@".socket" isDirectory:false];
23-
return QString::fromNSString(socketPath.path);
18+
NSURL *library = [container URLByAppendingPathComponent:@"Library" isDirectory:true];
19+
NSURL *applicationSupport = [library URLByAppendingPathComponent:@"Application Support" isDirectory:true];
20+
NSURL *socket = [applicationSupport URLByAppendingPathComponent:@".socket" isDirectory:false];
21+
22+
return QString::fromNSString(socket.path);
2423
}
2524

2625
}

0 commit comments

Comments
 (0)