3

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?

Claw
  • 317
  • 4
  • 13

2 Answers2

6

From Sandboxing guide

The following app behaviors are incompatible with App Sandbox:

Use of Authorization Services

Marek H
  • 5,173
  • 3
  • 31
  • 42
1

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.

Joshua Kaplan
  • 843
  • 5
  • 9