Pages

Monday, November 7, 2011

How To Encrypt Just Mail's Messages

This is kind of crazy, but it works like a charm. I was trying to find a way to just encrypt and password-protect my mail without going and putting my account in FileVault (evil). I noticed that Mac OS X would mount a disk image to open a program it knew was once on that disk image and, well, I put two and two together: what if my mail was on an encrypted disk image that also held the only working copy of the Mail application? Well, it would prompt for the image password, open Mail, and if I’d done things right then my mail would show up.
So that’s what I did.

Make the Image

You’ll need an encrypted disk image with your current mail accounts. Don’t use Disk Utility for this because its “Image from Folder” feature creates a static image and we want a sparse image. Do something like this:
$ cd Library
$ hdiutil create -size 2g -srcfolder Mail -format SPARSE -encryption -stdinpass Mail
Enter disk image passphrase:
....................................
created: /Users/ahknight/Library/Mail.sparseimage

Link the Image

For now, let’s just move the Library/Mail folder to the side rather than deleting it outright. Rename it to Mail-old or something. Then, open the image you just made (if you did the above, it’s in ~/Library/Mail.sparseimage) and then do the following:
$ ln -s /Volumes/Mail ~/Library/Mail
Now when Mail wants to use your mail, it will use the image. Of course, if you start mail without the image mounted you’ll get strange things happening, so we need to put Mail on the image.

Add and Lock Mail

Drag a copy of Mail into the image. Remove the Mail item from your Dock and add this copy to it instead (this is the important step). Now when you click on Mail, the system will know to go to this disk image.
However, if any other copy of Mail is available, it will go to that one, instead. To prevent this, we have to make the other Mail ineligible for launching in one way or another. Pick one:
  • Delete it off the system and symlink /Applications/Mail.app to the copy on the disk image while it’s mounted, and have the image mounted during updates (best idea, since it doesn’t break anything so long as the image is mounted)
  • sudo chown root /Applications/Mail.app; sudo chmod 700 /Applications/Mail.app and copy the program back to the image after updates
  • Trash it. You’ll need to copy it off the image and back into place before system updates and then back on the image when done updating.
The first is the easiest and preferable way to do it.

Test

Now the moment of truth. Unmount the image and then click on the Mail icon. You should get a password prompt for the image and then Mail should start with all of your mail.



from: http://www.macgeekery.com/hacks/software/how_to_encrypt_just_mails_messages

No comments:

Post a Comment