2 # Author: Carlos O'Donell
3 # Upstream status: Needs to go upstream (2015-05-07)
5 diff --git a/inet/rcmd.c b/inet/rcmd.c
6 index acacaa0..9f2443b 100644
9 @@ -803,29 +803,38 @@ __validuser2_sa(hostf, ra, ralen, luser, ruser, rhost)
10 *p = '\0'; /* <nul> terminate username (+host?) */
12 /* buf -> host(?) ; user -> username(?) */
18 + /* First check the user part. This is an optimization, since
19 + one should always check the host first in order to detect
20 + negative host checks (which we check for later). */
21 + ucheck = __icheckuser (user, ruser);
23 + /* Either we found the user, or we didn't and this is a
24 + negative host check. We must do the negative host lookup
25 + in order to preserve the semantics of stopping on this line
26 + before processing others. */
27 + if (ucheck != 0 || *buf == '-') {
29 + /* Next check host part */
30 + hcheck = __checkhost_sa (ra, ralen, buf, rhost);
32 + /* Negative '-host user(?)' match? */
36 - /* First check host part */
37 - hcheck = __checkhost_sa (ra, ralen, buf, rhost);
43 - /* Then check user part */
47 - ucheck = __icheckuser (user, ruser);
49 - /* Positive 'host user' match? */
51 + /* Positive 'host user' match? */
52 + if (hcheck > 0 && ucheck > 0) {
57 - /* Negative 'host -user' match? */
60 + /* Negative 'host -user' match? */
61 + if (hcheck > 0 && ucheck < 0)
64 /* Neither, go on looking for match */