]>
Commit | Line | Data |
---|---|---|
9eb008dc MT |
1 | # |
2 | # Author: Carlos O'Donell | |
3 | # Upstream status: Needs to go upstream (2015-05-07) | |
4 | # | |
5 | diff --git a/inet/rcmd.c b/inet/rcmd.c | |
6 | index acacaa0..9f2443b 100644 | |
7 | --- a/inet/rcmd.c | |
8 | +++ b/inet/rcmd.c | |
9 | @@ -803,29 +803,38 @@ __validuser2_sa(hostf, ra, ralen, luser, ruser, rhost) | |
10 | *p = '\0'; /* <nul> terminate username (+host?) */ | |
11 | ||
12 | /* buf -> host(?) ; user -> username(?) */ | |
13 | + if (*buf == '\0') | |
14 | + break; | |
15 | + if (*user == '\0') | |
16 | + user = luser; | |
17 | + | |
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); | |
22 | + | |
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 == '-') { | |
28 | + | |
29 | + /* Next check host part */ | |
30 | + hcheck = __checkhost_sa (ra, ralen, buf, rhost); | |
31 | + | |
32 | + /* Negative '-host user(?)' match? */ | |
33 | + if (hcheck < 0) | |
34 | + break; | |
35 | ||
36 | - /* First check host part */ | |
37 | - hcheck = __checkhost_sa (ra, ralen, buf, rhost); | |
38 | - | |
39 | - if (hcheck < 0) | |
40 | - break; | |
41 | - | |
42 | - if (hcheck) { | |
43 | - /* Then check user part */ | |
44 | - if (! (*user)) | |
45 | - user = luser; | |
46 | - | |
47 | - ucheck = __icheckuser (user, ruser); | |
48 | - | |
49 | - /* Positive 'host user' match? */ | |
50 | - if (ucheck > 0) { | |
51 | + /* Positive 'host user' match? */ | |
52 | + if (hcheck > 0 && ucheck > 0) { | |
53 | retval = 0; | |
54 | break; | |
55 | } | |
56 | ||
57 | - /* Negative 'host -user' match? */ | |
58 | - if (ucheck < 0) | |
59 | - break; | |
60 | + /* Negative 'host -user' match? */ | |
61 | + if (hcheck > 0 && ucheck < 0) | |
62 | + break; | |
63 | ||
64 | /* Neither, go on looking for match */ | |
65 | } |