Changing Users in Python

Serge Chevarie-Pelletier sergecpelletier at yahoo.com
Mon Dec 4 23:52:02 EST 2000


Using popen is as bad as having a bad setuid program.



Cliff Crawford wrote:

> You might be able to do it using the getpass module to get the oracle
> user's password, and then use something like
> 
> cmdin, cmdout = os.popen('su - oracle -c "cmd you want to run as oracle"')
> cmdin.write(passwd + "\n")
> 
> to execute the command.  I haven't actually tested this though.
> 
> Another way to do it would be to setuid your script, but this can cause
> a whole lot of security problems.  So don't do it. ;)
> 
> 
> * Doug Farrell <dfarrell01 at earthlink.net> menulis:
> | 
> | I'm fairly new at Python and I'm thinking about writing some programs in
> | for use at work on the Sun web servers we use. But I need to know
> | something, I have a user on the system who delivers data for input into
> | the Oracle database, and I'd like them to run some scripts to do it,
> | rather than me doing all the time. However, to do this they have to 'su
> | - oracle', in otherwords, the script would have to change userid and run
> | some Oracle scripts than exit from that user and return to the delivery
> | user. Can Python do this kind of thing? And if so, how?
> 
> 





More information about the Python-list mailing list