1- def authenticate (self , username , password , service = 'login' , encoding = 'utf-8' , resetcreds = True ):
2- libpam = CDLL (find_library ("pam" ))
3- pam_authenticate = libpam .pam_authenticate
4- pam_acct_mgmt = libpam .pam_acct_mgmt
5- pam_authenticate .restype = c_int
6- pam_authenticate .argtypes = [PamHandle , c_int ]
7- pam_acct_mgmt .restype = c_int
8- pam_acct_mgmt .argtypes = [PamHandle , c_int ]
9-
10- handle = PamHandle ()
11- conv = PamConv (my_conv , 0 )
12- retval = pam_start (service , username , byref (conv ), byref (handle ))
1+ libpam = CDLL (find_library ("pam" ))
132
14- retval = pam_authenticate (handle , 0 )
15- if retval == 0 :
16- retval = pam_acct_mgmt (handle , 0 )
17- return retval == 0
3+ pam_authenticate = libpam .pam_authenticate
4+ pam_authenticate .restype = c_int
5+ pam_authenticate .argtypes = [PamHandle , c_int ]
6+
7+ pam_acct_mgmt = libpam .pam_acct_mgmt
8+ pam_acct_mgmt .restype = c_int
9+ pam_acct_mgmt .argtypes = [PamHandle , c_int ]
10+
11+ def authenticate (username , password , service = 'login' ):
12+ def my_conv (n_messages , messages , p_response , app_data ):
13+ """
14+ Simple conversation function that responds to any prompt where the echo is off with the supplied password
15+ """
16+ ...
17+
18+ handle = PamHandle ()
19+ conv = PamConv (my_conv , 0 )
20+ retval = pam_start (service , username , byref (conv ), byref (handle ))
21+
22+ retval = pam_authenticate (handle , 0 )
23+ if retval == 0 :
24+ retval = pam_acct_mgmt (handle , 0 )
25+ return retval == 0
0 commit comments