[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: HostRange bug
From: |
rader |
Subject: |
Re: HostRange bug |
Date: |
Fri, 10 Sep 2004 16:01:43 -0500 |
Jim: thanks for finding the bug!
Mark: the enclosed patch is to cfengine-snap ca 1500 CST 10 Sep 2004.
Test script follows. Please apply it to the Source, or let me know
if it's not acceptable. Thanks.
steve
- - -
systems & network guy
high energy physics
university of wisconsin
> ---- Original Message ----
> From: Jim Wight
> > There appears to be a bug in the handling of HostRange in 2.1.10 and
> > earlier which may mean - it is certainly true in some circumstances -
> > that it is not possible to use HostRange more than once.
>
> [snip]
>
> > show that VDEFAULTBINSERVER.name is getting corrupted between calls to
> > HandleHostRange (in functions.c).
>
> The bug is in the loop starting at line 1079 in FuzzyHostMatch in item.c:
>
> for (sp = s2; sp < s2+strlen(s2); sp++ )
> {
> if ( isdigit((int)*sp) )
> {
> *sp = '\0';
> break;
> }
> }
>
> The loop modifies the string pointed to by s2 (the seond argument), and
> FuzzyHostMatch is called from HandleHostRange in functions.c with
> VDEFAULTBINSERVER.name as the second argument.
>
> Jim
>
>
>
> _______________________________________________
> Bug-cfengine mailing list
> address@hidden
> http://lists.gnu.org/mailman/listinfo/bug-cfengine
*** item.c.orig Fri Sep 3 07:13:06 2004
--- item.c Fri Sep 10 15:45:50 2004
***************
*** 1035,1040 ****
--- 1035,1041 ----
{ struct Item *args;
char *sp;
+ char s2_local[CF_MAXVARSIZE];
long cmp = -1, start = -1, end = -1;
Debug("SRDEBUG in FuzzyHostMatch(): %s vs %s\n",s2,s1);
args = SplitStringAsItemList(s1,',');
***************
*** 1075,1082 ****
}
Debug("SRDEBUG FuzzyHostMatch() %s is in (%ld..%ld)\n",s2,start,end);
!
! for (sp = s2; sp < s2+strlen(s2); sp++ )
{
if ( isdigit((int)*sp) )
{
--- 1076,1084 ----
}
Debug("SRDEBUG FuzzyHostMatch() %s is in (%ld..%ld)\n",s2,start,end);
!
! strcpy(s2_local,s2);
! for (sp = s2_local; sp < s2_local+strlen(s2_local); sp++ )
{
if ( isdigit((int)*sp) )
{
***************
*** 1084,1093 ****
break;
}
}
! Debug("SRDEBUG extracted basename %s\n",s2);
! Debug("SRDEBUG basename check: %s vs %s...\n",s2,args->name);
! if ( strcmp(s2,args->name) != 0 )
{
Debug("SRDEBUG FuzzyHostMatch() failed: basename %s does not match
%s\n",s2,args->name);
return 1;
--- 1086,1095 ----
break;
}
}
! Debug("SRDEBUG extracted basename %s\n",s2_local);
! Debug("SRDEBUG basename check: %s vs %s...\n",s2_local,args->name);
! if ( strcmp(s2_local,args->name) != 0 )
{
Debug("SRDEBUG FuzzyHostMatch() failed: basename %s does not match
%s\n",s2,args->name);
return 1;
#!/tmp/cfagent -d --no-splay --inform --no-lock --file
control:
actionsequence = ( shellcommands )
groups: desktop_node = ( HostRange(desktop,1-26) )
groups: atlas_node = ( HostRange(atlas,1-20) )
shellcommands: desktop_node:: "/bin/echo desktop_node is defined"
shellcommands: !desktop_node:: "/bin/echo desktop_node is NOT defined"
shellcommands: atlas_node:: "/bin/echo atlas_node is defined"
shellcommands: !atlas_node:: "/bin/echo atlas_node is NOT defined"