Becoming root within a Python script

Robert Vollmert rvollmert at gmx.net
Fri Sep 24 10:51:14 EDT 1999


On Fri, Sep 24, 1999 at 04:14:15AM +0000, Will Ware wrote:

[snip]
> if os.popen('whoami').readline()[:-1] == 'root':
[snip]

> Dumb question for those wiser than myself:
> The os.popen().readline()[:-1] construction is pretty ugly.
> Is there a better way to do it?

How about 'if os.getuid() == 0:' ?

-- 
Robert Vollmert                                      rvollmert at gmx.net




More information about the Python-list mailing list