diff options
author | Nigel Kersten <nigelk@google.com> | 2008-12-04 13:08:16 -0800 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2008-12-06 12:04:29 +1100 |
commit | c4412ec90c7ac4fecc49bbb632a0c4e84efb2ad4 (patch) | |
tree | c794c95eed9409cab41740bb3fdf2fa347f327d3 | |
parent | 7de82c387b29b0c9202e35d680f109407c07faa7 (diff) | |
download | puppet-c4412ec90c7ac4fecc49bbb632a0c4e84efb2ad4.tar.gz puppet-c4412ec90c7ac4fecc49bbb632a0c4e84efb2ad4.tar.xz puppet-c4412ec90c7ac4fecc49bbb632a0c4e84efb2ad4.zip |
add some more sanity checks around stdin
-rw-r--r-- | lib/puppet/util.rb | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb index b07b2dfec..a5f3c5b1a 100644 --- a/lib/puppet/util.rb +++ b/lib/puppet/util.rb @@ -268,7 +268,10 @@ module Util # Execute the desired command, and return the status and output. # def execute(command, failonfail = true, uid = nil, gid = nil) - def execute(command, arguments = {:failonfail => true, :combine => true, :stdin => "/dev/null"}) + # :combine sets whether or not to combine stdout/stderr in the output + # :stdinfile sets a file that can be used for stdin. Passing a string + # for stdin is not currently supported. + def execute(command, arguments = {:failonfail => true, :combine => true}) if command.is_a?(Array) command = command.flatten.collect { |i| i.to_s } str = command.join(" ") @@ -321,7 +324,11 @@ module Util # Child process executes this Process.setsid begin - $stdin.reopen(arguments[:stdin]) + if arguments[:stdinfile] + $stdin.reopen(arguments[:stdinfile]) + else + $stdin.reopen("/dev/null") + end $stdout.reopen(output_file) $stderr.reopen(error_file) @@ -466,4 +473,3 @@ require 'puppet/util/execution' require 'puppet/util/logging' require 'puppet/util/package' require 'puppet/util/warnings' - |