Blame SOURCES/sudo-1.8.23-pam_access-and-terminals.patch

46eb58
unchanged:
46eb58
--- b/plugins/sudoers/auth/pam.c
46eb58
+++ b/plugins/sudoers/auth/pam.c
46eb58
@@ -210,59 +210,71 @@
46eb58
 sudo_pam_approval(struct passwd *pw, sudo_auth *auth, bool exempt)
46eb58
 {
46eb58
     const char *s;
46eb58
+    int rc, status = AUTH_SUCCESS;
46eb58
     int *pam_status = (int *) auth->data;
46eb58
     debug_decl(sudo_pam_approval, SUDOERS_DEBUG_AUTH)
46eb58
 
46eb58
-    *pam_status = pam_acct_mgmt(pamh, PAM_SILENT);
46eb58
-    switch (*pam_status) {
46eb58
+    rc = pam_acct_mgmt(pamh, PAM_SILENT);
46eb58
+    switch (rc) {
46eb58
 	case PAM_SUCCESS:
46eb58
-	    debug_return_int(AUTH_SUCCESS);
46eb58
+	    break;
46eb58
 	case PAM_AUTH_ERR:
46eb58
 	    log_warningx(0, N_("account validation failure, "
46eb58
 		"is your account locked?"));
46eb58
-	    debug_return_int(AUTH_FATAL);
46eb58
+	    status = AUTH_FATAL;
46eb58
+	    break;
46eb58
 	case PAM_NEW_AUTHTOK_REQD:
46eb58
 	    /* Ignore if user is exempt from password restrictions. */
46eb58
-	    if (exempt)
46eb58
-		debug_return_int(AUTH_SUCCESS);
46eb58
+	    if (exempt) {
46eb58
+		rc = *pam_status;
46eb58
+		break;
46eb58
+	    }
46eb58
 	    /* New password required, try to change it. */
46eb58
 	    log_warningx(0, N_("Account or password is "
46eb58
 		"expired, reset your password and try again"));
46eb58
-	    *pam_status = pam_chauthtok(pamh,
46eb58
-		PAM_CHANGE_EXPIRED_AUTHTOK);
46eb58
-	    if (*pam_status == PAM_SUCCESS)
46eb58
-		debug_return_int(AUTH_SUCCESS);
46eb58
-	    if ((s = pam_strerror(pamh, *pam_status)) == NULL)
46eb58
+	    rc = pam_chauthtok(pamh, PAM_CHANGE_EXPIRED_AUTHTOK);
46eb58
+	    if (rc == PAM_SUCCESS)
46eb58
+		break;
46eb58
+	    if ((s = pam_strerror(pamh, rc)) == NULL)
46eb58
 		s = "unknown error";
46eb58
 	    log_warningx(0,
46eb58
 		N_("unable to change expired password: %s"), s);
46eb58
-	    debug_return_int(AUTH_FAILURE);
46eb58
+	    status = AUTH_FAILURE;
46eb58
+	    break;
46eb58
 	case PAM_AUTHTOK_EXPIRED:
46eb58
 	    /* Ignore if user is exempt from password restrictions. */
46eb58
-	    if (exempt)
46eb58
-		debug_return_int(AUTH_SUCCESS);
46eb58
+	    if (exempt) {
46eb58
+		rc = *pam_status;
46eb58
+		break;
46eb58
+	    }
46eb58
 	    /* Password expired, cannot be updated by user. */
46eb58
 	    log_warningx(0,
46eb58
 		N_("Password expired, contact your system administrator"));
46eb58
-	    debug_return_int(AUTH_FATAL);
46eb58
+	    status = AUTH_FATAL;
46eb58
+	    break;
46eb58
 	case PAM_ACCT_EXPIRED:
46eb58
 	    log_warningx(0,
46eb58
 		N_("Account expired or PAM config lacks an \"account\" "
46eb58
 		"section for sudo, contact your system administrator"));
46eb58
-	    debug_return_int(AUTH_FATAL);
46eb58
+	    status = AUTH_FATAL;
46eb58
+	    break;
46eb58
 	case PAM_AUTHINFO_UNAVAIL:
46eb58
 	case PAM_MAXTRIES:
46eb58
 	case PAM_PERM_DENIED:
46eb58
-	    s = pam_strerror(pamh, *pam_status);
46eb58
+	    s = pam_strerror(pamh, rc);
46eb58
 	    log_warningx(0, N_("PAM account management error: %s"),
46eb58
 		s ? s : "unknown error");
46eb58
-	    debug_return_int(AUTH_FAILURE);
46eb58
+	    status = AUTH_FAILURE;
46eb58
+	    break;
46eb58
 	default:
46eb58
-	    s = pam_strerror(pamh, *pam_status);
46eb58
+	    s = pam_strerror(pamh, rc);
46eb58
 	    log_warningx(0, N_("PAM account management error: %s"),
46eb58
 		s ? s : "unknown error");
46eb58
-	    debug_return_int(AUTH_FATAL);
46eb58
+	    status = AUTH_FATAL;
46eb58
+	    break;
46eb58
     }
46eb58
+    *pam_status = rc;
46eb58
+    debug_return_int(status);
46eb58
 }
46eb58
 
46eb58
 int
46eb58
unchanged:
46eb58
--- a/doc/sudoers.cat
46eb58
+++ b/doc/sudoers.cat
46eb58
@@ -1286,6 +1286,17 @@ S?SU?UD?DO?OE?ER?RS?S O?OP?PT?TI?IO?ON?NS?S
46eb58
                        well as the _?P_?r_?e_?v_?e_?n_?t_?i_?n_?g _?s_?h_?e_?l_?l _?e_?s_?c_?a_?p_?e_?s section at the end
46eb58
                        of this manual.  This flag is _?o_?f_?f by default.
46eb58
 
46eb58
+     pam_acct_mgmt     On systems that use PAM for authentication, s?su?ud?do?o will
46eb58
+                       perform PAM account validation for the invoking user by
46eb58
+                       default.  The actual checks performed depend on which
46eb58
+                       PAM modules are configured.  If enabled, account
46eb58
+                       validation will be performed regardless of whether or
46eb58
+                       not a password is required.  This flag is _?o_?n by
46eb58
+                       default.
46eb58
+
46eb58
+                       This setting is only supported by version 1.8.28 or
46eb58
+                       higher.
46eb58
+
46eb58
      pam_session       On systems that use PAM for authentication, s?su?ud?do?o will
46eb58
                        create a new PAM session for the command to be run in.
46eb58
                        Disabling _?p_?a_?m_?__?s_?e_?s_?s_?i_?o_?n may be needed on older PAM
46eb58
unchanged:
46eb58
--- a/doc/sudoers.man.in
46eb58
+++ b/doc/sudoers.man.in
46eb58
@@ -2722,6 +2722,19 @@ This flag is
46eb58
 \fIoff\fR
46eb58
 by default.
46eb58
 .TP 18n
46eb58
+pam_acct_mgmt
46eb58
+On systems that use PAM for authentication,
46eb58
+\fBsudo\fR
46eb58
+will perform PAM account validation for the invoking user by default.
46eb58
+The actual checks performed depend on which PAM modules are configured.
46eb58
+If enabled, account validation will be performed regardless of whether
46eb58
+or not a password is required.
46eb58
+This flag is
46eb58
+\fIon\fR
46eb58
+by default.
46eb58
+.sp
46eb58
+This setting is only supported by version 1.8.28 or higher.
46eb58
+.TP 18n
46eb58
 pam_session
46eb58
 On systems that use PAM for authentication,
46eb58
 \fBsudo\fR
46eb58
unchanged:
46eb58
--- a/doc/sudoers.mdoc.in
46eb58
+++ b/doc/sudoers.mdoc.in
46eb58
@@ -2560,6 +2560,18 @@ section at the end of this manual.
46eb58
 This flag is
46eb58
 .Em off
46eb58
 by default.
46eb58
+.It pam_acct_mgmt
46eb58
+On systems that use PAM for authentication,
46eb58
+.Nm sudo
46eb58
+will perform PAM account validation for the invoking user by default.
46eb58
+The actual checks performed depend on which PAM modules are configured.
46eb58
+If enabled, account validation will be performed regardless of whether
46eb58
+or not a password is required.
46eb58
+This flag is
46eb58
+.Em on
46eb58
+by default.
46eb58
+.Pp
46eb58
+This setting is only supported by version 1.8.28 or higher.
46eb58
 .It pam_session
46eb58
 On systems that use PAM for authentication,
46eb58
 .Nm sudo
46eb58
only in patch2:
46eb58
unchanged:
46eb58
--- ./plugins/sudoers/auth/pam.c.pamm	2019-01-11 21:30:17.000000000 +0100
46eb58
+++ ./plugins/sudoers/auth/pam.c	2019-08-02 15:14:38.980077956 +0200
46eb58
@@ -214,66 +214,68 @@ sudo_pam_approval(struct passwd *pw, sud
46eb58
     int *pam_status = (int *) auth->data;
46eb58
     debug_decl(sudo_pam_approval, SUDOERS_DEBUG_AUTH)
46eb58
 
46eb58
-    rc = pam_acct_mgmt(pamh, PAM_SILENT);
46eb58
-    switch (rc) {
46eb58
-	case PAM_SUCCESS:
46eb58
-	    break;
46eb58
-	case PAM_AUTH_ERR:
46eb58
-	    log_warningx(0, N_("account validation failure, "
46eb58
-		"is your account locked?"));
46eb58
-	    status = AUTH_FATAL;
46eb58
-	    break;
46eb58
-	case PAM_NEW_AUTHTOK_REQD:
46eb58
-	    /* Ignore if user is exempt from password restrictions. */
46eb58
-	    if (exempt) {
46eb58
-		rc = *pam_status;
46eb58
-		break;
46eb58
-	    }
46eb58
-	    /* New password required, try to change it. */
46eb58
-	    log_warningx(0, N_("Account or password is "
46eb58
-		"expired, reset your password and try again"));
46eb58
-	    rc = pam_chauthtok(pamh, PAM_CHANGE_EXPIRED_AUTHTOK);
46eb58
-	    if (rc == PAM_SUCCESS)
46eb58
-		break;
46eb58
-	    if ((s = pam_strerror(pamh, rc)) == NULL)
46eb58
-		s = "unknown error";
46eb58
-	    log_warningx(0,
46eb58
-		N_("unable to change expired password: %s"), s);
46eb58
-	    status = AUTH_FAILURE;
46eb58
-	    break;
46eb58
-	case PAM_AUTHTOK_EXPIRED:
46eb58
-	    /* Ignore if user is exempt from password restrictions. */
46eb58
-	    if (exempt) {
46eb58
-		rc = *pam_status;
46eb58
-		break;
46eb58
-	    }
46eb58
-	    /* Password expired, cannot be updated by user. */
46eb58
-	    log_warningx(0,
46eb58
-		N_("Password expired, contact your system administrator"));
46eb58
-	    status = AUTH_FATAL;
46eb58
-	    break;
46eb58
-	case PAM_ACCT_EXPIRED:
46eb58
-	    log_warningx(0,
46eb58
-		N_("Account expired or PAM config lacks an \"account\" "
46eb58
-		"section for sudo, contact your system administrator"));
46eb58
-	    status = AUTH_FATAL;
46eb58
-	    break;
46eb58
-	case PAM_AUTHINFO_UNAVAIL:
46eb58
-	case PAM_MAXTRIES:
46eb58
-	case PAM_PERM_DENIED:
46eb58
-	    s = pam_strerror(pamh, rc);
46eb58
-	    log_warningx(0, N_("PAM account management error: %s"),
46eb58
-		s ? s : "unknown error");
46eb58
-	    status = AUTH_FAILURE;
46eb58
-	    break;
46eb58
-	default:
46eb58
-	    s = pam_strerror(pamh, rc);
46eb58
-	    log_warningx(0, N_("PAM account management error: %s"),
46eb58
-		s ? s : "unknown error");
46eb58
-	    status = AUTH_FATAL;
46eb58
-	    break;
46eb58
+    if (def_pam_acct_mgmt) {
46eb58
+	rc = pam_acct_mgmt(pamh, PAM_SILENT);
46eb58
+	switch (rc) {
46eb58
+	    case PAM_SUCCESS:
46eb58
+		break;
46eb58
+	    case PAM_AUTH_ERR:
46eb58
+		log_warningx(0, N_("account validation failure, "
46eb58
+		    "is your account locked?"));
46eb58
+		status = AUTH_FATAL;
46eb58
+		break;
46eb58
+	    case PAM_NEW_AUTHTOK_REQD:
46eb58
+		/* Ignore if user is exempt from password restrictions. */
46eb58
+		if (exempt) {
46eb58
+		    rc = *pam_status;
46eb58
+		    break;
46eb58
+		}
46eb58
+		/* New password required, try to change it. */
46eb58
+		log_warningx(0, N_("Account or password is "
46eb58
+		    "expired, reset your password and try again"));
46eb58
+		rc = pam_chauthtok(pamh, PAM_CHANGE_EXPIRED_AUTHTOK);
46eb58
+		if (rc == PAM_SUCCESS)
46eb58
+		    break;
46eb58
+		if ((s = pam_strerror(pamh, rc)) == NULL)
46eb58
+		    s = "unknown error";
46eb58
+		log_warningx(0,
46eb58
+		    N_("unable to change expired password: %s"), s);
46eb58
+		status = AUTH_FAILURE;
46eb58
+		break;
46eb58
+	    case PAM_AUTHTOK_EXPIRED:
46eb58
+		/* Ignore if user is exempt from password restrictions. */
46eb58
+		if (exempt) {
46eb58
+		    rc = *pam_status;
46eb58
+		    break;
46eb58
+		}
46eb58
+		/* Password expired, cannot be updated by user. */
46eb58
+		log_warningx(0,
46eb58
+		    N_("Password expired, contact your system administrator"));
46eb58
+		status = AUTH_FATAL;
46eb58
+		break;
46eb58
+	    case PAM_ACCT_EXPIRED:
46eb58
+		log_warningx(0,
46eb58
+		    N_("Account expired or PAM config lacks an \"account\" "
46eb58
+		    "section for sudo, contact your system administrator"));
46eb58
+		status = AUTH_FATAL;
46eb58
+		break;
46eb58
+	    case PAM_AUTHINFO_UNAVAIL:
46eb58
+	    case PAM_MAXTRIES:
46eb58
+	    case PAM_PERM_DENIED:
46eb58
+		s = pam_strerror(pamh, rc);
46eb58
+		log_warningx(0, N_("PAM account management error: %s"),
46eb58
+		    s ? s : "unknown error");
46eb58
+		status = AUTH_FAILURE;
46eb58
+		break;
46eb58
+	    default:
46eb58
+		s = pam_strerror(pamh, rc);
46eb58
+		log_warningx(0, N_("PAM account management error: %s"),
46eb58
+		    s ? s : "unknown error");
46eb58
+		status = AUTH_FATAL;
46eb58
+		break;
46eb58
+	}
46eb58
+	*pam_status = rc;
46eb58
     }
46eb58
-    *pam_status = rc;
46eb58
     debug_return_int(status);
46eb58
 }
46eb58
 
46eb58
only in patch2:
46eb58
unchanged:
46eb58
--- ./plugins/sudoers/defaults.c.pamm	2019-08-02 15:14:38.973077882 +0200
46eb58
+++ ./plugins/sudoers/defaults.c	2019-08-02 15:14:38.987078030 +0200
46eb58
@@ -642,6 +642,7 @@ init_defaults(void)
46eb58
     if ((def_editor = strdup(EDITOR)) == NULL)
46eb58
 	goto oom;
46eb58
     def_set_utmp = true;
46eb58
+    def_pam_acct_mgmt = true;
46eb58
     def_pam_setcred = true;
46eb58
     def_syslog_maxlen = MAXSYSLOGLEN;
46eb58
     def_case_insensitive_user = true;
46eb58
only in patch2:
46eb58
unchanged:
46eb58
--- ./plugins/sudoers/def_data.c.pamm	2019-08-02 15:14:38.976077914 +0200
46eb58
+++ ./plugins/sudoers/def_data.c	2019-08-02 15:20:37.592876029 +0200
46eb58
@@ -502,6 +502,10 @@ struct sudo_defs_types sudo_defs_table[]
46eb58
 	N_("Don't fork and wait for the command to finish, just exec it"),
46eb58
 	NULL,
46eb58
     }, {
46eb58
+  "pam_acct_mgmt", T_FLAG,
46eb58
+  N_("Perform PAM account validation management"),
46eb58
+  NULL,
46eb58
+    }, {
46eb58
 	NULL, 0, NULL
46eb58
     }
46eb58
 };
