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

Ability to discard moved obstructions

    XMLWordPrintable

    Details

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

      Description

      Currently, files promises can move_obstructions out of the way if the wrong file type is encountered (expecting plain file vs directory or vice versa). When enabled obstructions are moved out of the way and suffixed with .cf-moved. It would be nice if it were possible to simply discard obstructions.

      Discarding moved obstructions requires a separate files promise

      mkdir -p /tmp/mail/ 
      rm -rf /tmp/mail/*  
      touch /tmp/mail/mbox1 /tmp/mail/mbox2 /tmp/mail/mbox3
      ls /tmp/mail
      
      mbox1
      mbox2
      mbox3

      Here we promise to delete any .cf-moved suffixed files just after we promised the presence of directories and moving obstructions.

      bundle agent example
      {
       vars:
            "files_or_dirs"
              slist => findfiles( "/tmp/mail/*" );
      
        reports:
            "$(files_or_dirs)";
      
        files:
            # What's wrong with this?
            "$(files_or_dirs)/"
              create => "true",
              move_obstructions => "true";
      
            "$(files_or_dirs).cf-moved"
              comment => "Discard obstructions that were moved out of the way",
              delete => tidy;
      }
      
      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: Deleted file '/tmp/mail/mbox1.cf-moved'
          info: Deleted file '/tmp/mail/mbox2.cf-moved'
          info: Deleted file '/tmp/mail/mbox3.cf-moved'
      R: /tmp/mail/mbox1
      R: /tmp/mail/mbox2
      R: /tmp/mail/mbox3
         error: Method 'example' failed in some repairs
      
      find /tmp/mail -type f
      
      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