[Twisted-Python] SetUID per XML RPC client

Phil Mayers p.mayers at imperial.ac.uk
Fri Mar 21 07:33:30 EDT 2008

Faraz Khan wrote:
> Dear all,
> What Im trying to do is the following. Please suggest whether this makes 
> sense or not (I dont think it does- so am asking for suggestions!):
> 1. I have a XML RPC Server using xmlrpc.XMLRPC
> 2. Clients connect to it using SSL (am using reactor.listenSSL with a 
> custom context factory)
> 3. This server (or agent) is being used for sys admin tasks. I want to 
> connect, auth and then be able to do various sys admin tasks which the 
> XMLRPC server lets them do.
> 4. What i wish to be able to do is that a UID/GID is set (based on their 
> auth credentials) for that particular request.
> I personally think this is impossible to do with threads. I have done 
> something simliar using Fork & C though.

It may or may not be possible with threads, but it doesn't matter 
because Twisted doesn't use threads. It's single-process, single-thread 
async/event driven.

You will not be able to setuid effectively in the main Twisted program.

> Doing os.setuid works but (obviously) changes the main process's UID 
> which is not what I want.
> Any advice would be highly appreciated.

Run child processes doing the actual admin tasks.

More information about the Twisted-Python mailing list