SMJobBless给出错误CFErrorDomainLaunchd Code = 8 [英] SMJobBless gives error CFErrorDomainLaunchd Code=8
问题描述
我正在尝试通过SMJobBless安装帮助程序工具,并且出现以下错误,
I am trying to install a helper tool via SMJobBless and I am getting the following error,
Error Domain = CFErrorDomainLaunchd代码= 8该操作无法完成.(CFErrorDomainLaunchd错误8.)
Error Domain=CFErrorDomainLaunchd Code=8 "The operation couldn’t be completed. (CFErrorDomainLaunchd error 8.)
我验证了代码符号,应用程序和帮助程序工具的清单,在launchServices中复制了该工具,并链接了plists.
I verified the code sign, plist of application and helper tool, copied the tool in launchServices and also linked the plists.
有人可以帮助我吗?
谢谢
推荐答案
验证以下内容:
1.Code
- (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(主应用程序)中安装后拥有的工具
2.Tools owned after installation field in info.plist(main app)
helper bundle : identifier <Helper Bundle Identifier> and certificate leaf[subject.CN] = "Developer ID Application: xxxxx (YYXSFDHZ6W)"
3.允许客户端添加和删除帮助程序info.plist中的工具字段.
3.Clients allowed to add and remove tool field in helper info.plist.
item 0 : identifier <Main App Bundle Identifier> and certificate leaf[subject.CN] = "Developer ID Application: xxxxxx (YYXSFDHZ6W)"
4.检查xxxxHelperTool-Launchd.plist中归档的MachServices.
4.Check MachServices filed in xxxxHelperTool-Launchd.plist.it should be
helper tool bundle : YES
这篇关于SMJobBless给出错误CFErrorDomainLaunchd Code = 8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!