about summary refs log tree commit homepage
path: root/extras
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2014-04-20 22:53:43 +0000
committerEric Wong <normalperson@yhbt.net>2014-04-21 01:24:56 +0000
commit0432c84f14dc900a1ec0e9e9ccb66a9267437fb3 (patch)
tree49a185cfa81b2deffba67142805ecea977770315 /extras
parent95975647c0759f1c141c8627a2826fa8c706258d (diff)
downloadyahns-0432c84f14dc900a1ec0e9e9ccb66a9267437fb3.tar.gz
Sometimes a CGI script wants to run with some environment
variables set or overridden.  Allow it.
Diffstat (limited to 'extras')
-rw-r--r--extras/exec_cgi.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/extras/exec_cgi.rb b/extras/exec_cgi.rb
index 5eadef8..f718f7b 100644
--- a/extras/exec_cgi.rb
+++ b/extras/exec_cgi.rb
@@ -65,6 +65,7 @@ class ExecCgi
   ).map(&:freeze)  # frozen strings are faster for Hash assignments
 
   def initialize(*args)
+    @env = Hash === args[0] ? args.shift : {}
     @args = args
     first = args[0] or
       raise ArgumentError, "need path to executable"
@@ -80,7 +81,7 @@ class ExecCgi
     env.each { |key,val| cgi_env[key] = val if key =~ /\AHTTP_/ }
     pipe = MyIO.pipe
     errbody = pipe[0]
-    errbody.my_pid = Process.spawn(cgi_env, *@args,
+    errbody.my_pid = Process.spawn(cgi_env.merge!(@env), *@args,
                                    out: pipe[1], close_others: true)
     pipe[1].close
     pipe = pipe[0]