我已经修改了示例 python 脚本:
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!'
这有效,但要求我输入密码。我想验证作为参数传递的密码(sys.argv[2])。文档不存在,那么我该怎么做呢?