Closed crew102 closed 5 years ago
To give you some background on the original choice of:
return pwd.getpwuid(os.getuid())[5]
This returns the user based on their uid, as opposed to other (not as certain) methods like looking at $HOME. It was something that gmk of Singularity taught me how to do, and I believe is a more secure approach to getting the user home (but not needed here). If you look at the docs for getpass, they are using environment variables and falling back to pwd:
This function checks the environment variables LOGNAME, USER, LNAME and USERNAME, in order, and returns the value of the first one which is set to a non-empty string. If none are set, the login name from the password database is returned on systems which support the pwd module, otherwise, an exception is raised.
It makes me a bit uneasy, but my unease is overkill for this case. Thanks for this check! I've redone the fix (without removing the test) and it's now merged into master - I'm going to close here, please take a look and if the changes are satisfactory we can close #19.
/home/<uname>
. For example, I'm on OSX and so my home dir is/Users/cbaker
, hence the test that I dropped in 4b23cc7 was failing.