classification
Title: os.getuid() documentation should be clear on what kind of uid it is referring
Type: behavior Stage: resolved
Components: Documentation Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: adam.woodbeck, docs@python, giampaolo.rodola, python-dev, r.david.murray, εσχατοκυριος
Priority: normal Keywords: patch

Created on 2010-11-22 13:01 by giampaolo.rodola, last changed 2014-06-07 20:52 by python-dev. This issue is now closed.

Files
File name Uploaded Description Edit
mywork.patch εσχατοκυριος, 2014-06-07 17:48 review
Messages (6)
msg122117 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2010-11-22 13:01
http://docs.python.org/library/os.html#os.getuid
os.getuid() documentation just states:

> Return the current process’s user id.

It is not clear, however, whether "user id" refers to real, effective or saved user id.

As per:
http://linux.about.com/library/cmd/blcmdl2_getuid.htm
...it should refer to _real_ user id.
msg122123 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2010-11-22 13:42
Update: I think also os.getlogin() doc is wrong.
This is what it states (2.7 doc):


> Return the name of the user logged in on the controlling terminal of 
> the process. For most purposes, it is more useful to use the 
> environment variable LOGNAME to find out who the user is, or 
> pwd.getpwuid(os.getuid())[0] to get the login name of the currently 
> effective user id.

Since os.getuid() refers to _real_ uid the last sentence should be changed as such:

- ... to get the login name of the currently effective user id.
+ ... to get the login name of the currently real user id.
msg122161 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-11-22 20:17
These are wrappers around the posix functions.  As such the unix man pages are a better authority than the Python docs :)  Still, we could certainly improve the docs.

The getlogin error is probably a miscopy from the man page: the man page on my system shows the example as  getpwuid(geteuid()), but it is actually showing a replacement for 'cuserid', not 'getlogin'.
msg122165 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2010-11-22 20:37
Indeed, now that I google for "getlogin", it's not easy to figure out what kind of user it is supposed to return exactly.

For getuid() it seems pretty clear that we're talking about _real_ uid, though.
http://www.manpagez.com/man/2/getuid/
http://linux.die.net/man/2/getuid
msg219954 - (view) Author: Greg (εσχατοκυριος) * Date: 2014-06-07 17:48
Here's a wording change in the documentation to clarify this.
msg219973 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-06-07 20:52
New changeset 19172062e5c0 by Benjamin Peterson in branch '3.4':
specify that getuid() returns the real uid (closes #10503)
http://hg.python.org/cpython/rev/19172062e5c0

New changeset 6dfbe504f659 by Benjamin Peterson in branch '2.7':
specify that getuid() returns the real uid (closes #10503)
http://hg.python.org/cpython/rev/6dfbe504f659

New changeset 8866ac6f2269 by Benjamin Peterson in branch 'default':
merge 3.4 (#10503)
http://hg.python.org/cpython/rev/8866ac6f2269
History
Date User Action Args
2014-06-07 20:52:00python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg219973

resolution: fixed
stage: needs patch -> resolved
2014-06-07 17:48:07εσχατοκυριοςsetfiles: + mywork.patch

nosy: + εσχατοκυριος
messages: + msg219954

keywords: + patch
2011-07-21 17:04:57adam.woodbecksetnosy: + adam.woodbeck
2010-11-22 20:37:40giampaolo.rodolasetmessages: + msg122165
2010-11-22 20:17:13r.david.murraysetversions: - Python 2.6
nosy: + r.david.murray

messages: + msg122161

type: behavior
stage: needs patch
2010-11-22 13:42:40giampaolo.rodolasetmessages: + msg122123
2010-11-22 13:01:10giampaolo.rodolacreate