macosswiftsandboxsmjobbless

Sandboxed app with Helper app


I'm trying to execute helper app from sandboxed application, but its throwing error errAuthorizationDenied (-60005), I'm using Apple SMJobBless as example. Currently I have this

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)
}

Am I doing something wrong, or it isn't possible in sandbox?


Solution

  • From Sandboxing guide

    The following app behaviors are incompatible with App Sandbox:

    Use of Authorization Services