Reputation: 24727
I have modified the example python script:
service = 'passwd'
if len(sys.argv) == 3:
user = sys.argv[1]
password = sys.argv[2]
else:
print 'error'
auth = PAM.pam()
auth.start(service)
if user != None:
auth.set_item(PAM.PAM_USER, user)
auth.set_item(PAM.PAM_CONV, pam_conv)
try:
auth.authenticate()
auth.acct_mgmt()
except PAM.error, resp:
print 'Go away! (%s)' % resp
except:
print 'Internal error'
else:
print 'Good to go!'
This works, but asks me to input the password. I would like instead to verify the password which is passed as a parameter (sys.argv[2]). Documentation is non-existant, so how should I do it?
Upvotes: 2
Views: 1799
Reputation: 21
The example first lines are missing. The provided 'pam_conv' function asks the password to the user. You must define your own function returning a constant password:
def pam_conv(auth, query_list, userData):
return [(the_password,0)]
Upvotes: 2
Reputation: 7323
When I was finding solution for interactive password prompt, I only found this solution python expect lib
Upvotes: 1