Search code examples
javalaunchadministratormacos-catalina

OSX Catalina broke osascript launch with administrator priviledges


All known prior macOS versions were working with this sort of script context:

osascript -e "/path/to/my/app.command" with administrator privileges

Now it just silently fails...after asking for admin password. The command file is what was originally used to launch the app, and the app has a button to re-launch with privileges...and the prior non privileged app closes.

If I remove the "with administrator privileges", it re-launches. if that is there, it does not.

If I try using:

/usr/bin/security execute-with-privileges /path/to/my/app.command

It also fails...never even shows password prompt.

I tried also "sudo open /Applications/myApp.app" but that of course doesn't actually launch with privileges.

From a shell i can sudo launch my app, and that is fine, but I can't expect an average user to be able to do sudo in a shell.

As I said, this had been a nice method that has worked for probably the past 6 to 8 years...but now fails. Anyone have any tricks or ways to get around it?

At one time....and I have no idea why, I saw the OSX security popup indicating "java" is not a trusted app and my settings only allow app store apps. But that only happened once...and it was strange. I clicked OK, it disappeared. I thought maybe java had been quarantined, so I did the command to clear that flag:

xattr -rd com.apple.quarantine /path/to/the/binary/java

But that made no difference. I'm sure this is new security features in Catalina making things difficult...but I can't figure out why or how to work through them. Its a java app that is launched via the app.command file which finds java on the machine and then launches it...defaulting to finding a local copy in its own subfolder.


Solution

  • Checkout out the sandbox settings of your project. the App Sandbox should be set as false in the entitlements file. The sandboxing feature prevents your app from elevating the privilege in your app. reference: https://developer.apple.com/app-sandboxing/