首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SMJobBless给出错误CFErrorDomainLaunchd Code=8

SMJobBless给出错误CFErrorDomainLaunchd Code=8
EN

Stack Overflow用户
提问于 2015-06-24 15:58:23
回答 4查看 2.4K关注 0票数 2

我正在尝试通过SMJobBless安装一个帮助工具,我得到了以下错误,

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

我验证了代码符号、应用程序的plist和辅助工具,在launchServices中复制了该工具,还链接了plist。

有谁能帮帮我吗?

谢谢,

EN

回答 4

Stack Overflow用户

发布于 2015-06-24 19:03:57

验证以下内容:

1.Code

代码语言:javascript
复制
- (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(主应用)中安装后拥有的工具字段

代码语言:javascript
复制
helper bundle : identifier <Helper Bundle Identifier> and certificate leaf[subject.CN] = "Developer ID Application: xxxxx (YYXSFDHZ6W)"

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

代码语言:javascript
复制
item 0 : identifier <Main App Bundle Identifier> and certificate leaf[subject.CN] = "Developer ID Application: xxxxxx (YYXSFDHZ6W)"

4.检查xxxxHelperTool-Launchd.plist中的MachServices文件。它应该是

代码语言:javascript
复制
helper tool bundle : YES
票数 5
EN

Stack Overflow用户

发布于 2018-08-18 06:26:48

在SMJobBless示例代码(否则将被取代)中找到工具SMJobBlessUtil.py:https://developer.apple.com/library/archive/samplecode/SMJobBless/Introduction/Intro.html

注意: SMJobBless是祝福工作的正确方式。旧方法AuthorizationExecuteWithPrivileges已被弃用,并将在不久的将来被积极避免。不推荐使用"SMJobBless“示例代码,因为下面的示例代码在几乎所有方面都更好。

好的,获取该工具,现在获取当前示例代码:https://developer.apple.com/library/archive/samplecode/EvenBetterAuthorizationSample/Introduction/Intro.html

使用SMJobBlessUtil.py脚本验证和/或设置主程序和帮助器中的Info.plist内容。

票数 1
EN

Stack Overflow用户

发布于 2019-04-24 08:08:16

你可以使用SMJobBlessUtil.py来检查你的应用程序;也许它会出现像dump malformed这样的错误描述;1、

2、然后你可以比较示例代码的项目设置,找到帮助器目标other linker flags,看看你是否应该这样设置。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31020919

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档