user authentication via /etc/passwd|/etc/shadow

"Martin v. Löwis" martin at v.loewis.de
Sun Apr 4 13:47:16 EDT 2004


Marco Herrn wrote:
> I want to write a program where I authenticate users via the standard
> unix system accounts. I didn't find a module providing this
> functionality. Is there such a module available? If not, how can I
> achieve this?

You need a combination of the pwd and crypt modules. Lookup the name
of the user using the pwd module, and fetch the encrypted password.
Then use crypt.crypt for encryption; use the first two letters of
the encrypted password as the salt.

Be aware that some installations use MD5 passwords, which can be
recognized by starting with $1$ (or some such).

Regards,
Martin




More information about the Python-list mailing list