-
-
Notifications
You must be signed in to change notification settings - Fork 105
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Handle installs that require password #5
Comments
This is an issue that I couldn't solve yet. We can't just call the brew commands with sudo because it will give this error for a good reason:
So we would have to inject the password safely into the running shell somehow. |
What do you mean by "this"? Calling brew with sudo? |
No, when I press install in Applite, it automatically ask me to enter my credentials when I install an app, e.g. Edge that requires sudo. |
I think this one works because you bound your sudo to fido/keychain/passkeys. |
Hmm... I don't really understand this then. Can you explain this further: "bound your sudo to fido/keychain/passkeys"? I don't know that much about this. |
@tmikaeld are you referring to this:
I added the |
Just checked it. Indeed, it is this line I added |
I just checked it too, I changed it and it works. |
@milanvarady I guess you need to write a Privileged Helper Extension. |
PINEntry is a passphrase entry dialog from GPGTools which utilizes the Assuan protocol. So if you add a dependency on
where
Your call-pinentry script will return the entered text (password). This is just an example. For instance, SETOK, SETCANCEL and SETDESC could all be omitted. Hope this helps. It might be a challenge to provide localized text in the dialog box that pinentry-mac displays[2], but it should be secure. [1] https://github.com/Homebrew/brew/blob/3c8b4949baefb1f8166749ff1a3f0665afadedda/docs/Manpage.md?plain=1#L2369-L2370 |
Note that /private/etc/pam.d/sudo will be overwritten when macOS receives an update, and it will be necessary to re-edit /private/etc/pam.d/sudo after each such macOS update. Something like this might work.
And if you are on the CLI and use [1] https://github.com/fabianishere/pam_reattach |
@toobuntu thanks for your detailed answers, now I understand things better. I have a question. Does using
Alternatively, I've been looking for a way to prompt the user with the default password prompt that also allows Touch ID, but couldn't find a solution. Do you know of a method that would allow this? |
Yes, a simple AppleScript dialog will work. But, even Apple admits it is not an ideal solution for obtaining passwords[1]:
By the way, the AppleScript can be simplified to[2]:
Using pam_tid.so is a nicety when invoking sudo in the terminal and I know which commands sudo wants to run. But it does have limitations. The prompt indicates only that sudo is trying to execute a command as administrator, and nothing about the command which sudo is trying to run[3]. There are also people who refuse to enable Touch ID, though pam_tid.so at least falls back to asking the user to input a password in this case. Another consideration is NIST recommendations to allow unmasking (bottom of page 14). AppleScript does not. PINEntry does. Enter pinentry[4]:
In browsing the source[5], it seems to try to minimize the chance that the passphrase is saved in memory and that memory is exposed to an attacker by initializing the secure memory subsystem and dropping privileges. Debian has manpages for the various pinentries, which sum it up (I have replaced the toolkit with an asterisk because the remainder of the paragraph is identical regardless of whether it is pinentry-tty or pinentry-gnome3, etc.):
Similar to pinentry from GnuPG, ssh-askpass is an X11-based passphrase dialog for use with OpenSSH. But it is not relevant in macOS since Apple deprecated the askpass UI and provided an option to integrate ssh passphrases into the Keychain. However, the brew cask for an unofficial (that is, not provided by OpenSSH and available only in a private tap instead of in homebrew/cask) macOS variant of ssh-askpass is just an AppleScript dialog. There is also ssh-askpass-mac written in Swift, which stores the passphrase in the macOS Keychain. And so it is really better suited for ssh which has many passphrases instead of sudo which requires the login passphrase. It also has this security caveat:
I do not. The problem here is that I would be remiss if I failed to mention sudo-touchid for the concept. It hasn't been updated in seven years. It is a fork of sudo which has Touch ID built in. You could theoretically do the same, with a current sudo, and tell brew to use that instead of the system sudo. But brew hardcodes the path to sudo so that wouldn't work anyway. It seems heavy-handed to forcibly edit /private/etc/pam.d/sudo to add Touch ID, and maintain that configuration, especially if the user doesn't even want Touch ID enabled or wasn't asked. It occurred to me that, on every [1] https://developer.apple.com/library/archive/documentation/LanguagesUtilities/Conceptual/MacAutomationScriptingGuide/PromptforText.html#//apple_ref/doc/uid/TP40016239-CH80-SW1 |
It came to my attention that Homebrew has multiple packages that provide pinentry-mac: The most popular seems to be the formula |
Thanks to the help of @toobuntu, I finally implemented this feature. The solution was to use the pinentry-mac package and pass it to brew with the The app installs pinentry during the setup, and also checks every time the app is opened or a .pkg app is downloaded, and fixes the installation if needed. Pinentry is called from a script called See changes in this commit: ba98754. This feature will be released in the next update soon. |
The feature is now live in the v1.2 update. |
For example, when installing microsoft-edge cask
The text was updated successfully, but these errors were encountered: