So.... if that call isn't available to us mere NSXPCConnection users, what could we do instead? I'm verifyng caller at the
- (BOOL)listener:(NSXPCListener *)listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection;
level, identifying the caller by PID, but every once in a while
NSDictionary *attributes = @{(__bridge NSString *)kSecGuestAttributePid : @(clientPID) }; OSStatus status = SecCodeCopyGuestWithAttributes(NULL, (__bridge CFDictionaryRef)attributes, kSecCSDefaultFlags, &dynamicCode);
crashes my XPC Service, with nice stack somewhere deep in SecCodeCopyGuestWithAttributes:
`
0 libsystem_kernel.dylib 0x183dcd9b8 __pthread_kill + 8
1 libsystem_pthread.dylib 0x183e0115c pthread_kill + 288
2 libsystem_c.dylib 0x183d3e314 abort + 164
3 libsystem_malloc.dylib 0x183c23a1c malloc_vreport + 552
4 libsystem_malloc.dylib 0x183c38c8c malloc_zone_error + 104
5 libsystem_malloc.dylib 0x183c15db0 nanov2_allocate_from_block + 568
6 libsystem_malloc.dylib 0x183c153a4 nanov2_allocate + 128
7 libsystem_malloc.dylib 0x183c152c0 nanov2_malloc + 64
8 libsystem_malloc.dylib 0x183c32770 _malloc_zone_malloc + 156
9 CoreFoundation 0x183e5ab0c resolveAbsoluteURLStringBuffer + 1012
10 CoreFoundation 0x183e5a678 resolveAbsoluteURLString + 188
11 CoreFoundation 0x183e58744 CFURLCopyAbsoluteURL + 568
12 CoreFoundation 0x183f6f750 _CFURLCreateWithFileSystemPath + 2236
13 CoreFoundation 0x183eb874c _CFBundleCopyExecutableURLRaw + 320
14 CoreFoundation 0x183eb84e0 _CFBundleCopyExecutableURLInDirectory2 + 452
15 CoreFoundation 0x183f37ff0 _CFBundleCreateWithExecutableURLIfLooksLikeBundle + 128
16 CoreFoundation 0x183f37f24 _CFBundleCreateWithExecutableURLIfMightBeBundle + 20
17 Security 0x1860d3d18 Security::CodeSigning::KernelCode::identifyGuest(Security::CodeSigning::SecCode*, __CFData const**) + 544
18 Security 0x1860ab040 Security::CodeSigning::SecCode::identify() + 96
19 Security 0x1860ab8c0 Security::CodeSigning::SecCode::autoLocateGuest(__CFDictionary const*, unsigned int) + 188
20 Security 0x1860b2318 SecCodeCopyGuestWithAttributes + 144
21 xpcj 0x11706c3b0 -[OITContentScanningXPCService listener:shouldAcceptNewConnection:] + 556 (OITContentScanningXPCService.m:209)
22 Foundation 0x184e274c8
`
So... how to go about this, and is it better to use the kSecGuestAttributeAudit instead of the kSecGuestAttributePid when calling SecCodeCopyGuestWithAttributes ?