46eb58
only in patch2:
46eb58
unchanged:
46eb58
--- ./plugins/sudoers/def_data.h.pamm	2019-08-02 15:14:38.976077914 +0200
46eb58
+++ ./plugins/sudoers/def_data.h	2019-08-02 15:14:38.987078030 +0200
46eb58
@@ -230,6 +230,8 @@
46eb58
 #define def_legacy_group_processing (sudo_defs_table[I_LEGACY_GROUP_PROCESSING].sd_un.flag)
46eb58
 #define I_CMND_NO_WAIT          115
46eb58
 #define def_cmnd_no_wait        (sudo_defs_table[I_CMND_NO_WAIT].sd_un.flag)
46eb58
+#define I_PAM_ACCT_MGMT         116
46eb58
+#define def_pam_acct_mgmt       (sudo_defs_table[I_PAM_ACCT_MGMT].sd_un.flag)
46eb58
 
46eb58
 enum def_tuple {
46eb58
 	never,
46eb58
only in patch2:
46eb58
unchanged:
46eb58
--- ./plugins/sudoers/def_data.in.pamm	2019-08-02 15:14:38.976077914 +0200
46eb58
+++ ./plugins/sudoers/def_data.in	2019-08-02 15:14:38.987078030 +0200
46eb58
@@ -363,3 +363,6 @@ legacy_group_processing
46eb58
 cmnd_no_wait
46eb58
 	T_FLAG
46eb58
 	"Don't fork and wait for the command to finish, just exec it"
46eb58
+pam_acct_mgmt
46eb58
+	T_FLAG
46eb58
+	"Perform PAM account validation management"