-
Notifications
You must be signed in to change notification settings - Fork 132
Dropping privileges and listening to low ports
nipapd is built on the Twisted framework which takes care of a lot of stuff, among other things setting up the TCP socket to listen on.
We'd like to run nipapd as a non-root user to avoid potential security issues but if we want to listen to a low port (<1024) we need root privileges. One usually does this by setting up the socket and then dropping privileges from root to another user. In Twisted the socket setup and running the actual program is kind of a one-step thing so it's difficult for us to setup the socket, drop privs and then hand over to the rest of Twisted.
For the time being nipapd doesn't support both dropping privileges and listening on a low port but as the nipapd protocol is not a standardised one with a standardised port (like http on port 80), there are no compelling reasons to run it on a low port anyway - pretty much a non-issue.
Twisted can be told to run with a different uid and gid but then it should be initialised as a Twisted process by twistd. Since we already have our own init stuff we don't want to use twistd and this can also be done but requires quite a hack - http://stackoverflow.com/questions/6610489/twisted-application-without-twistd