mirror of
https://github.com/github/codeql.git
synced 2026-07-20 18:58:36 +02:00
26 lines
833 B
Python
26 lines
833 B
Python
libpam = CDLL(find_library("pam"))
|
|
|
|
pam_authenticate = libpam.pam_authenticate
|
|
pam_authenticate.restype = c_int
|
|
pam_authenticate.argtypes = [PamHandle, c_int]
|
|
|
|
pam_acct_mgmt = libpam.pam_acct_mgmt
|
|
pam_acct_mgmt.restype = c_int
|
|
pam_acct_mgmt.argtypes = [PamHandle, c_int]
|
|
|
|
def authenticate(username, password, service='login'):
|
|
def my_conv(n_messages, messages, p_response, app_data):
|
|
"""
|
|
Simple conversation function that responds to any prompt where the echo is off with the supplied password
|
|
"""
|
|
...
|
|
|
|
handle = PamHandle()
|
|
conv = PamConv(my_conv, 0)
|
|
retval = pam_start(service, username, byref(conv), byref(handle))
|
|
|
|
retval = pam_authenticate(handle, 0)
|
|
if retval == 0:
|
|
retval = pam_acct_mgmt(handle, 0)
|
|
return retval == 0
|