vsoch / watchme

Reproducible watchers for research
https://vsoch.github.io/watchme/
Mozilla Public License 2.0
878 stars 32 forks source link

Fix fileio functions #20

Closed crew102 closed 5 years ago

crew102 commented 5 years ago
vsoch commented 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.