From: Todd C. Miller Date: Mon, 15 Nov 2004 19:43:47 +0000 (+0000) Subject: Properly negate the return value of alias_matches() when appropriate. X-Git-Tag: SUDO_1_7_0~824 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fd46c2c3efb690604ac6238ad35c1345a222f4ae;p=sudo Properly negate the return value of alias_matches() when appropriate. --- diff --git a/match.c b/match.c index 93849b18e..9a6696186 100644 --- a/match.c +++ b/match.c @@ -113,8 +113,9 @@ user_matches(pw, list) switch (m->type) { case ALIAS: rval = alias_matches(m->name, USERALIAS, pw, NULL); - if (rval != UNSPEC || (rval = !strcmp(m->name, pw->pw_name))) - matched = rval; + if (rval == UNSPEC) + rval = !strcmp(m->name, pw->pw_name); + matched = m->negated ? !rval : rval; break; case ALL: matched = !m->negated; @@ -156,8 +157,9 @@ runas_matches(pw, list) switch (m->type) { case ALIAS: rval = alias_matches(m->name, RUNASALIAS, pw, NULL); - if (rval != UNSPEC || (rval = !strcmp(m->name, pw->pw_name))) - matched = rval; + if (rval == UNSPEC) + rval = !strcmp(m->name, pw->pw_name); + matched = m->negated ? !rval : rval; break; case ALL: matched = !m->negated; @@ -195,8 +197,9 @@ host_matches(shost, lhost, list) switch (m->type) { case ALIAS: rval = alias_matches(m->name, HOSTALIAS, shost, lhost); - if (rval != UNSPEC || (rval = hostname_matches(shost, lhost, m->name))) - matched = rval; + if (rval == UNSPEC) + rval = hostname_matches(shost, lhost, m->name); + matched = m->negated ? !rval : rval; break; case ALL: matched = !m->negated; @@ -237,7 +240,7 @@ cmnd_matches(cmnd, args, list) case ALIAS: rval = alias_matches(m->name, CMNDALIAS, cmnd, args); if (rval != UNSPEC) - matched = rval; + matched = m->negated ? !rval : rval; break; case ALL: matched = !m->negated;