os.path.expanduser ignores os.seteuid

Graham Guttocks graham_guttocks at yahoo.co.nz
Tue Jun 4 14:54:13 EDT 2002


Sean 'Shaleh' Perry <shalehperry at attbi.com> wrote:
>
> It uses short circuit eval for the '~' case and simply
> reads the environment $HOME.  If you could pass '~user/' 
> it would give you the answer you want.

Well, I also need to support lots of existing ~/foo cases.

Looks like I can just set $HOME after the os.seteuid() call
with the following:

os.environ['HOME'] = pwd.getpwuid(os.geteuid())[5]

Then subsequent os.path.expanduser calls should work as I want.

Regards,
Graham

__________________________________________________
Do You Yahoo!?
Yahoo! - Official partner of 2002 FIFA World Cup
http://fifaworldcup.yahoo.com





More information about the Python-list mailing list