Changing Users in Python 
Author Message
 Changing Users in Python

Hi,

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?

Thanks



Thu, 22 May 2003 13:29:41 GMT  
 Changing Users in Python
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. ;)


|
| 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?

--
cliff crawford   http://www.people.cornell.edu/pages/cjc26/
                "Blink your eyelids periodically to lubricate your eyes."



Fri, 23 May 2003 09:15:16 GMT  
 Changing Users in Python
Using popen is as bad as having a bad setuid program.
Quote:

> 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. ;)


> |
> | 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?



Fri, 23 May 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ANN: Python User Groups page at python.org

2. DC: Zope Python User Group: ZODB and Python

3. New Python User Question about Python.

4. Python creator: Perl users are moving to Python

5. Python User Survey: was Python success story..

6. ANN: Python User Groups page at python.org

7. Colors changed on the end user PCs

8. How can I let user to change report

9. Changing the wording when user is asked if they want to add another record

10. New template to allow users to change screen layouts

11. Howto - Determine if the user selected ADD or CHANGE button

12. Trapping field changing when user left it blank

 

 
Powered by phpBB® Forum Software