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

The location where moved obstructions are stored should be configurable

    XMLWordPrintable

    Details

    • Type: Story
    • Status: Open
    • Priority: (None)
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      Currently, when obstructions are encountered by files promsies that have move_obstructions enabled, the obstructions are renamed to have a .cf-moved suffix. It would be nice if the location where obstructions are preserved could be configured (like default_repository which works for backups of edited or copied files). Perhaps this is a BUG since default_repository does not take effect.

      Currently, since there is no ability to discard moved obstructions, a separate files promise is required.

      How can I discard moved obstructions?

      default_repository does not affect move_obstructions

      With default_repository in body agent control set to /tmp/obstructions, obstructions are still renamed with a -moved extension.

      mkdir -p /tmp/mail/ 
      rm -rf /tmp/mail/*  
      touch /tmp/mail/mbox1 /tmp/mail/mbox2 /tmp/mail/mbox3
      ls /tmp/mail
      
      mbox1
      mbox2
      mbox3
      body agent control
      {
            default_repository => "/tmp/obstructions";
      }
      bundle agent example
      {
       vars:
            "files_or_dirs"
              slist => findfiles( "/tmp/mail/*" );
      
        reports:
            "$(files_or_dirs)";
      
        files:
            "$(files_or_dirs)/"
              create => "true",
              move_obstructions => "true";
      }
      
      bundle agent __main__
      {
        methods: "example";
      
      }
      
          info: Moving obstructing file/link /tmp/mail/mbox1 to /tmp/mail/mbox1.cf-moved to make directory
         error: Error creating file '/tmp/mail/mbox1/', mode '0600'. (open: 'File exists'). Most likely a dangling symlink is in the way. Refusing to create the target file of dangling symlink (security risk).
          info: Moving obstructing file/link /tmp/mail/mbox2 to /tmp/mail/mbox2.cf-moved to make directory
         error: Error creating file '/tmp/mail/mbox2/', mode '0600'. (open: 'File exists'). Most likely a dangling symlink is in the way. Refusing to create the target file of dangling symlink (security risk).
          info: Moving obstructing file/link /tmp/mail/mbox3 to /tmp/mail/mbox3.cf-moved to make directory
         error: Error creating file '/tmp/mail/mbox3/', mode '0600'. (open: 'File exists'). Most likely a dangling symlink is in the way. Refusing to create the target file of dangling symlink (security risk).
      R: /tmp/mail/mbox1
      R: /tmp/mail/mbox2
      R: /tmp/mail/mbox3
          info: Moving obstructing file/link /tmp/mail/mbox1.cf-moved to /tmp/mail/mbox1.cf-moved.cf-moved to make directory
         error: Error creating file '/tmp/mail/mbox1.cf-moved/', mode '0600'. (open: 'File exists'). Most likely a dangling symlink is in the way. Refusing to create the target file of dangling symlink (security risk).
          info: Moving obstructing file/link /tmp/mail/mbox2.cf-moved to /tmp/mail/mbox2.cf-moved.cf-moved to make directory
         error: Error creating file '/tmp/mail/mbox2.cf-moved/', mode '0600'. (open: 'File exists'). Most likely a dangling symlink is in the way. Refusing to create the target file of dangling symlink (security risk).
          info: Moving obstructing file/link /tmp/mail/mbox3.cf-moved to /tmp/mail/mbox3.cf-moved.cf-moved to make directory
         error: Error creating file '/tmp/mail/mbox3.cf-moved/', mode '0600'. (open: 'File exists'). Most likely a dangling symlink is in the way. Refusing to create the target file of dangling symlink (security risk).
      R: /tmp/mail/mbox1.cf-moved
      R: /tmp/mail/mbox2.cf-moved
      R: /tmp/mail/mbox3.cf-moved
          info: Moving obstructing file/link /tmp/mail/mbox1.cf-moved.cf-moved to /tmp/mail/mbox1.cf-moved.cf-moved.cf-moved to make directory
         error: Error creating file '/tmp/mail/mbox1.cf-moved.cf-moved/', mode '0600'. (open: 'File exists'). Most likely a dangling symlink is in the way. Refusing to create the target file of dangling symlink (security risk).
          info: Moving obstructing file/link /tmp/mail/mbox2.cf-moved.cf-moved to /tmp/mail/mbox2.cf-moved.cf-moved.cf-moved to make directory
         error: Error creating file '/tmp/mail/mbox2.cf-moved.cf-moved/', mode '0600'. (open: 'File exists'). Most likely a dangling symlink is in the way. Refusing to create the target file of dangling symlink (security risk).
          info: Moving obstructing file/link /tmp/mail/mbox3.cf-moved.cf-moved to /tmp/mail/mbox3.cf-moved.cf-moved.cf-moved to make directory
         error: Error creating file '/tmp/mail/mbox3.cf-moved.cf-moved/', mode '0600'. (open: 'File exists'). Most likely a dangling symlink is in the way. Refusing to create the target file of dangling symlink (security risk).
      R: /tmp/mail/mbox1.cf-moved.cf-moved
      R: /tmp/mail/mbox2.cf-moved.cf-moved
      R: /tmp/mail/mbox3.cf-moved.cf-moved
         error: Method 'example' failed in some repairs
      

      Find the plain files:

      find /tmp/mail -type f
      
      /tmp/mail/mbox3.cf-moved.cf-moved.cf-moved
      /tmp/mail/mbox1.cf-moved.cf-moved.cf-moved
      /tmp/mail/mbox2.cf-moved.cf-moved.cf-moved

      Find the directories:

      find /tmp/mail -type d
      
      /tmp/mail
      /tmp/mail/mbox1.cf-moved
      /tmp/mail/mbox2.cf-moved.cf-moved
      /tmp/mail/mbox2.cf-moved
      /tmp/mail/mbox3.cf-moved.cf-moved
      /tmp/mail/mbox1
      /tmp/mail/mbox1.cf-moved.cf-moved
      /tmp/mail/mbox3.cf-moved
      /tmp/mail/mbox2
      /tmp/mail/mbox3
      
      /tmp/mail
      /tmp/mail/mbox1.cf-moved
      /tmp/mail/mbox2.cf-moved.cf-moved
      /tmp/mail/mbox2.cf-moved
      /tmp/mail/mbox3.cf-moved.cf-moved
      /tmp/mail/mbox1
      /tmp/mail/mbox1.cf-moved.cf-moved
      /tmp/mail/mbox3.cf-moved
      /tmp/mail/mbox2
      /tmp/mail/mbox3
      

      In order to discard the moved obstructions, a separate files promise must be made.

      .cf-move suffixed files could be transformed

      With default_repository in body agent control set to /tmp/obstructions, obstructions are still renamed with a -moved extension.

      mkdir -p /tmp/mail/ 
      rm -rf /tmp/mail/*  
      touch /tmp/mail/mbox1 /tmp/mail/mbox2 /tmp/mail/mbox3
      ls /tmp/mail
      
      mbox1
      mbox2
      mbox3
      bundle agent example
      {
       vars:
            "files_or_dirs"
              slist => findfiles( "/tmp/mail/*" );
      
        reports:
            "$(files_or_dirs)";
      
        files:
      
            # Only directories should exist, move files out of the way
            "$(files_or_dirs)/"
              create => "true",
              move_obstructions => "true";
      
            # Move the obstructions out to some other backup location 
            "$(files_or_dirs).cf-moved"
              transformer => "/bin/mv $(this.promiser) /tmp/obstructions/";
      }
      
      bundle agent __main__
      {
        methods: "example";
      
      }
      
          info: Moving obstructing file/link /tmp/mail/mbox1 to /tmp/mail/mbox1.cf-moved to make directory
         error: Error creating file '/tmp/mail/mbox1/', mode '0600'. (open: 'File exists'). Most likely a dangling symlink is in the way. Refusing to create the target file of dangling symlink (security risk).
          info: Moving obstructing file/link /tmp/mail/mbox2 to /tmp/mail/mbox2.cf-moved to make directory
         error: Error creating file '/tmp/mail/mbox2/', mode '0600'. (open: 'File exists'). Most likely a dangling symlink is in the way. Refusing to create the target file of dangling symlink (security risk).
          info: Moving obstructing file/link /tmp/mail/mbox3 to /tmp/mail/mbox3.cf-moved to make directory
         error: Error creating file '/tmp/mail/mbox3/', mode '0600'. (open: 'File exists'). Most likely a dangling symlink is in the way. Refusing to create the target file of dangling symlink (security risk).
          info: Transforming '/bin/mv /tmp/mail/mbox1.cf-moved /tmp/obstructions/' 
          info: Transformer '/tmp/mail/mbox1.cf-moved' => '/bin/mv /tmp/mail/mbox1.cf-moved /tmp/obstructions/' seemed to work ok
          info: Transforming '/bin/mv /tmp/mail/mbox2.cf-moved /tmp/obstructions/' 
          info: Transformer '/tmp/mail/mbox2.cf-moved' => '/bin/mv /tmp/mail/mbox2.cf-moved /tmp/obstructions/' seemed to work ok
          info: Transforming '/bin/mv /tmp/mail/mbox3.cf-moved /tmp/obstructions/' 
          info: Transformer '/tmp/mail/mbox3.cf-moved' => '/bin/mv /tmp/mail/mbox3.cf-moved /tmp/obstructions/' seemed to work ok
      R: /tmp/mail/mbox1
      R: /tmp/mail/mbox2
      R: /tmp/mail/mbox3
         error: Method 'example' failed in some repairs
      

      Find the plain files:

      find /tmp/mail -type f
      

      Find the old obstructions:

      find /tmp/obstructions -type f
      
      /tmp/obstructions/mbox1.cf-moved
      /tmp/obstructions/mbox2.cf-moved
      /tmp/obstructions/mbox3.cf-moved

      Find the directories:

      find /tmp/mail -type d
      
      /tmp/mail
      /tmp/mail/mbox1
      /tmp/mail/mbox2
      /tmp/mail/mbox3

      In order to discard the moved obstructions, a separate files promise must be made.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                a10042 Nick Anderson
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:

                  Summary Panel