changeing users on linux
Mike Meyer
mwm at mired.org
Fri Nov 11 23:25:56 EST 2005
darkchild50 at gmail.com writes:
> how would i go about makeing a program in python that asks for username
> and password and changes to that user?
For some definition of "changes to that user":
# Untested code
from pwd import getpwnam
from os import setuid
setuid(getpwnam(raw_input("Who do you want to be? "))[2])
I don't recommend the one-liner version for production code, though.
You didn't say what the password was for, so I skipped asking for it.
<mike
--
Mike Meyer <mwm at mired.org> http://www.mired.org/home/mwm/
Independent WWW/Perforce/FreeBSD/Unix consultant, email for more information.
More information about the Python-list
mailing list