User impersonation using CLI and environment variables

This is one option of fixing #538. The other potential solution would use regular options (using optparse) instead of environment variables to accomplish the same thing.