"visudo -x". This was never required by the standard and not
escaping them improves readability of the output.
+ * Sudo no longer treats PAM_SESSION_ERR as a fatal error when
+ opening the PAM session. Other errors from pam_open_session()
+ are still treated as fatal. This avoids the "policy plugin
+ failed session initialization" error message seen on some systems.
+
What's new in Sudo 1.8.16
* Fixed a compilation error on Solaris 10 with Stun Studio 12.
{
int rc, status = AUTH_SUCCESS;
int *pam_status = (int *) auth->data;
+ const char *errstr;
debug_decl(sudo_pam_begin_session, SUDOERS_DEBUG_AUTH)
/*
if (pamh != NULL) {
rc = pam_end(pamh, PAM_SUCCESS | PAM_DATA_SILENT);
if (rc != PAM_SUCCESS) {
- const char *errstr = pam_strerror(pamh, rc);
+ errstr = pam_strerror(pamh, rc);
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
"pam_end: %s", errstr ? errstr : "unknown error");
}
*/
rc = pam_set_item(pamh, PAM_USER, pw->pw_name);
if (rc != PAM_SUCCESS) {
- const char *errstr = pam_strerror(pamh, rc);
+ errstr = pam_strerror(pamh, rc);
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
"pam_set_item(pamh, PAM_USER, %s): %s", pw->pw_name,
errstr ? errstr : "unknown error");
if (def_pam_setcred) {
rc = pam_setcred(pamh, PAM_REINITIALIZE_CRED);
if (rc != PAM_SUCCESS) {
- const char *errstr = pam_strerror(pamh, rc);
+ errstr = pam_strerror(pamh, rc);
sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
"pam_setcred: %s", errstr ? errstr : "unknown error");
}
}
if (def_pam_session) {
- *pam_status = pam_open_session(pamh, 0);
- if (*pam_status != PAM_SUCCESS) {
- const char *errstr = pam_strerror(pamh, *pam_status);
+ rc = pam_open_session(pamh, 0);
+ switch (rc) {
+ case PAM_SUCCESS:
+ break;
+ case PAM_SESSION_ERR:
+ /* Treat PAM_SESSION_ERR as a non-fatal error. */
+ errstr = pam_strerror(pamh, rc);
+ sudo_debug_printf(SUDO_DEBUG_ERROR|SUDO_DEBUG_LINENO,
+ "pam_open_session: %s", errstr ? errstr : "unknown error");
+ /* Avoid closing session that was not opened. */
+ def_pam_session = false;
+ break;
+ default:
+ /* Unexpected session failure, treat as fatal error. */
+ *pam_status = rc;
+ errstr = pam_strerror(pamh, *pam_status);
log_warningx(0, N_("%s: %s"), "pam_open_session",
errstr ? errstr : "unknown error");
rc = pam_end(pamh, *pam_status | PAM_DATA_SILENT);