1

I am using a solution from @CarlosP in my objective C app to execute a script as administrator.

Link is above but basically it's doing this:

NSDictionary *errorInfo = [NSDictionary new];
NSString *script =  [NSString stringWithFormat:@"do shell script \"%@\" with administrator privileges", fullScript];

NSAppleScript *appleScript = [[NSAppleScript new] initWithSource:script];
NSAppleEventDescriptor * eventResult = [appleScript executeAndReturnError:&errorInfo];

It works great, but it doesn't enable/allow Touch ID. Is there a way for me to do that within the scope of NSAppleScript?

spartygw
  • 3,289
  • 2
  • 27
  • 51
  • There's no reference in the script to TouchID. A script can't perform operations that it isn't told to. All this script is doing is instantiating an `NSAppleScript` process in which it uses an AppleScript command to then instantiate a shell process to run the contents of whatever `fullScript` is meant to be. Did you forget to include the `fullScript` ? The use of AppleScript here seems unnecessary. If you're running a shell script, you can use `NSTask`. – CJK Aug 27 '21 at 07:30
  • `with administrator privileges` invokes a popup asking for admin password. What I'm curious about is how to enable touch ID in that popup. Yes, `fullScript` is just a shell script I've got that needs admin. The contents of the shell script I felt are irrelevent. – spartygw Aug 27 '21 at 16:45

1 Answers1

0

You can enable Touch ID authorization for sudo. Check details here and here.

Add auth sufficient pam_tid.so to /etc/pam.d/sudo file. In you Applescript remove with administrator privileges and use sudo in your shell script.

Sers
  • 12,047
  • 2
  • 12
  • 31
  • 1
    Hmm. That might work but I guess I wasn't explicit enough in my question. I want to enable touch ID for software I'm handing to clients, not just my own machine. – spartygw May 02 '22 at 15:32
  • Yes, you're write. The solution will not work for the software. – Sers May 02 '22 at 16:51