> to use a port below 1000 on a Unix system one needs root priviledges. > But it's dangerous to execute all of a script under those priviledges. > Therefore I'd like to drop the root priviledges as soon as possible. > (How) is this possible? >
Are you sure you don't just want to use twisted? http://twistedmatrix.com/ It is a bit more complex to start, but for just serving web pages it may actually be simpler. Plus you get a lot of extra functionality built in (like dropping privelege and chroot). Looking at the code for twistd, they use os.setuid and os.setgid -- http://mail.python.org/mailman/listinfo/python-list