On Mar 29, 2010, at 2:53 AM, Axel Luttgens wrote: Le 29 mars 2010 à 00:25:57, Luther Fuller a écrit : On Mar 28, 2010, at 5:05 PM, Axel Luttgens wrote:
Apparently because stdin isn't a tty in the context created by "do shell script":
do shell script "test -t 0; echo $?"
--> 1
On the other hand, without the -stdinpass, hdiutil should raise a password dialog with the option to save the password in the user's keychain; in all cases, this would be safer than having a cleartext password stored in a script...
I'm experimenting with using a password that is never seen by human eyeballs. I don't want the user to ever have to type the password, so the password dialog is out. And I don't want the password recorded anywhere, so Keychain is out. (You are wondering where I'm getting the password, aren't you?)
So, I'm looking for a 'do shell script ...' command that will mount a password protected sparsebundle.
Sorry, I misread hdiutil's man page and thus didn't go much further... in fact, hdiutil doesn't require stdin to be a tty for its -stdinpass option to be effective. The reason here is that, when invoked from "do shell script", the shell is by default in a posix-compatible mode, and the "-n" option isn't recognized by echo. One may for example make use of printf (which is anyway the recommended substitute to echo nowadays): do shell script "printf 'abcd' | hdiutil attach -stdinpass " & the result
I looked at the printf man page. I didn't really want to see anything that complicated, but I tried this anyway ...
set imageAlias to alias "OS_X:Users:lutherfuller:Desktop:Password TEST:PassWordTest.sparsebundle" set pw to "abcd" quoted form of (POSIX path of imageAlias) do shell script "printf " & pw & " | hdiutil attach -stdinpass " & the result
And it worked!
And yes: where do you take the password from? :-)
The password is a UUID obtained from any mountable and removable device such as a thumb drive. If the device is not mounted, you can't open the encrypted image file. There will be a lot of AppleScripting involved to get it working right, but now it seems feasible. (But, is it useful?)
|