[Re] euid/egid eaten up by os.popen
Changjune Kim
juneaftn at REMOVETHIShanmail.net
Fri Jul 26 10:35:21 EDT 2002
"Donn Cave" <donn at u.washington.edu> wrote in message
news:ahptae$22qg$1 at nntp6.u.washington.edu...
> Quoth janeaustine50 at hotmail.com (Jane Austine):
> | >I bet you're running Linux. My suggestion is to try popen2, and
> |
> | Yes, Red Hat 7.3
> |
> |> specify the command as a list of arguments. For example, if you
> |> have been writing
> |> fp = os.popen('id')
> |> then try
> |> fp, ignore = popen2.popen2(['id'])
> |
> | Have done that and it didn't work still.
> ...
> | It seems like when popen forks for a new shell, euid is all cleared.
>
> Yes, I think it's the shell, all right. All I can say is, popen2()
> works for me - *IF* I use the list of parameters as above. It doesn't
> help to just use popen2 instead of popen, and give it the same command
> string.
>
> Donn Cave, donn at u.washington.edu
You can pass parameters for the /bin/sh with popen2 in posix.
Try this:
import popen2
cmd="id"
cmd=['/bin/sh','-pc',cmd]
f,ign=popen2.popen2(cmd)
The parameter "-p" tells sh not to reset euid as to ruid.
More information about the Python-list
mailing list