Blame SOURCES/sudo-1.8.19p2-sudo-l-sssd.patch

110381
From 1f37620953699fe71b09760fe01e33eb6ada771c Mon Sep 17 00:00:00 2001
110381
From: "Todd C. Miller" <Todd.Miller@courtesan.com>
110381
Date: Wed, 15 Nov 2017 12:27:39 -0700
110381
Subject: [PATCH] When checking the results for "sudo -l" and "sudo -v", keep
110381
 checking even after we get a match since the value of doauth may depend on
110381
 evaluating all the results.  From Radovan Sroka of RedHat.
110381
110381
In list (-l) or verify (-v) mode, if we have a match but authentication
110381
is required, clear FLAG_NOPASSWD so that when listpw/verifypw is
110381
set to "all" and there are multiple sudoers sources a password will
110381
be required unless none of the entries in all sources require
110381
authentication.  From Radovan Sroka of RedHat
110381
110381
Avoid calling cmnd_matches() in list/verify mode if we already have
110381
a match.
110381
---
110381
 plugins/sudoers/ldap.c  |  5 ++++-
110381
 plugins/sudoers/parse.c | 10 +++++++---
110381
 plugins/sudoers/sssd.c  |  5 ++++-
110381
 3 files changed, 15 insertions(+), 5 deletions(-)
110381
110381
diff --git a/plugins/sudoers/ldap.c b/plugins/sudoers/ldap.c
110381
index 46309cba..c5c18360 100644
110381
--- a/plugins/sudoers/ldap.c
110381
+++ b/plugins/sudoers/ldap.c
110381
@@ -3320,12 +3320,13 @@ sudo_ldap_lookup(struct sudo_nss *nss, int ret, int pwflag)
110381
 		(pwcheck == all && doauth != true)) {
110381
 		doauth = !!sudo_ldap_check_bool(ld, entry, "authenticate");
110381
 	    }
110381
+	    if (matched == true)
110381
+		continue;
110381
 	    /* Only check the command when listing another user. */
110381
 	    if (user_uid == 0 || list_pw == NULL ||
110381
 		user_uid == list_pw->pw_uid ||
110381
 		sudo_ldap_check_command(ld, entry, NULL) == true) {
110381
 		matched = true;
110381
-		break;
110381
 	    }
110381
 	}
110381
 	if (matched == true || user_uid == 0) {
110381
@@ -3339,6 +3340,8 @@ sudo_ldap_lookup(struct sudo_nss *nss, int ret, int pwflag)
110381
 		case any:
110381
 		    if (doauth == false)
110381
 			SET(ret, FLAG_NOPASSWD);
110381
+		    else
110381
+			CLR(ret, FLAG_NOPASSWD);
110381
 		    break;
110381
 		default:
110381
 		    break;
110381
diff --git a/plugins/sudoers/parse.c b/plugins/sudoers/parse.c
110381
index 749a3eb2..a12e88c5 100644
110381
--- a/plugins/sudoers/parse.c
110381
+++ b/plugins/sudoers/parse.c
110381
@@ -182,14 +182,16 @@ sudo_file_lookup(struct sudo_nss *nss, int validated, int pwflag)
110381
 		if (hostlist_matches(sudo_user.pw, &priv->hostlist) != ALLOW)
110381
 		    continue;
110381
 		TAILQ_FOREACH(cs, &priv->cmndlist, entries) {
110381
+		    if ((pwcheck == any && cs->tags.nopasswd == true) ||
110381
+			(pwcheck == all && cs->tags.nopasswd != true))
110381
+			nopass = cs->tags.nopasswd;
110381
+		    if (match == ALLOW)
110381
+			continue;
110381
 		    /* Only check the command when listing another user. */
110381
 		    if (user_uid == 0 || list_pw == NULL ||
110381
 			user_uid == list_pw->pw_uid ||
110381
 			cmnd_matches(cs->cmnd) == ALLOW)
110381
 			    match = ALLOW;
110381
-		    if ((pwcheck == any && cs->tags.nopasswd == true) ||
110381
-			(pwcheck == all && cs->tags.nopasswd != true))
110381
-			nopass = cs->tags.nopasswd;
110381
 		}
110381
 	    }
110381
 	}
110381
@@ -202,6 +204,8 @@ sudo_file_lookup(struct sudo_nss *nss, int validated, int pwflag)
110381
 	    SET(validated, FLAG_CHECK_USER);
110381
 	else if (nopass == true)
110381
 	    SET(validated, FLAG_NOPASSWD);
110381
+	else
110381
+	    CLR(validated, FLAG_NOPASSWD);
110381
 	debug_return_int(validated);
110381
     }
110381
 
110381
diff --git a/plugins/sudoers/sssd.c b/plugins/sudoers/sssd.c
110381
index 65b4d875..09ca9fee 100644
110381
--- a/plugins/sudoers/sssd.c
110381
+++ b/plugins/sudoers/sssd.c
110381
@@ -1321,12 +1321,13 @@ sudo_sss_lookup(struct sudo_nss *nss, int ret, int pwflag)
110381
 		    (pwcheck == all && doauth != true)) {
110381
 		    doauth = !!sudo_sss_check_bool(handle, rule, "authenticate");
110381
 		}
110381
+		if (matched == true)
110381
+		    continue;
110381
 		/* Only check the command when listing another user. */
110381
 		if (user_uid == 0 || list_pw == NULL ||
110381
 		    user_uid == list_pw->pw_uid ||
110381
 		    sudo_sss_check_command(handle, rule, NULL) == true) {
110381
 		    matched = true;
110381
-		    break;
110381
 		}
110381
 	    }
110381
 	}
110381
@@ -1341,6 +1342,8 @@ sudo_sss_lookup(struct sudo_nss *nss, int ret, int pwflag)
110381
 		case any:
110381
 		    if (doauth == false)
110381
 			SET(ret, FLAG_NOPASSWD);
110381
+		    else
110381
+			CLR(ret, FLAG_NOPASSWD);
110381
 		    break;
110381
 		default:
110381
 		    break;
110381
-- 
110381
2.14.3
110381