1
2
3
4 import PAM
5 import warn
6
9
11 """ Authentication based on Unix login, the process must have root
12 access. You must have this in mind. You can change the uid and gid
13 to give root to this function or put it in an SPyRO server"""
14 def getpassword(auth, query_list, args):
15 resp = []
16 for query, t in query_list:
17 if t in (PAM.PAM_PROMPT_ECHO_ON, PAM.PAM_PROMPT_ECHO_OFF):
18 resp.append((password, 0))
19 elif t in (PAM.PAM_PROMPT_ERROR_MSG, PAM.PAM_PROMPT_TEXT_INFO):
20 warn.log("AUTH:",query)
21 resp.append(('', 0));
22 else:
23 return None
24 return resp
25 pam = PAM.pam()
26 pam.start('ftp')
27 pam.set_item(PAM.PAM_USER, login)
28 pam.set_item(PAM.PAM_CONV, getpassword)
29 isauth = False
30 try:
31 pam.authenticate()
32 isauth = True
33 except PAM.error, err:
34 warn.log(login, " ", err)
35 return isauth
36
37 if __name__ == '__main__':
38 print authunix('xxx','xxx')
39