On Tue, 17 Apr 2007, Brandon Hutchinson wrote:

> In cfengine 2.1.22, if a number appears in the basename part of the
> HostName function, cfengine does not seem to add the hosts to the class.
> 
> As an example, we have two servers named d7ospsawb801 and d7ospsawb802.
> 
> classes:
>       test_class     = ( HostRange(d7ospsawb8,01-02) )
> 
> These servers do not appear to be placed in test_class. Is this a bug,
> or should a number not appear in the basename part of the HostName
> function?

You're right, this is a bug.  The FuzzyHostMatch truncates the base at 
the first numerical character it finds -- the sscanf equivalent of a 
greedy regex match (item.c): 

   1044 { struct Item *args;
   1045  char *sp, refbase[CF_MAXVARSIZE];
   1046   long cmp = -1, start = -1, end = -1;
   1047 
   1048 sscanf(refhost,"%[^0-9]%ld",&refbase,&cmp);
   1049 
   1050 Debug("Found refbase=%s,cmp=%d\n",refbase,cmp);

Results in 'Found refbase=pa,cmp=2' given 'pa2-dhcp-192-168-230-46'
(which happens to be my test box's hostname at the moment).  

I can't think of a ready fix for this but my printf format-fu is not
strong -- spoiled by real regex engines, I guess. Maybe we should be 
scanning _backwards_ through 'refhost' looking for non-numerics?
(Steve Rader are you still around? This is your code, steve... :-) )

-=Eric


_______________________________________________
Bug-cfengine mailing list
[email protected]
https://cfengine.org/mailman/listinfo/bug-cfengine

Reply via email to