Python with etc/Shadow
Question: so I'm writing this program that needs to check the password hash in
etc/shadow and compare it to the password the user entered. I tried encrypting
the password with hashlib.sha512, but the result was not the same. I think
it's salted some how, but I don't know if it uses a universal salt or how I
can get the salt each time.

tldr; I need a way for a user to enter a password, then have the program hash
it and check it against the etc/shadow. Any ideas?


Answer: Try this <https://pypi.python.org/pypi/pam> . First link in google by `python
pam`. Look at distribution package manager for python-pam if exists. Else
install with `pip` or `easy_install`.

Small example:

    
    
    >>> import pam
    >>> pam.authenticate('fred', 'fredspassword')
    False
    

