If I have a promise with a copy_from promise where the body specifies that permissions should be preserved and I also have a perms body on the same promise what is expected to happen?

The files type promises documentation describes the normal order of files promise attributes during promise actuation.

The documentation notes:

  1. file presence ( create | copy | link )
  2. permissions
  3. file content

So the explicitly specified permissions should win in the end. Here is a small example illustrating the behavior of a copy_from body that is preserving permissions when combined with perms body specifying explicit permissions.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
  bundle agent main
  {
    files:
      "$(this.promise_filename).copy_preserve_and_perms"    
        copy_from => perms_dcp( $(this.promise_filename) ),
        perms => m( 777 );

      "$(this.promise_filename).copy_preserve"    
        copy_from => perms_dcp( $(this.promise_filename) );

    reports:
      "CFEngine $(sys.cf_version)";

      "$(this.promise_filename) mode = $(with)" 
        with => filestat( $(this.promise_filename), permoct );

      "$(this.promise_filename).copy_preserve mode = $(with)" 
        with => filestat( "$(this.promise_filename).copy_preserve", permoct );
      
      "$(this.promise_filename).copy_preserve_and_perms mode = $(with)" 
        with => filestat( "$(this.promise_filename).copy_preserve_and_perms", permoct );
  }

Results in this output:

R: CFEngine 3.11.0
R: /home/nickanderson/org/cfengine3-8600Hlr mode = 600
R: /home/nickanderson/org/cfengine3-8600Hlr.copy_preserve mode = 600
R: /home/nickanderson/org/cfengine3-8600Hlr.copy_preserve_and_perms mode = 777