bug-cfengine
[Top][All Lists]
Advanced

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

[CORRECTED] fix for copy symlink bugs I recently reported in cfengine 2.


From: Joe Ramey
Subject: [CORRECTED] fix for copy symlink bugs I recently reported in cfengine 2.0.3
Date: Thu, 11 Jul 2002 15:04:05 -0500 (CDT)

[I sent this in yesterday but I just found I had a misplaced curly
brace.  Here's a corrected version of the patch.]

I recently reported two instances in which cfengine 2.0.3 does not
handle symlinks the way I would expect.  For one, when asked to copy a
file onto a symlink but the -n option is set, cfagent goes ahead and
removes the symlink (apparently ignoring -n).  The second bug is that,
when -n is not in use, cfagent will remove the symlink and copy the
regular file in place whether or not typecheck is set.  Seems to me
that typecheck=true should prevent this from occurring.

The following change to image.c seems to fix both of these problems
for me.

*** src/image.c.ORIG    Sun Jun 23 11:31:03 2002
--- src/image.c Thu Jul 11 15:00:44 2002
***************
*** 685,690 ****
--- 685,702 ----
     {
     if ((S_ISLNK(deststatbuf.st_mode) && (ip->linktype == 'n')) || 
(S_ISLNK(deststatbuf.st_mode)  && ! S_ISLNK(sourcestatbuf.st_mode)))
        {
+       if (!S_ISLNK(sourcestatbuf.st_mode) && (ip->typecheck == 'y'))
+          {
+          printf("%s: image exists but destination type is silly 
(file/dir/link doesn't match)\n",VPREFIX);
+        printf("%s: source=%s, dest=%s\n",VPREFIX,sourcefile,destfile);
+        return;
+          }
+       if (DONTDO)
+          {
+          Verbose("Need to remove old symbolic link %s to make way for 
copy\n",destfile);
+          }
+       else 
+          {
           if (unlink(destfile) == -1)
            {
            snprintf(OUTPUT,bufsize*2,"Couldn't remove link %s",destfile);
***************
*** 695,700 ****
--- 707,713 ----
           found = -1;
           }
        }
+    }
  
  if (ip->size != cfnosize)
     {



reply via email to

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