bug-cfengine
[Top][All Lists]
Advanced

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

cfagent excessively excludes during copy


From: Jonathan Chen
Subject: cfagent excessively excludes during copy
Date: Mon, 24 Mar 2003 17:58:47 -0500
User-agent: telnet/1.1x

Somewhere between 2.0.5pre2 and 2.0.5 release, a bug was introduced into
cfagent such that when I do a server copy with purge and recurse, some
symlinks were not copied over.  After some investigation, it appears this
is due to some incorrect usage of strncmp().  A cursory glance revealed
some similar errors (though not all uses of strncmp() were incorrect). I
believe the following patch will fix all the errors of this type.  I'm not
too familiar with the internals of cfengine, so someone else should
probably examine this in more detail and see if I've incorrectly changed
something or if I missed a strncmp() change.

<patch below>

--- cfengine-2.0.6b1.orig/src/image.c   Tue Mar 18 02:54:59 2003
+++ cfengine-2.0.6b1/src/image.c        Mon Mar 24 17:42:55 2003
@@ -165,7 +165,7 @@
       succeed = 0;
       for (ptr = VEXCLUDECACHE; ptr != NULL; ptr=ptr->next)
           {
-          if ((strncmp(ptr->name,newto,strlen(newto)) == 0) && 
(strncmp(ptr->classes,ip->classes,strlen(ip->classes)) == 0))
+          if ((strncmp(ptr->name,newto,strlen(newto)+1) == 0) && 
(strncmp(ptr->classes,ip->classes,strlen(ip->classes)+1) == 0))
              {
              succeed = 1;
              }
@@ -663,7 +663,7 @@
 succeed = 0;
 for (ptr = VEXCLUDECACHE; ptr != NULL; ptr=ptr->next)
     {
-    if ((strncmp(ptr->name,destfile,strlen(destfile)) == 0) && 
(strncmp(ptr->classes,ip->classes,strlen(ip->classes)) == 0))
+    if ((strncmp(ptr->name,destfile,strlen(destfile)+1) == 0) && 
(strncmp(ptr->classes,ip->classes,strlen(ip->classes)+1) == 0))
        {
        succeed = 1;
        }
@@ -819,7 +819,7 @@
 
         for (ptr = VAUTODEFINE; ptr != NULL; ptr=ptr->next)
             {
-            if (strncmp(ptr->name,destfile,strlen(destfile)) == 0) 
+            if (strncmp(ptr->name,destfile,strlen(destfile)+1) == 0) 
                {
                snprintf(OUTPUT,bufsize*2,"cfengine: image %s was set to 
autodefine %s\n",ptr->name,ptr->classes);
                CfLog(cfinform,OUTPUT,"");
@@ -836,11 +836,11 @@
               continue;
               }
            
-           if (strncmp(ptr->classes,ip->classes,strlen(ip->classes)) == 0)
+           if (strncmp(ptr->classes,ip->classes,strlen(ip->classes)+1) == 0)
               {
               for (ptr1 = VEXCLUDECACHE; ptr1 != NULL; ptr1=ptr1->next)
                  {
-                 if ((strncmp(ptr1->name,destfile,strlen(destfile)) == 0) && 
(strncmp(ptr1->classes,ip->classes,strlen(ip->classes)) == 0))
+                 if ((strncmp(ptr1->name,destfile,strlen(destfile)+1) == 0) && 
(strncmp(ptr1->classes,ip->classes,strlen(ip->classes)+1) == 0))
                     {
                     succeed = 0;               
                     }
@@ -1057,7 +1057,7 @@
 
         for (ptr = VAUTODEFINE; ptr != NULL; ptr=ptr->next)
             {
-            if (strncmp(ptr->name,destfile,strlen(destfile)) == 0)
+            if (strncmp(ptr->name,destfile,strlen(destfile)+1) == 0)
                {
                snprintf(OUTPUT,bufsize*2,"cfengine: image %s was set to 
autodefine %s\n",ptr->name,ptr->classes);
                CfLog(cfinform,OUTPUT,"");
@@ -1073,11 +1073,11 @@
             succeed = 1;
             for (ptr = VSINGLECOPY; ptr != NULL; ptr=ptr->next)
                 {
-                if (strncmp(ptr->classes,ip->classes,strlen(ip->classes)) == 0)
+                if (strncmp(ptr->classes,ip->classes,strlen(ip->classes)+1) == 
0)
                    {
                    for (ptr1 = VEXCLUDECACHE; ptr1 != NULL; ptr1=ptr1->next)
                        {
-                       if ((strncmp(ptr1->name,destfile,strlen(destfile)) == 
0) && (strncmp(ptr1->classes,ip->classes,strlen(ip->classes)) == 0))
+                       if ((strncmp(ptr1->name,destfile,strlen(destfile)+1) == 
0) && (strncmp(ptr1->classes,ip->classes,strlen(ip->classes)+1) == 0))
                           {
                           succeed = 0;
                           }
@@ -1150,11 +1150,11 @@
       succeed = 1;
       for (ptr = VSINGLECOPY; ptr != NULL; ptr=ptr->next)
           {
-          if (strncmp(ptr->classes,ip->classes,strlen(ip->classes)) == 0)
+          if (strncmp(ptr->classes,ip->classes,strlen(ip->classes)+1) == 0)
              {
              for (ptr1 = VEXCLUDECACHE; ptr1 != NULL; ptr1=ptr1->next)
                  {
-                 if ((strncmp(ptr1->name,destfile,strlen(destfile)) == 0) && 
(strncmp(ptr1->classes,ip->classes,strlen(ip->classes)) == 0))
+                 if ((strncmp(ptr1->name,destfile,strlen(destfile)+1) == 0) && 
(strncmp(ptr1->classes,ip->classes,strlen(ip->classes)+1) == 0))
                     {
                     succeed = 0;
                     }




reply via email to

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