SMJobBless错误 [英] SMJobBless error

查看:3177
本文介绍了SMJobBless错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试通过SMJobBless安装帮助工具,并得到以下错误



错误域= CFErrorDomainLaunchd Code = 8操作不能完成。(CFErrorDomainLaunchd错误8)



我验证了代码符号,plist应用程序和帮助工具,在launchServices中复制工具并链接plists。 >

任何人都可以帮助我吗?



谢谢,

解决方案

验证以下内容:



1.Code

   - (BOOL)blessHelperWithLabel:(NSString *)label 
错误:(NSError **)错误{

BOOL result = NO;

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

AuthorizationRef authRef = NULL;

/ *获取安装特权助手工具的权限(kSMRightBlessPrivilegedHelper)。 * /
OSStatus status = AuthorizationCreate(& authRights,kAuthorizationEmptyEnvironment,flags,& authRef);
if(status!= errAuthorizationSuccess){
NSLog(@%@,[NSString stringWithFormat:@Failed to create AuthorizationRef。Error code:%d,(int)status]);

} else {
/ *这将完成对应用程序
*验证辅助工具的所有工作,反之亦然。一旦验证通过,嵌入的launchd.plist
*被提取并放置在/ Library / LaunchDaemons中,然后加载。
*可执行文件放在/ Library / PrivilegedHelperTools中。
* /
result = SMJobBless(kSMDomainSystemLaunchd,(CFStringRef)label,authRef,(CFErrorRef *)error);
}
return result;
}

2. info.plist / p>

 帮助包:标识符辅助标识符和证书叶[subject.CN] =开发者ID应用程序:xxxxx(YYXSFDHZ6W)

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

 项目0:标识符主应用程序包和证书叶[subject.CN] =开发者ID应用程序:xxxxxx(YYXSFDHZ6W)

4.在xxxxHelperTool-Launchd.plist.it中归档的MachServices应为

 帮助工具包:YES 


I am trying to install a helper tool via SMJobBless and I am getting the following error,

Error Domain=CFErrorDomainLaunchd Code=8 "The operation couldn’t be completed. (CFErrorDomainLaunchd error 8.)

I verified the code sign, plist of application and helper tool, copied the tool in launchServices and also linked the plists.

Can anyone please help me?

Thank you,

解决方案

Verify Following Things:

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.Tools owned after installation field in info.plist(main app)

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

3.Clients allowed to add and remove tool field in helper info.plist.

item 0 : identifier main app bundle and certificate leaf[subject.CN] = "Developer ID Application: xxxxxx (YYXSFDHZ6W)"

4.Check MachServices filed in xxxxHelperTool-Launchd.plist.it should be

helper tool bundle : YES

这篇关于SMJobBless错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