Dropping privileges in python daemon

D

David Härdeman

I'm currently working on a python daemon which needs to be able to
correctly drop privileges after opening ports and files that it needs to
open as root.

I'm used from C programming to use setresuid() to change the real,
effective and saved uid in one go, and although the os module has some of
the set*uid() functions it doesn't seem to have setresuid().

Nor could I find any another functions in os.* or posix.* which manipulate
the saved uid...so how do I get/set the saved uid in python?

(please CC me any replies)
 
M

Matthias Bläsing

Am Mon, 18 Aug 2008 14:33:27 +0200 schrieb David Härdeman:
I'm used from C programming to use setresuid() to change the real,
effective and saved uid in one go, and although the os module has some
of the set*uid() functions it doesn't seem to have setresuid().

no - python offers the posix function setuid. Have a look here:

http://www.opengroup.org/onlinepubs/000095399/functions/setuid.html

Without any further knowledge this should do everything you want from it
and it is available from the posix and/or the os module.

HTH

Matthias
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,756
Messages
2,569,534
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top