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

fileexists() returns class on broken link

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Done
    • Priority: Low
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.12.0, 3.10.4
    • Component/s: Documentation
    • Labels:
      None

      Description

      Resolution

      Reported behaviour for fileexists() returning true on a broken symlink is as designed.

      Documentation updated in master, 3.10.x, and 3.7.x to include behaviour note and methodologies for determining if a symlink is broken.

      Reported Issue

      fileexists() returns a class on broken link

      Reported Expectation

      fileexists() would behave similarly to test.

      Manual Testing

      [root@vsie1d085 ~]# ln -s /tmp/non /tmp/dest
      [root@vsie1d085 ~]# [ -f /tmp/dest ] && echo Y || echo N
      N
      [root@vsie1d085 ~]# [ -x /tmp/dest ] && echo Y || echo N
      N
      [root@vsie1d085 ~]# [ -e /tmp/dest ] && echo Y || echo N
      N
      [root@vsie1d085 ~]# [ -L /tmp/dest ] && echo Y || echo N
      Y
      

      Here's the cfengine's behaviour:

      [root@vsie1d085 ~]# cat /tmp/test1.cf
      bundle agent test {
              classes:
                      "exists" expression => fileexists("/tmp/dest");
                      "executable" expression => isexecutable("/tmp/dest");
                      "link" expression => islink("/tmp/dest");
                      "file" expression => isplain("/tmp/dest");
              reports:
                      cfengine::
                      "File exists" ifvarclass => "exists";
                      "File is executable" ifvarclass => "executable";
                      "File is a link" ifvarclass =>  "link";
                      "File is a plain file" ifvarclass => "file";
      }
      
      [root@vsie1d085 ~]# cf-agent -Kf /tmp/test1.cf -b test
      Proposed executable file "/tmp/dest" doesn't exist
      Proposed executable file "/tmp/dest" doesn't exist
      Proposed executable file "/tmp/dest" doesn't exist
      R: File exists
      R: File is a link
      Proposed executable file "/tmp/dest" doesn't exist
      Proposed executable file "/tmp/dest" doesn't exist
      

      Error message thrown by isexecutable() as noted in CFE-741 is related.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel