summaryrefslogtreecommitdiffstats
path: root/lib/puppet/util.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet/util.rb')
-rw-r--r--lib/puppet/util.rb12
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb
index 94c96db0c..d6de3e2e1 100644
--- a/lib/puppet/util.rb
+++ b/lib/puppet/util.rb
@@ -220,19 +220,14 @@ module Util
def binary(bin)
if bin =~ /^\//
- if FileTest.exists? bin
+ if FileTest.file? bin and FileTest.executable? bin
return bin
else
return nil
end
else
- # LAK:NOTE See http://snurl.com/21zf8 [groups_google_com]
- x = ENV['PATH'].split(":").each do |dir|
- if FileTest.exists? File.join(dir, bin)
- return File.join(dir, bin)
- end
- end
- return nil
+ x = %x{which #{bin} 2>/dev/null}.chomp
+ return x
end
end
module_function :binary
@@ -321,6 +316,7 @@ module Util
$stdin.reopen("/dev/null")
$stdout.reopen(output_file)
$stderr.reopen(output_file)
+ 3.upto(256){|fd| IO::new(fd).close rescue nil}
if arguments[:gid]
Process.egid = arguments[:gid]
Process.gid = arguments[:gid] unless @@os == "Darwin"