summaryrefslogtreecommitdiffstats
path: root/lib/puppet/provider
diff options
context:
space:
mode:
authorNick Lewis <nick@puppetlabs.com>2011-08-16 11:45:55 -0700
committerNick Lewis <nick@puppetlabs.com>2011-08-16 11:45:55 -0700
commit66d852bb2c2b66ff5e7c9966fdb510e2edd529db (patch)
treec5e682eda7956676f43091927723842c76f6802d /lib/puppet/provider
parent39116d4a6ed4861e46b16ba26c679a8b346fca00 (diff)
parent1049458461b5ec5e1e48ad0244d63eb24626b09d (diff)
downloadpuppet-66d852bb2c2b66ff5e7c9966fdb510e2edd529db.tar.gz
puppet-66d852bb2c2b66ff5e7c9966fdb510e2edd529db.tar.xz
puppet-66d852bb2c2b66ff5e7c9966fdb510e2edd529db.zip
Merge branch '2.7.x'
Conflicts: lib/puppet/provider/augeas/augeas.rb spec/unit/node_spec.rb
Diffstat (limited to 'lib/puppet/provider')
-rw-r--r--lib/puppet/provider/exec/posix.rb32
1 files changed, 16 insertions, 16 deletions
diff --git a/lib/puppet/provider/exec/posix.rb b/lib/puppet/provider/exec/posix.rb
index 157d0f28d..782f1eac6 100644
--- a/lib/puppet/provider/exec/posix.rb
+++ b/lib/puppet/provider/exec/posix.rb
@@ -76,26 +76,26 @@ Puppet::Type.type(:exec).provide :posix do
def checkexe(command)
exe = extractexe(command)
- if resource[:path]
- if Puppet.features.posix? and !File.exists?(exe)
- withenv :PATH => resource[:path].join(File::PATH_SEPARATOR) do
- exe = which(exe) || raise(ArgumentError,"Could not find command '#{exe}'")
- end
- elsif Puppet.features.microsoft_windows? and !File.exists?(exe)
- resource[:path].each do |path|
- [".exe", ".ps1", ".bat", ".com", ""].each do |extension|
- file = File.join(path, exe+extension)
- return if File.exists?(file)
- end
- end
+ if File.expand_path(exe) == exe
+ if !File.exists?(exe)
+ raise ArgumentError, "Could not find command '#{exe}'"
+ elsif !File.file?(exe)
+ raise ArgumentError, "'#{exe}' is a #{File.ftype(exe)}, not a file"
+ elsif !File.executable?(exe)
+ raise ArgumentError, "'#{exe}' is not executable"
end
+ return
end
- raise ArgumentError, "Could not find command '#{exe}'" unless File.exists?(exe)
- unless File.executable?(exe)
- raise ArgumentError,
- "'#{exe}' is not executable"
+ if resource[:path]
+ withenv :PATH => resource[:path].join(File::PATH_SEPARATOR) do
+ return if which(exe)
+ end
end
+
+ # 'which' will only return the command if it's executable, so we can't
+ # distinguish not found from not executable
+ raise ArgumentError, "Could not find command '#{exe}'"
end
def extractexe(command)