Somehow be able to use AS to send a PW to unlock an App

Started by ravedog, July 05, 2009, 05:40:48 AM

Previous topic - Next topic

ravedog

I lock Mail. I also use Carbon Copy CLoner to do rotated backups. I also perform a few scripts within CCC, a pre script that tells all running apps (except for CCC and the Finder) to quit before it does it's backup. That way all programs that are running that use Espionage have the chance to quit and have their data folders re-locked. Then CCC does its backup, then runs a post script that emails me the log report for the backup so I can take a look at its operations when I'm at work (the backup occurs while I'm away). You can see where I'm going with this:  When the post script attempts to open Mail it will inevitably get the dialog box asking for a password and this is where it will fail.

I was wondering if I could embed within the Applescript to pass a password to Espionage's Dialog so as to let Mail run It's kind of like how you can mount shared volumes with an AS by embedding the username and password within the script.

I know Espionage doesn't currently offer such a thing, but I cannot wrap my head around how this could even be achieved without leaving a huge security whole (unless I script some Apple Events that type into the dialog box. But I'm not even sure the Espionage password entry dialog box is standard OS X fair).

I guess the other option would be to download another email app like Thunderbird and maybe script it if it has a scriptable library. I was hoping to avoid this.

I know Espionage has built-in backups but I have to stick to CCC as I need bootable clones.

greg

#1
I see your conundrum. Unfortunately Espionage is not very scriptable at the moment, although this is on our list of refinements to add down the road.

I would suggest considering various workarounds to this problem.  For example, are you sure that you need Mail to be locked during this process? You might be able to modify your script to quit only certain applications and leave Mail running.  After all, if you have a script that would pass a password to Espionage, that means that password is stored somewhere on your drive, and that's just about as secure as leaving Mail running anyway.  As long as the screensaver password is protecting the computer, there should be no problem with this work-around.

Another possible solution is to write your own script that sends the email, although this may or may not be a realistic option for you.  There are plenty of languages out there that have libraries that support "easily" sending email via SMTP.

QuoteBut I'm not even sure the Espionage password entry dialog box is standard OS X fair).

It is, Espionage is completely Cocoa-based, though for this you would want to script EspionageHelper, not Espionage.
Follow @espionageapp@twitter.com or @espionage@mstdn.io for news and updates!

ravedog

#2
Quote from: "greg"I would suggest considering various workarounds to this problem.  For example, are you sure that you need Mail to be locked during this process? You might be able to modify your script to quit only certain applications and leave Mail running.  After all, if you have a script that would pass a password to Espionage, that means that password is stored somewhere on your drive, and that's just about as secure as leaving Mail running anyway.  As long as the screensaver password is protecting the computer, there should be no problem with this work-around.

I do have a whitelist of apps listed in in the script that says to leave those processes running, so adding Mail would not be a problem. However, if I have read all your documentation correctly about back-up procedures, it is preferred to have data re-locked. Hence why I quit Mail. Not to mention the fact there is an off chance that I may have quit mail from running.

Quote from: "greg"Another possible solution is to write your own script that sends the email, although this may or may not be a realistic option for you.  There are plenty of languages out there that have libraries that support "easily" sending email via SMTP.

Yikes! Too scary for me. Ironically, after I wrote you the email, I just found my old copy of Entourage on my hard drive and scripted it to do the log notification email. SO I found a temporary workaround.


Quote from: "greg"It is, Espionage is completely Cocoa-based, though for this you would want to script EspionageHelper, not Espionage.

Funny you should mention that. Again, after I wrote the initial posting, I decided not to give up and poke around the UI elements of EspionageHelper, since it was the one handling the password dialog process. SO I gave it a try and came up with this script:

activate application "EspionageHelper"
tell application "System Events"
tell process "EspionageHelper"
tell window "Folder Locked"
select text field 1
keystroke ("password")
click button "OK"
end tell
end tell
end tell

It worked. So then I decided to expand it a little and add a couple more lines to the script to trigger the password dialog by opening Mail:

launch application "Mail"

delay 5

activate application "EspionageHelper"
tell application "System Events"
tell process "EspionageHelper"
tell window "Folder Locked"
select text field 1
keystroke ("password)
click button "OK"
end tell
end tell
end tell

Unfortunately, this doesn't work because once you issue an "Open" command from AS it will not continue the script until the app opens, and the app won't open since it's waiting for the dialog box to be confirmed, which never happens because its stuck at "Open." ARRRRRGHHHH!

ravedog

#3
I GOT IT TO WORK! It seems there is an additional command i can use in the do shell script command that tells it not to wait and to output the result to dev/null.  Here is the resulting script that works:

do shell script "open /Applications/iCal.app &> /dev/null &"

delay 5

activate application "EspionageHelper"
tell application "System Events"
tell process "EspionageHelper"
tell window 1
select text field 1
keystroke ("passworkd")
click button "OK"
end tell
end tell
end tell

IT WORKS! :D  :D  :D  Now I think I will stick with launching Entourage until I know of doing it thru the CL using smtp. Although I got it to work, as both you and I have pointed out, that this script alone can be dangerous as anyone with access to it can unlock Mail without a password.

By the way, did I mention I'm not really a scripter?

greg

#4
Quote from: "ravedog"I GOT IT TO WORK! It seems there is an additional command i can use in the do shell script command that tells it not to wait and to output the result to dev/null.  Here is the resulting script that works:

Great job!  :D

QuoteBy the way, did I mention I'm not really a scripter?

I certainly wouldn't have guessed that as you certainly seem to have a programmer's drive. ;-)

Quote from: "ravedog"IT WORKS! :D  :D  :D  Now I think I will stick with launching Entourage until I know of doing it thru the CL using smtp. Although I got it to work, as both you and I have pointed out, that this script alone can be dangerous as anyone with access to it can unlock Mail without a password.

You may want to have a look at getting the 'sendmail' command working... I don't know much about it but I'm fairly certain that if you got that working you would have an ideal solution to your problem.

Here are some possibly useful links:

http://subtlecoolness.com/2009/06/21/enabling-postfix-sendmail-on-mac-os-x-105-leopard/
http://www.macosxhints.com/article.php?story=20081217161612647

Google Searches:
http://www.google.com/search?q=sendmail+os+x
http://www.google.com/search?q=sendmail+os+x+10.5
Follow @espionageapp@twitter.com or @espionage@mstdn.io for news and updates!

ravedog

#5
Quote from: "greg"You may want to have a look at getting the 'sendmail' command working... I don't know much about it but I'm fairly certain that if you got that working you would have an ideal solution to your problem.

Here are some possibly useful links:

http://subtlecoolness.com/2009/06/21/enabling-postfix-sendmail-on-mac-os-x-105-leopard/
http://www.macosxhints.com/article.php?story=20081217161612647

Google Searches:
http://www.google.com/search?q=sendmail+os+x
http://www.google.com/search?q=sendmail+os+x+10.5

Those got me started. I found a really simple How-To on enabling Postfix in Leopard:

http://www.riverturn.com/blog/?p=239

Once I got postfix running, all I needed was one command line to send out my email:

do shell script "tail -n50 /Library/Logs/CCC.log | mail -s "Garrett's CCC Report" ravedog@gmail.com"
which pipes the last 50 lines of my log file into the body of an email message (yes I learned what piping was today!)

Anyway, this has gotten so off topic but I thank you for leading me in the right direction.  :D

greg

#6
Great! :-) Thanks for the link on how to get postfix setup, that looks like it could be useful knowledge to have.
Follow @espionageapp@twitter.com or @espionage@mstdn.io for news and updates!