Use a more portable way of finding the users login.

os.getlogin() isn't reliable, and requires a login shell for it to
work. A more portable method is to use getuser from the getpass module.

Reference:

https://stackoverflow.com/questions/842059/is-there-a-portable-way-to-get-the-current-username-in-python
http://www.postgresql.org/message-id/20060512221230.0D04486C565@pgfoundry.org