小编AvD*_*AvD的帖子

SMJobBless更新后无法访问钥匙串项目

我们在使用SMJobBless更新帮助工具时遇到了问题,这个工具一直困扰着我们好几天.

我们正在开发一个应用程序,在某些时候我们需要执行管理任务(加载/卸载kext).我们还使用钥匙串存储我们的应用程序的帐户信息.

对于管理任务,我们使用一个使用SMJobBless安装的辅助工具,我们使用DO over Mach端口(使用NSConnection)与之交流.

在帮助工具中:

// use our bundle id as our service name
NSString* name = [[NSBundle mainBundle] bundleIdentifier];

launch_data_t checkinRequest = launch_data_new_string(LAUNCH_KEY_CHECKIN);
launch_data_t checkinResponse = launch_msg(checkinRequest);
launch_data_t machServicesDict = launch_data_dict_lookup(checkinResponse, LAUNCH_JOBKEY_MACHSERVICES);
launch_data_t machPort = launch_data_dict_lookup(machServicesDict, [name UTF8String]);

mach_port_t mp = launch_data_get_machport(machPort);

launch_data_free(checkinResponse);
launch_data_free(checkinRequest);

NSMachPort *receivePort = [[NSMachPort alloc] initWithMachPort:mp];
NSConnection *server = [NSConnection connectionWithReceivePort:receivePort sendPort:nil];        
Run Code Online (Sandbox Code Playgroud)

在应用程序中:

NSConnection *conn = [NSConnection connectionWithRegisteredName:HELPER_BUNDLE_IDENTIFIER host:nil];

id proxyServerObject = [conn rootProxy];

if(conn && proxyServerObject) {
    return [proxyServerObject someMethod];
} …
Run Code Online (Sandbox Code Playgroud)

macos code-signing objective-c launchd osx-lion

23
推荐指数
1
解决办法
1039
查看次数

标签 统计

code-signing ×1

launchd ×1

macos ×1

objective-c ×1

osx-lion ×1