[clug] Python question Re setuid()

Brad Hards bhards at bigpond.net.au
Fri Jan 16 00:31:26 GMT 2004


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, 16 Jan 2004 11:26 am, Leigh Makewell wrote:
> So does anyone know how to get the userid for a given username?
pwd module

Python 2.2.1 (#1, Dec  4 2002, 23:43:31)
[GCC 3.2 (Mandrake Linux 9.0 3.2-1mdk)] on linux-i386
Type "help", "copyright", "credits" or "license" for more information.
>>> import pwd
>>> pwd.getpwnam("bradh")
('bradh', 'x', 500, 500, '', '/home/bradh', '/bin/bash')
>>> pwd.getpwnam("bradh")[2]
500

> I suppose I could parse the passwd file, but thats just a pain in the
> butt :)
Don't do that. It won't even work on machines that are using LDAP or some 
other db system.

Brad
- -- 
http://linux.conf.au - Having fun now!
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFABzDlGwwszQ/PZzgRAgQHAJsF3EumedeVpO4rhfxDSp37BiylTwCffEYZ
c3lkDNvZBZq1xz/rGFi2XbU=
=YAAN
-----END PGP SIGNATURE-----


More information about the linux mailing list