【问题标题】:Sandboxed app with Helper app带有 Helper 应用程序的沙盒应用程序
【发布时间】:2015-10-06 21:37:19
【问题描述】:

我正在尝试从沙盒应用程序执行帮助应用程序,但它抛出错误 errAuthorizationDenied (-60005),我使用 Apple SMJobBless 作为示例。目前我有这个

var authItem: AuthorizationItem = AuthorizationItem(name: kAuthorizationRightExecute, valueLength: 0, value: nil, flags: 0)
var authRights: AuthorizationRights = AuthorizationRights(count: 1, items: &authItem)
let authFlags: AuthorizationFlags = AuthorizationFlags.ExtendRights
var result = false
var authRef: AuthorizationRef = nil

let status: OSStatus = AuthorizationCreate(&authRights, nil, authFlags, &authRef)
if status == errAuthorizationSuccess {
    result = SMJobBless(kSMDomainSystemLaunchd, "**helperBundleIdentifier**", authRef, nil)
}

是我做错了什么,还是在沙盒中不可能?

【问题讨论】:

  • 你的助手也被沙盒化了吗?当沙盒不存在时,该示例代码来自 10.6

标签: macos swift sandbox smjobbless


【解决方案1】:

来自沙盒guide

以下应用行为与应用沙盒不兼容:

授权服务的使用

【讨论】:

    【解决方案2】:

    即使您没有被沙盒化,您编写的代码也会失败,因为 kAuthorizationRightExecute 是请求授权的错误权利。您需要申请kSMRightBlessPrivilegedHelper

    【讨论】:

    • 这是正确答案。 kAuthorizationRightExecute 不用于安装帮助工具。
    猜你喜欢
    • 2015-01-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多