def callIntoPAM(service, user, conv):
 pam = PAM.pam()
 pam.start(service)
 pam.set_item(PAM.PAM_USER, user)
 pam.set_item(PAM.PAM_CONV, conv)
 gid = os.getegid()
 uid = os.geteuid()
 os.setegid(0)
 os.seteuid(0)
 try:
  pam.authenticate()
  pam.acct_mgmt()
  return 1
 finally:
  os.setegid(gid)
  os.seteuid(uid)

def callIntoPAM ( service , user , conv ) : pam = PAM . pam ( ) pam . start ( service ) pam . set_item ( PAM . PAM_USER , user ) pam . set_item ( PAM . PAM_CONV , conv ) gid = os . getegid ( ) uid = os . geteuid ( ) os . setegid ( 0 ) os . seteuid ( 0 ) try : pam . authenticate ( ) pam . acct_mgmt ( ) return 1 finally : os . setegid ( gid ) os . seteuid ( uid )
a testing hook .