Uploaded image for project: 'Facter'
  1. Facter
  2. FACT-1286

Facter::Util::Resolution.which() returns directories, not only executable files

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Normal
    • Resolution: Fixed
    • Affects Version/s: FACT 2.4.4
    • Fix Version/s: FACT 2.4.5
    • Component/s: Community
    • Labels:
      None
    • Template:
    • Story Points:
      1
    • Sprint:
      Client 2015-12-30
    • Release Notes:
      Bug Fix
    • Release Notes Summary:
      `Facter::Util::Resolution.which` no longer returns a directory if a directory with a matching name is found earlier in the PATH than an executable file with a matching name.

      Description

      Environment:

      $ echo $PATH
      /usr/java/default/bin:/sbin:/bin:/usr/sbin:/usr/bin
       
      $ PATH=/tmp:$PATH
       
      $ echo $PATH
      /tmp:/usr/java/default/bin:/sbin:/bin:/usr/sbin:/usr/bin
       
      $ mkdir /tmp/ifconfig
      

      Expected behavior:

      $ which ifconfig
      /sbin/ifconfig
       
      $ irb
      irb(main):001:0> require 'facter'
      => true
      irb(main):002:0> Facter::Util::Resolution.which('ifconfig')
      => "/sbin/ifconfig"
      

      Actual behavior:

      $ which ifconfig
      /sbin/ifconfig
       
      $ irb
      irb(main):001:0> require 'facter'
      => true
      irb(main):002:0> Facter::Util::Resolution.which('ifconfig')
      => "/tmp/ifconfig"
      

      This appears to be caused by the fact that Ruby's 'File.executable?' method returns true for directories.

        Attachments

          Activity

            jsd-sla-details-panel

              People

              • Assignee:
                Unassigned
                Reporter:
                p8952 Peter Wilmott
                QA Contact:
                Eric Thompson
              • Votes:
                0 Vote for this issue
                Watchers:
                1 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:

                  Zendesk Support