bug-cfengine
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

HostRange bug


From: Bas van der Vlies
Subject: HostRange bug
Date: Mon, 24 Jan 2005 14:24:22 +0100
User-agent: Mozilla Thunderbird 1.0 (Windows/20041206)

HostRange fails with multiple digits in hostname, eg: gb-r7n15

groups:
        TEST_CLUSTER = HostRange(gb-r7n,15-19) )


control:
        actionsequence = ( shellcommands )


shellcommands:
        TEST_CLUSTER::
                        "/bin/echo yes"

-------------------------------------------------------------------

On host gb-r7n15 it will fail because the function FuzzyHostMatch
determines the wrong basename for this host: gb-r instead of gb-r7n.

This causes the function to exit and not set the class TEST_CLUSTER.

Here is the patch. It is patches against the latest item.c from CVS:
--- item.c.org  Mon Jan 24 13:46:39 2005
+++ item.c      Mon Jan 24 14:16:37 2005
@@ -1035,11 +1035,11 @@
 
 { 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,',');
   sp = s2;
+  char host_basename[CF_MAXVARSIZE];
   
   for (sp = s2+strlen(s2)-1; sp > s2; sp--)
      {
@@ -1061,41 +1061,33 @@
      }
   sscanf(sp,"%ld",&cmp);
   Debug("SRDEBUG extracted int %d\n",cmp,sp);
+
+  /* HvB basename is */
+  strncpy(host_basename, s2, strlen(s2) - strlen(sp));
+  Debug("SRDEBUG host basename is  %s\n",host_basename,sp);
   
   if ( cmp < 0 )
      { 
      Debug("SRDEBUG FuzzyHostMatch() failed: %s doesn't have an int in it's 
domain name\n",s2);
      return 1;
      }
+   
   sscanf(args->next->name,"%ld-%ld",&start,&end);
-  
   if ( cmp < start || cmp > end )
      { 
      Debug("SRDEBUG FuzzyHostMatch() failed: %ld is not in 
(%ld..%ld)\n",cmp,start,end);
      return 1;
      }
-  
   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) )
-        {
-        *sp = '\0';
-        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 host basename check: %s vs %s...\n",host_basename,args->name);
+  if ( strcmp(host_basename,args->name) != 0 )
      {
      Debug("SRDEBUG FuzzyHostMatch() failed: basename %s does not match 
%s\n",s2,args->name);
      return 1;
      }
-
   Debug("SRDEBUG basename matches\n");
+
   Debug("SRDEBUG FuzzyHostMatch() succeeded\n");
   return 0;
 }

reply via email to

[Prev in Thread] Current Thread [Next in Thread]