Skip to content

Commit 23fc7ab

Browse files
committed
runas_userlist_matches: fix matching a Runas_Spec with an empty runas user.
We should only match a rule with an empty runas user if a group was specified on the command line (sudo -g) without a user (no -u option) or the user specified their own name on the command line. GitHub issue #290 --HG-- branch : 1.9
1 parent d821e8d commit 23fc7ab

1 file changed

Lines changed: 8 additions & 2 deletions

File tree

plugins/sudoers/match.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,14 @@ runas_userlist_matches(const struct sudoers_parse_tree *parse_tree,
188188
user_matched = !m->negated;
189189
break;
190190
case MYSELF:
191-
if (!ISSET(sudo_user.flags, RUNAS_USER_SPECIFIED) ||
192-
strcmp(user_name, runas_pw->pw_name) == 0)
191+
/*
192+
* Only match a rule with an empty runas user if a group
193+
* was specified on the command line without a user _or_
194+
* the user specified their own name on the command line.
195+
*/
196+
if ((!ISSET(sudo_user.flags, RUNAS_USER_SPECIFIED) &&
197+
ISSET(sudo_user.flags, RUNAS_GROUP_SPECIFIED)) ||
198+
strcmp(user_name, runas_pw->pw_name) == 0)
193199
user_matched = !m->negated;
194200
break;
195201
}

0 commit comments

Comments
 (0)