diff options
author | Jerome Charaoui <jcharaoui@cmaisonneuve.qc.ca> | 2015-03-02 15:39:50 +0000 |
---|---|---|
committer | Jerome Charaoui <jcharaoui@cmaisonneuve.qc.ca> | 2015-03-02 15:39:50 +0000 |
commit | 3ae2ea930dfb5134e5fe6f946ecc658aacb2da04 (patch) | |
tree | 2adf57c2bc189eb06a35420176d10e723b166eaa | |
parent | f87223c4cbd6445010b7189f06b043286c3b1958 (diff) | |
parent | 92569fe8cf9770fde6a5e2bde79ad2f5978e0224 (diff) |
Merge branch 'master' into 'master'
Don't screw up ENV["PATH"] for other platforms
Minor bugfix to prevent overriding ENV["PATH"] for non-Linux platforms.
See merge request !1
-rw-r--r-- | lib/facter/mountpoints.rb | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/facter/mountpoints.rb b/lib/facter/mountpoints.rb index c51e6e6..da2f2a9 100644 --- a/lib/facter/mountpoints.rb +++ b/lib/facter/mountpoints.rb @@ -12,21 +12,23 @@ begin require 'filesystem' rescue Exception => e confine :kernel => :linux - ENV["PATH"]="/bin:/sbin:/usr/bin:/usr/sbin" - fs_source = nil - if FileTest.exists?("/etc/mtab") - fs_source = "/etc/mtab" - elsif FileTest.exists?("/proc/mounts") - fs_source = "/proc/mounts" - end + setcode do + ENV["PATH"]="/bin:/sbin:/usr/bin:/usr/sbin" + fs_source = nil + if FileTest.exists?("/etc/mtab") + fs_source = "/etc/mtab" + elsif FileTest.exists?("/proc/mounts") + fs_source = "/proc/mounts" + end - mounts = File.read(fs_source).split("\n") - mounts.each do |mount| - mount = mount.split(" ") - if ((not ignorefs.include?(mount[2])) && (mount[3] !~ /bind/) && (not devices.include?(mount[0])) && (not mountpoints.include?(mount[1]))) - mountpoints.push(mount[1]) + mounts = File.read(fs_source).split("\n") + mounts.each do |mount| + mount = mount.split(" ") + if ((not ignorefs.include?(mount[2])) && (mount[3] !~ /bind/) && (not devices.include?(mount[0])) && (not mountpoints.include?(mount[1]))) + mountpoints.push(mount[1]) + end + devices.push(mount[0]) if not devices.include?(mount[0]) end - devices.push(mount[0]) if not devices.include?(mount[0]) end else FileSystem.mounts.each do |m| |