Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: blank passwords+ adminstrator privileges



AppleScript returns an error (-927) if you do not provide a password.
Try this code:

on verifyPassword(passwd)
try
do shell script "sudo -k"
do shell script "sudo -v" password passwd with administrator
privileges
return passwd
on error errMsg number errNum
if errMsg contains ("Sorry, try again" as Unicode text) then
display dialog "The password you entered is incorrect" buttons
{"OK"} default button 1
return false
else if errNum is -927 then
-- handle the blank password. You can return any string, sudo will
accept everything. Its AppleScript that won't accept the empty string
try
set arbitraryPassword to "blank"
do shell script "sudo -v" password arbitraryPassword with
administrator privileges
return arbitraryPassword
on error msg
display dialog "The password you entered is incorrect" buttons
{"OK"} default button 1
return false
end try
else
log errMsg & return & errNum
return false
end if
end try
end verifyPassword

HTH,
Mike

> On Dec 23, 2003, at 1:31 PM, Scott C. Brown 02 wrote:
>
> if i want to run a terminal command with administrator privleges from
> an applescript studio app, do I have to do anything special to handle
> a blank password? A friend was just telling me that he has a blank
> password in 10.3, and it made me wonder if my app would handle it
> correctly. is there a special way to handle this?
>
> i can't test my app or look at the code until tomorrow so that's why
> i'm asking you guys now :)
>
> scott
_______________________________________________
applescript-studio mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-studio
Do not post admin requests to the list. They will be ignored.



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.