#!/usr/bin/python

# pam_authenticate.py: a script to check a user's password against PAM.
# part of the pywiki project, see https://github.com/pepaslabs/pywiki
# written by <NAME>, released under the terms of the MIT license.

# usage: pipe a password into this script, giving the username as the first argument.
# a zero exit status indicates successful authentication.

import sys

import pam # pip install python-pam
p = pam.pam()

logged_in = False

try:
    user = sys.argv[1]
    passwd = sys.stdin.read()
    logged_in = p.authenticate(user, passwd)
except Exception as e:
    sys.exit(2)
else:
    if logged_in == True:
        sys.exit(0)
    else:
        sys.exit(1)

#!/usr/bin/python

# pam_authenticate.py: a script to check a user's password against PAM.
# part of the pywiki project, see https://github.com/pepaslabs/pywiki
# written by <NAME>, released under the terms of the MIT license.

# usage: pipe a password into this script, giving the username as the first argument.
# a zero exit status indicates successful authentication.

import sys

import pam # pip install python-pam
p = pam.pam()

logged_in = False

try:
    user = sys.argv[1]
    passwd = sys.stdin.read()
    logged_in = p.authenticate(user, passwd)
except Exception as e:
    sys.exit(2)
else:
    if logged_in == True:
        sys.exit(0)
    else:
        sys.exit(1)

#!/usr/bin/python # pam_authenticate.py: a script to check a user's password against PAM. # part of the pywiki project, see https://github.com/pepaslabs/pywiki # written by <NAME>, released under the terms of the MIT license. # usage: pipe a password into this script, giving the username as the first argument. # a zero exit status indicates successful authentication. # pip install python-pam