I has signed my binary with "platform-application" entitlement, but it still can't load untrusted lib.
The log says:
Library Validation failed: Rejecting '/usr/lib/libTest.dylib' (Team ID: none, platform: no) for process 'test11(12099)' (Team ID: none, platform: no), reason: mapped file has no Team ID and is not a platform binary (signed with custom identity or adhoc?)
and console says:
dyld: Library not loaded: /usr/lib/libTest.dylib
Referenced from: /usr/bin/test11
Reason: no suitable image found. Did find:
/usr/lib/libTest.dylib: code signing blocked mmap() of '/usr/lib/libTest.dylib'
/usr/lib/libTest.dylib: code signing blocked mmap() of '/usr/lib/libTest.dylib'
After reading docs, i removed the -lTest from LDFLAGS, and do dlopen after jb_oneshot_entitle_now(getpid(), FLAG_PLATFORMIZE);, it works.
But it is inconvenient to change lib linking to dlopen, because i have to dlsym those symbols that i use. Even worse, if i want to use CocoaLumberjack.framework, i have to dlopen it manually, and modify the DDLogInfo macro from [DDLog xxxx] to [NSClassFromString(@"DDLog") xxx] to make linker happy.
After some try, i made a loader that posix_spawn target binary with POSIX_SPAWN_START_SUSPENDED, and then jb_oneshot_entitle_now using the pid, it works fine.
I also found that the binary can run normally after first loader called. May be there is some kind of cache, but it won't maintain for too long, after some period of time, it failed to run again.
I has signed my binary with "platform-application" entitlement, but it still can't load untrusted lib. The log says:
and console says:
After reading docs, i removed the
-lTest
fromLDFLAGS
, and dodlopen
afterjb_oneshot_entitle_now(getpid(), FLAG_PLATFORMIZE);
, it works.But it is inconvenient to change lib linking to dlopen, because i have to dlsym those symbols that i use. Even worse, if i want to use CocoaLumberjack.framework, i have to dlopen it manually, and modify the
DDLogInfo
macro from[DDLog xxxx]
to[NSClassFromString(@"DDLog") xxx]
to make linker happy.After some try, i made a loader that
posix_spawn
target binary withPOSIX_SPAWN_START_SUSPENDED
, and thenjb_oneshot_entitle_now
using the pid, it works fine.I also found that the binary can run normally after first loader called. May be there is some kind of cache, but it won't maintain for too long, after some period of time, it failed to run again.
Is there any solution for this?