how to spawn a process under different user
gagsl-py2 at yahoo.com.ar
Thu Jul 2 21:28:42 EDT 2009
En Thu, 02 Jul 2009 19:27:05 -0300, Tim Harig <usernet at ilthio.net>
> On 2009-07-02, sanket <sanket.s.patel at gmail.com> wrote:
>>> sanket wrote:
>>> > I am trying to use python's subprocess module to launch a process.
>>> > but in order to do that I have to change the user.
>> I am using python 2.4 on centos.
> I have never done this in python; but, using the normal system calls in C
> the process is basically:
> 1. fork() a new process
> 2. the child process changes its user id with setreuid() and
> possibly its group id with setregid()
> 3. then the child exec()s new process which replaces itself
> All of the necessary functions should be under the os module on POSIX
> operating systems.
How to do that using the subprocess module: write a function for item (2)
above and pass it as the preexec_fn argument to Popen. preexec_fn is
executed after fork() and before exec()
More information about the Python-list