The pythonic way equal to "whoami"

Christopher Head chead at is.invalid
Wed Jun 8 16:08:45 EDT 2011


On Wed, 08 Jun 2011 21:58:17 +0800
TheSaint <nobody at nowhere.net.no> wrote:

> Kushal Kumaran wrote:
> 
> > os.geteuid
> This return 0 for *root* . I don't know if it's a standard for all
> distro. Mine is Archlinux.
> I'd just like to avoid error caused by wrong access by user
> 

It is. Until Linux capabilities, EUID==0 used to be special-cased in the
kernel as being the test for binding to network ports <1024, bypassing
filesystem access control, changing the system time, and so on. Since
Linux caps, it's theoretically possible to use a different UID, but for
compatibility and convenience, as well as because PID 1 (/sbin/init) is
still invoked by the kernel as UID 0, everyone still does that.

Chris



More information about the Python-list mailing list