[clug] Python question Re setuid()
Leigh Makewell
leigh at ozforces.com
Fri Jan 16 00:26:09 GMT 2004
Hi guys.
I've got a question for you about Python.
I have just written my first python script. It's a simple server script
that listens on a port for connections. It reads it's config from a
MySQL database.
This script is running on multiple machines, getting the same config
settings from the database.
The problem is we want the script to listen on port 90, so we start it
as the root user, once the port is open it I get it to switch it's user
to a non root user. This user is set up via the database config.
As far as I can tell the only way to change the process user is via the
function setuid() which takes a user id as the parameter. Thats fine
except the userid for the user we want is different on every server. So
I want to be able to change the user by username. Also username is much
more user friendly.
So does anyone know how to get the userid for a given username?
I suppose I could parse the passwd file, but thats just a pain in the
butt :)
Leigh Makewell
More information about the linux
mailing list