Coder Social home page Coder Social logo

Comments (10)

jorangreef avatar jorangreef commented on July 22, 2024

Thanks @jviotti I will look into it. Any ideas from your side?

from sudo-prompt.

jviotti avatar jviotti commented on July 22, 2024

I have very little macOS programming knowledge, and my MacBook Pro doesn't have Touch ID, but I'll see if I can find something :)

from sudo-prompt.

ryankon avatar ryankon commented on July 22, 2024

I've been using Etcher a lot, so I tried to take a closer look at this, and I had a quick question. If I execute the AppleScript directly or if I do the following, I get the Touch ID prompt.

osascript -e 'do shell script "echo foo" with administrator privileges'

Perhaps it has something to do with the applet binary? What is it actually doing?

Thanks!

from sudo-prompt.

jorangreef avatar jorangreef commented on July 22, 2024

Thanks @ryankon

The applet is just an AppleScript packaged as an app by Xcode.

We moved away from copying the osascript binary since this applet technique lets us set the prompt's icon by changing the applet's icon dynamically.

You can inspect the applet in Xcode: decode the applet base64, unzip, then open Contents/Resources/Scripts in Xcode, which looks like this:

do shell script "./sudo-prompt-script" with administrator privileges

MacOS/sudo-prompt-script then looks like this:

#!/bin/bash
# Set sudo timestamp for subsequent sudo calls if tty_tickets are disabled:
/bin/mkdir -p /var/db/sudo/$USER > /dev/null 2>&1
/usr/bin/touch /var/db/sudo/$USER > /dev/null 2>&1
# AppleScript's "do shell script" may alter stdout line-endings.
# It may also set stdout to stderr if there was a non-zero return code and no stderr.
# We therefore prefer to redirect output streams and capture return code manually:
/bin/bash sudo-prompt-command 1>stdout 2>stderr
/bin/echo $? > code
# Correct ownership of stdout, stderr and code so that user can delete them:
/usr/sbin/chown $USER stdout stderr code
# Always return 0 so that AppleScript does not show error dialog:
exit 0

sudo-prompt-command is written out dynamically.

This might be a red herring but I think I recall that with administrator privileges works slightly differently when executing a native shell command vs executing a compound shell script but I'm not sure if this is accurate.

Perhaps osascript is wired up to show the Touch ID prompt when it sees with administrator privileges but Xcode AppleScript applets are not? Perhaps the applet just needs to be rebuilt on a newer macOS? Could you look into this on your Mac?

from sudo-prompt.

jorangreef avatar jorangreef commented on July 22, 2024
Perhaps the applet just needs to be rebuilt on a newer macOS? Could you look into this on your Mac?

This might just do the trick.

from sudo-prompt.

ryankon avatar ryankon commented on July 22, 2024

Thanks for the detailed response @jorangreef

Unfortunately, I attempted to rebuild the AppleScript app using the latest Xcode (9.2) on MacOS 10.3.3, and it still prompts for a password instead of using Touch ID.

If we want to preserve the prompt customizability, we may have to use the Local Authentication framework instead. I can try to carve out some time in the coming weeks to take a closer look. Thoughts?

from sudo-prompt.

jorangreef avatar jorangreef commented on July 22, 2024

Sure, thanks @ryankon for trying the rebuild.

It would be great to look into using the Local Authentication framework, especially if we can interact with it from C/C++ with a minimum of anything else. I have tried to keep sudo-prompt free from being a native add-on for convenience. Please let me know what ideas you have or what might work.

from sudo-prompt.

jorangreef avatar jorangreef commented on July 22, 2024

@ryankon , would you like to try rebuild the AppleScript app again to see if Xcode now prompts with Touch ID?

from sudo-prompt.

jorangreef avatar jorangreef commented on July 22, 2024

Closing for now, let me know if anything changes with this please.

from sudo-prompt.

Fndroid avatar Fndroid commented on July 22, 2024

any update for this issue?

from sudo-prompt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.