I have a lua script, running on the Mac, that needs to call sudo.
I’d hoped that Mac OS would automatically bring up a password request dialog, but instead it the command fails by returning 256.
Is there anyway that I can achieve my goal?
Tim
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Quick and easy way: run it like this
Proper and configurable way: use
AuthorizationExecuteWithPrivilegesAPI from Authorization Services (in Security.framework).Both will display standard Mac OS X GUI asking for administrator password and then execute the command as root, the same way as sudo does except that
SUDO_USERenvironment variables will not be set.If you need to execute individual commands from under user account when you’re already elevated to root, you can prepend them with
/usr/bin/sudo -u $USER.