how to check for unix password

Fredrik Lundh fredrik at pythonware.com
Wed Nov 2 12:00:34 EST 2005


eight02645999 at yahoo.com wrote:

> i created a login page that authenticate the user and his/her password
> to the unix ssystem. what modules can i used to compare the unix
> password with what the user typed in the cgi form? the password is
> encrypted (shadowed) so i need to decrypt it first before comparing
> to what the user typed.

encrypted != shadowed.  unix passwords are always encrypted, and
cannot be decrypted (at least not easily).

to check a password, encrypt the given password using the same salt,
and check if you get the same result.  see the second example on this
page for an example:

    http://effbot.org/librarybook/crypt.htm

if the password is shadowed, you need the right privileges, and the spwd
module:

    http://www.python.org/dev/doc/devel/lib/module-spwd.html

this is only available in development versions. to use it with an older
version, you have to built it yourself.  the source code is here:

    http://svn.python.org/view/python/trunk/Modules/spwdmodule.c

</F>






More information about the Python-list mailing list