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

isexecutable() throws errrors on broken links

    XMLWordPrintable

    Details

      Description

      isexecutable() throws errors when checking broken link. Here is example code:

      [root@li488-19 ~]# cat /tmp/test.cf
      bundle agent test {
          classes:
              "e" expression => isexecutable("/tmp/broken_link");
      }
      

      The output:

      [root@li488-19 ~]# ln -s /tmp/none /tmp/broken_link
      [root@li488-19 ~]# cf-agent -Kf /tmp/test.cf -b test
      2013-06-17T07:43:22+0000    error: Proposed executable file '/tmp/broken_link' doesn't exist
      2013-06-17T07:43:22+0000    error: Proposed executable file '/tmp/broken_link' doesn't exist
      2013-06-17T07:43:22+0000    error: Proposed executable file '/tmp/broken_link' doesn't exist
      2013-06-17T07:43:22+0000    error: Proposed executable file '/tmp/broken_link' doesn't exist
      2013-06-17T07:43:22+0000    error: Proposed executable file '/tmp/broken_link' doesn't exist
      

      To compare with, /bin/test just returns false for this file:

      [root@li488-19 ~]# test -x /tmp/broken_link || echo N
      N
      

      Workaround

      bundle agent main
      {
        classes:
          "missing_symlink_isexecutable"
            expression => isexecutable( "/tmp/ln-missing" ),
            # If the symlink is borken you will get an error.
            # You can further restrict the promise to when the symlink target exists
            if => fileexists( filestat("/tmp/ln-missing", "linktarget" ));
      
            "symlink_isexecutable"
              expression => isexecutable( "/tmp/ln-true" );
      
        reports:
            missing_symlink_isexecutable::
              "ERROR a broken symlink is not executable";
      
            symlink_isexecutable::
              "symlink to executable";
      }
      

      With fileexists filestat linktarget restriction:

      R: symlink to executable
      

      Without fileexists filestat linktarget restriction:

         error: Proposed executable file '/tmp/ln-missing' doesn't exist
         error: Proposed executable file '/tmp/ln-missing' doesn't exist
      R: symlink to executable
         error: Proposed executable file '/tmp/ln-missing' doesn't exist
         error: Proposed executable file '/tmp/ln-missing' doesn't exist
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                olehermanse Ole Herman Schumacher Elgesem
                Reporter:
                ipesin Ivan Pesin
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Summary Panel