You need to make these applications consistent with
the documented order in which to call pam_setcred
and pam_session modules.
pam_start (...)
pam_authenticate (...)
pam_acct_mgmt (...)
pam_setcred (..., PAM_ESTABLISH_CRED)
pam_open_session (...)
...
pam_close_session (...)
pam_setcred (..., PAM_DELETE_CRED)
pam_end (...)
Cheers
Andrew