gpt4 book ai didi

macos - SMJobBless 给出错误 CFErrorDomainLaunchd Code=8

转载 作者:行者123 更新时间:2023-12-03 16:25:06 31 4
gpt4 key购买 nike

我尝试通过 SMJobBless 安装辅助工具,但收到以下错误,

Error Domain=CFErrorDomainLaunchd Code=8“操作无法完成。(CFErrorDomainLaunchd 错误 8。)

我验证了代码签名、应用程序的 plist 和辅助工具,将工具复制到 launchServices 中并链接了 plist。

有人可以帮我吗?

谢谢,

最佳答案

验证以下事项:

1.代码

- (BOOL)blessHelperWithLabel:(NSString *)label
error:(NSError **)error {

BOOL result = NO;

AuthorizationItem authItem = { kSMRightBlessPrivilegedHelper, 0, NULL, 0 };
AuthorizationRights authRights = { 1, &authItem };
AuthorizationFlags flags = kAuthorizationFlagDefaults |
kAuthorizationFlagInteractionAllowed |
kAuthorizationFlagPreAuthorize |
kAuthorizationFlagExtendRights;

AuthorizationRef authRef = NULL;

/* Obtain the right to install privileged helper tools (kSMRightBlessPrivilegedHelper). */
OSStatus status = AuthorizationCreate(&authRights, kAuthorizationEmptyEnvironment, flags, &authRef);
if (status != errAuthorizationSuccess) {
NSLog(@"%@", [NSString stringWithFormat:@"Failed to create AuthorizationRef. Error code: %d", (int)status]);

} else {
/* This does all the work of verifying the helper tool against the application
* and vice-versa. Once verification has passed, the embedded launchd.plist
* is extracted and placed in /Library/LaunchDaemons and then loaded. The
* executable is placed in /Library/PrivilegedHelperTools.
*/
result = SMJobBless(kSMDomainSystemLaunchd, (CFStringRef)label, authRef, (CFErrorRef *)error);
}
return result;
}

2.info.plist(主应用)中安装后拥有的工具字段

helper bundle : identifier <Helper Bundle Identifier> and certificate leaf[subject.CN] = "Developer ID Application: xxxxx (YYXSFDHZ6W)"

3.客户端允许在helper info.plist中添加和删除工具字段。

item 0 : identifier <Main App Bundle Identifier> and certificate leaf[subject.CN] = "Developer ID Application: xxxxxx (YYXSFDHZ6W)"

4.检查xxxxHelperTool-Launchd.plist.it中归档的MachServices应该是

helper tool bundle : YES

关于macos - SMJobBless 给出错误 CFErrorDomainLaunchd Code=8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31020919/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com