[wpkg-users] Strange behaviour when selecting hosts

Lukasz Zalewski lukas at dcs.qmul.ac.uk
Sun Aug 23 22:15:33 CEST 2009


Rainer Meier wrote:
> 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

Hi Rainer,
Thx a lot for clarifying things, i was not aware of direct ip matching 
and assumed ip address i specified was a regexp. I think regexp support 
for IP adresses would be much desired :) and if implemented the order of 
matching you listed would still be preserved.
Does ip matching currently supports ipaddr/netmask syntax either through 
x.x.x.x/24 or x.x.x.x/255.255.255.0?

Many Thanks

Lukasz



More information about the wpkg-users mailing list