lib/puppet/util.rb in puppet-0.24.5 vs lib/puppet/util.rb in puppet-0.24.6
- old
+ new
@@ -218,23 +218,22 @@
end
end
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
+ x = %x{which #{bin} 2>/dev/null}.chomp
+ if x == ""
+ return nil
+ else
+ return x
end
- return nil
end
end
module_function :binary
# Execute the provided command in a pipe, yielding the pipe object.
@@ -319,9 +318,10 @@
Process.setsid
begin
$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"
end
if arguments[:uid]