Search code examples
swiftsudomac-app-storeappstore-sandboxnsapplescript

Is there an App store entitlement for NSAppleScript(source: "do shell script \"sudo" commands?


For example, my app uses the following command with the OS handling a pop up alert to request the admin password to authenticate as root. Is there an entitlement that will allow me run this from within the sandbox ?

    @IBAction func clearFonts(sender: NSButton) {

    NSAppleScript(source: "do shell script \"sudo atsutil databases -remove;sudo atsutil server -shutdown\" with administrator " +
        "privileges")!.executeAndReturnError(nil)

}

Solution

  • you can't do that if the app is sandboxed, arbitrary script execution is forbidden by the sandbox. No sudo allowed.