Vagrant NFS Shares without a password

Since I switched a few months ago, Vagrant has been humming along nicely, spinning up trim little Ansible-provisioned Ubuntu boxes as needed. Since I’m using Virtual Box as the provider and shared folders barely work with more than a handful of files, my active projects are made available as NFS share points. Running on OS X, Vagrant’s NFS shares are configured by modifying /etc/exports, and unfortunately, that requires administrator privileges and a password prompt.

Thankfully someone shared a workaround shell script which tweaked sudoers so vagrant up no longer required a password. It worked perfectly, until recently.

With the release of Vagrant 1.3, the NFS password prompt was back. The modified sudoers commands no longer worked.

Updating sudoers

All sudo commands are logged, so figuring out what changed was just a slightly clumsy matter of checking the logs with Vagrant 1.2.7, then installing Vagrant 1.3.x and looking for changes. This was a lot more effective than trying to step through the diffs of the Ruby code to reconstruct the various commands.

In previous versions of Vagrant whitelisting these commands allows editing of /etc/exports without a password:

/usr/bin/su root -c echo '*' >> /etc/exports
/usr/bin/sed -e /*/ d -ibak /etc/exports

In Vagrant 1.3.x, those commands were updated:

/bin/bash -c echo '*' >> /etc/exports
/usr/bin/sed -E -e /*/ d -ibak /etc/exports

Based on the original shell script, here is the block that needs to be added to /etc/sudoers for password-free startup with NFS shares:

Cmnd_Alias VAGRANT_EXPORTS_ADD = /bin/bash -c echo '*' >> /etc/exports
Cmnd_Alias VAGRANT_NFSD = /sbin/nfsd restart
Cmnd_Alias VAGRANT_EXPORTS_REMOVE = /usr/bin/sed -E -e /*/ d -ibak /etc/exports

I also posted an updated fork of the original workaround,

WWDC 08 wrapup

WWDC 08 was incredible. While the iPhone gold rush euphoria contributed, everything just seemed especially good this year.

I’ve been quietly disappointed in Leopard since it shipped. It just seemed too rough around the edges and somewhat rushed, especially compared to the polish demonstrated by the iPhoneOS. Because of that, I’m probably more excited about Snow Leopard than I was about Leopard. Besides the promise of generally improving the overall experience, the under-the-hood OpenCL and “Grand Central” additions are truly revolutionary advances for desktop OSs. The idea behind OpenCL being able to utilize the largely untapped parallel processing power of the GPU has the potential to radically reorganize the entire idea of computing, moving things distinctly towards a brain-like collection of specialized processing units. I’ve been joking this is OS X SP1 but that’s just not true, Apple is mainlining some serious innovation into the backend of Snow Leopard and this should be a very, very good release.

My plan for this year worked very well. I managed to set aside the week prior to essentially cram on Cocoa and Objective-C. While that was originally supposed to be three weeks, the time I eeked out still helped a great deal. I also maintained a very disciplined focus about which sessions I went to. In the past I’ve flitted around trying to get a taste of every subject that interested me — which is almost everything. This year’s deliberate focus and pre-study nearly eliminated the blank-stare drift I’d experienced in the past and left me feeling more confident than ever about building stuff with Cocoa, writing FXPlugs and making things for iPhone.

But far and away the best thing about this year was the people. Twitter made a lot of this possible by starting conversations beforehand. I think I probably met half my twitterstream in person, which was awesome and kind of funny. The social dynamic of first meeting twitterers is sort of one where everyone treats everyone else like a celebrity. It ended up being this wonderful abstracted feeling of recognition which wasn’t nearly as creepy as it sounds like it would be. My only regret is not meeting the handful of people I knew were there but never crossed paths with.

There are just too many people to call out, but I was blown away by just about everyone I met.

Note about AppleScript records

When combining an existing AppleScript record with another overlapping record, the order of concatenation matters. Consider this example:

set breakfast to {food:"toast", drink:"coffee"}
set lunch to breakfast & {food:"sandwich"}

--- lunch is {food:"toast", drink:"coffee"}

Because breakfast comes before lunch (naturally, when I get to eat breakfast), food is already defined and isn’t recast by the new record. So we get toast for lunch.

Flipping the order of how the lunch record is built gives the expected result, and a better lunch:

set breakfast to {food:"toast", drink:"coffee"}
set lunch to {food:"sandwich"} & breakfast

--- lunch is {food:"sandwich", drink:"coffee"}

Deleting Unused mbox files

Or, How I reclaimed 1.25 gigabytes of my hard drive.

When 10.4 imported mail from the old 10.3 mbox files, it broke each message into an individual file so Spotlight could index them. The old mbox files, rightly, were left on the drive. For most people this wouldn’t take up a noticeable amount of space, however those of us with a ton of mail saw a significant hit to our disk space.

The following commands will remove the unused mbox files from the drive, recovering a potentially large amount of disk space:

    cd ~/Library/Mail
    find . -name "mbox" -ls

Make sure the only thing listed are mbox files in your mail directory (they should be). To delete all those files, change the last “-ls” of the above command to “-delete“. (I didn’t include the full command on purpose since it deletes files and I wanted to strongly encourage everyone doing this to check the file list before deleting.) Just to be doubly safe, backup before doing this.

Total size of my mail folder went from 3.07 GB (3,206,511,328 bytes) to 1.84 GB (1,884,864,581). A savings of almost 1.25 GB. At $229.00 for a 93.2 GB formatted notebook drive, that’s an actual cost savings of $3.02.

Note there was/is a bug with Mail importing under 10.4 where very large mbox files don’t read correctly. Make sure all your messages really did import correctly before deleting your mbox files.