[wpkg-users] Strange behaviour when selecting hosts
Rainer Meier
r.meier at wpkg.org
Sun Aug 23 14:16:54 CEST 2009
Hi Lukasz,
Lukasz Zalewski wrote:
> Hi!
> I have the following hosts.xml file:
>
> <host name="ityyy|itzzz" profile-id="allaccess" />
>
> <host name="it14[789]" profile-id="ITLtop" />
> <host name="it1[56789][123456789]" profile-id="ITLtop" />
> <host name="it2[123456789][123456789]" profile-id="ITLtop" />
>
> <host name="it07[89]" profile-id="ITLmiddle" />
> <host name="it1[123][123456789]" profile-id="ITLmiddle" />
> <host name="it14[123456]" profile-id="ITLmiddle" />
>
> <host name="138.37.94.+" profile-id="student" />
>
> when the script is run on ityyy student profile is always selected
> (match is found on 138.37.94.+). As the documentation states that the
> hosts are processed top to bottom (with the exeptions of non reg
> expressions) the allaccess would be found and used first.
I see multiple problems here. First of all IP-Adresses are currently not matched
by regular expressions. So if you would like to specify something like
138.37.94.+ you should specify 138.37.94.0-255 (ranges are supported indeed. In
your case the "+" notation did still work in this special case because "+"
evaluates to NaN and therefore is treated not to be outside the range. Well,
this might be changed in the future.
Unfortunately in your case you hit a very special case which is there since WPKG
0.9 and has not been changed due to compatibility.
WPKG starts from top and first checks all host entries if the name match
directly. Since you use regular expressions in all host entries this fails for
all of them.
Then WPKG tries to match all host entries by IP-address. This only works on the
last entry since it contains 4 "." charactres and therefore can be treated as a
IP-address.
Here your host "ityyy" matches and WPKG stops evaluation.
Probably you could change your IP-adress match to a generic reg-exp host match:
<host name=".*" profile-id="student" />
In that case WPKG would find no match in direct host matching, no match while
matching IP adresses and then proceed to regex matching.
So to say it again. Currently the WPKG implementation includes some priority:
1. Direct host matching
2. IP-address matching
3. Regex matching
It might have been not the best decision to do it this way. That's why I am
thinking about changing it in order that each single host entry is first matched
directly, then try a direct IP-match (with ranges), then do a regex match on
the hostname and finally a regex match on ip-address. But this might have some
other side effects - especially I am afraid it could break some host definitions
out there.
br,
Rainer
More information about the wpkg-users
mailing list