Sandboxed app with Helper app

761 views Asked by At

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?

2

There are 2 answers

0
Marek H On BEST ANSWER

From Sandboxing guide

The following app behaviors are incompatible with App Sandbox:

Use of Authorization Services

1
Joshua Kaplan On

Even if you weren't sandboxed, the code you wrote will fail because kAuthorizationRightExecute is the wrong right to be requesting authorization for. You need to request for kSMRightBlessPrivilegedHelper.