Mikuro
Crotchety UI Nitpicker
What's the best way to go about having an AppleScript acquire and retain administrator priveleges for use in shell scripts? I need to execute many admin-level shell scripts, and I only want the user to need to enter their password once.
Here are the details:
I have an AppleScript that executes certain shell scripts repeatedly (using the "do shell script" command). Some of these shell scripts require admin priveleges. The Do Shell Script command lets me say "with administrator priveleges", but if I do that, then I need to enter my password every time it needs to execute a shell script (which is absolutely unacceptable, since this is a background script which should be completely transparent).
Now, I know I can pass a specific password to the Do Shell Script command. This works, but I don't know how to ask for the user's password to begin with, and in a secure way. If I do display dialog "Enter your administrator password:" default answer "", the user's input won't be asterisk'd out, and I'm also afraid storing the admin password in such a way wouldn't be very secure (am I wrong?).
Any advice on how I should go about this?
Here are the details:
I have an AppleScript that executes certain shell scripts repeatedly (using the "do shell script" command). Some of these shell scripts require admin priveleges. The Do Shell Script command lets me say "with administrator priveleges", but if I do that, then I need to enter my password every time it needs to execute a shell script (which is absolutely unacceptable, since this is a background script which should be completely transparent).
Now, I know I can pass a specific password to the Do Shell Script command. This works, but I don't know how to ask for the user's password to begin with, and in a secure way. If I do display dialog "Enter your administrator password:" default answer "", the user's input won't be asterisk'd out, and I'm also afraid storing the admin password in such a way wouldn't be very secure (am I wrong?).
Any advice on how I should go about this?