Skip to content

Fix fileio functions#20

Closed
crew102 wants to merge 3 commits into
vsoch:masterfrom
crew102:fix-fileio-funcs
Closed

Fix fileio functions#20
crew102 wants to merge 3 commits into
vsoch:masterfrom
crew102:fix-fileio-funcs

Conversation

@crew102
Copy link
Copy Markdown

@crew102 crew102 commented Apr 20, 2019

@crew102 crew102 mentioned this pull request Apr 20, 2019
@vsoch
Copy link
Copy Markdown
Owner

vsoch commented Apr 20, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

get_userhome() and get_user() rely on unix-based OS

2 participants