Uploaded image for project: 'CFEngine Community'
  1. CFEngine Community
  2. CFE-2216

files converted to directories are not changed back on later recursive copy

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open
    • Priority: High
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Promise type: files
    • Labels:
      None
    • Platform:
      RHEL or CentOS
    • Found in version (details):
      3.7.2 (nightly build 80)
    • Steps to reproduce:
      Manual steps provided

      Description

      As a result of bugs like #6027, some files which are supposed to be copied down by CFEngine are created as (or converted to) directories. Unfortunately, they are never changed back - once a file is a directory, CFEngine happily leaves it that way while reporting that all is well. I have this happen with remote copies, but it apparently affects local copies as well.

      Here are the steps to reproduce, demonstrating a successful copy if the files aren't there, and a failure to replace an existing directory with a file.

      <pre>
      user@host [/home/user]
      $ mkdir -p /tmp/src
      user@host [/home/user]
      $ touch /tmp/src/file

      {1,2}
      user@host [/home/user]
      $ mkdir -p /tmp/src/dir{1,2}

      user@host [/home/user]
      $ cat ./test.cf
      bundle agent test {
      files:
      "/tmp/dst/"
      copy_from => tst,
      move_obstructions => "true",
      depth_search => recurse("inf");
      }

      body depth_search recurse(d) {
      depth => "$(d)";
      xdev => "true";
      }

      body copy_from tst {
      source => "/tmp/src";
      compare => "digest";
      }
      user@host [/home/user]
      $ sudo cf-agent -lIKf ./test.cf -b test
      2015-11-30T17:45:37-0600 info: Using command line specified bundlesequence
      2015-11-30T17:45:37-0600 info: Copying from 'localhost:/tmp/src/file2'
      2015-11-30T17:45:37-0600 info: Copying from 'localhost:/tmp/src/file1'
      user@host [/home/user]
      $ ls -la /tmp/dst
      total 16
      drwxr-xr-x 4 root root 4096 Nov 30 17:45 .
      drwxrwxrwt. 18 root root 4096 Nov 30 17:45 ..
      drwx------ 2 root root 4096 Nov 30 17:45 dir1
      drwx------ 2 root root 4096 Nov 30 17:45 dir2
      rw-r---- 1 root root 0 Nov 30 17:45 file1
      rw-r---- 1 root root 0 Nov 30 17:45 file2
      user@host [/home/user]
      $ sudo cf-agent -ldKf ./test.cf -b test | grep file1
      2015-11-30T17:46:06-0600 verbose: Destination file '/tmp/dst/file1' already exists
      2015-11-30T17:46:06-0600 verbose: File permissions on '/tmp/dst/file1' as promised
      2015-11-30T17:46:06-0600 verbose: File '/tmp/dst/file1' is an up to date copy of source
      user@host [/home/user]
      $ sudo rm /tmp/dst/file1 && sudo mkdir -p /tmp/dst/file1
      user@host [/home/user]
      $ ls -la /tmp/dst
      total 20
      drwxr-xr-x 5 root root 4096 Nov 30 17:46 .
      drwxrwxrwt. 18 root root 4096 Nov 30 17:46 ..
      drwx------ 2 root root 4096 Nov 30 17:45 dir1
      drwx------ 2 root root 4096 Nov 30 17:45 dir2
      drwxr-x--- 2 root root 4096 Nov 30 17:46 file1
      rw-r---- 1 root root 0 Nov 30 17:45 file2
      user@host [/home/user]
      $ sudo cf-agent -ldKf ./test.cf -b test | grep file1
      2015-11-30T17:46:25-0600 verbose: Destination file '/tmp/dst/file1' already exists
      2015-11-30T17:46:25-0600 verbose: File permissions on '/tmp/dst/file1' as promised
      2015-11-30T17:46:25-0600 verbose: File '/tmp/dst/file1' is an up to date copy of source
      user@host [/home/user]
      $ ls -la /tmp/dst
      total 20
      drwxr-xr-x 5 root root 4096 Nov 30 17:46 .
      drwxrwxrwt. 18 root root 4096 Nov 30 17:46 ..
      drwx------ 2 root root 4096 Nov 30 17:45 dir1
      drwx------ 2 root root 4096 Nov 30 17:45 dir2
      drwxr-x--- 2 root root 4096 Nov 30 17:46 file1
      rw-r---- 1 root root 0 Nov 30 17:45 file2
      user@host [/home/user]
      $ ls -la /tmp/src/
      total 16
      drwxr-x--- 4 q0px usec_pm 4096 Nov 30 17:36 .
      drwxrwxrwt. 18 bin bin 4096 Nov 30 17:56 ..
      drwxr-x--- 2 q0px usec_pm 4096 Nov 30 17:36 dir1
      drwxr-x--- 2 q0px usec_pm 4096 Nov 30 17:36 dir2
      rw-r---- 1 q0px usec_pm 0 Nov 30 17:36 file1
      rw-r---- 1 q0px usec_pm 0 Nov 30 17:36 file2
      </pre>

      Here also are the extra debug lines around the file1 comparison:

      <pre>
      verbose: File '/tmp/dst/file2' is an up to date copy of source
      verbose: Destination file '/tmp/dst/file1' already exists
      verbose: Checksum comparison replaced by ctime: files not regular
      debug: Directory...fixing x bits
      debug: File okay, newperm '750', stat '750'
      verbose: Additional promise info: source path './test.cf' at line 3
      verbose: File permissions on '/tmp/dst/file1' as promised
      verbose: Additional promise info: source path './test.cf' at line 3
      verbose: File '/tmp/dst/file1' is an up to date copy of source
      debug: Filename '/tmp/src/..' is classified as ignorable
      verbose: Entering '/tmp/dst/dir2'
      </pre>

        Attachments

          Activity

            People

            • Assignee:
              a10003 Eystein Maloy Stenberg
              Reporter:
              dannysauer Danny Sauer
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:

                Summary Panel