Improve with-write-permissions macro.
Check write permissions in lein jvm, fixes #1775.

This doesn't check the legacy repl port file, presumably that's okay as
it's... well, legacy.
Merge branch 'improve-write-permissions'.