diff options
author | Senthil Kumaran <orsenthil@gmail.com> | 2010-10-03 17:55:45 (GMT) |
---|---|---|
committer | Senthil Kumaran <orsenthil@gmail.com> | 2010-10-03 17:55:45 (GMT) |
commit | 4271372a7145fe4a8e44982e5b89c3c7e3637c8e (patch) | |
tree | eeaa60b3b19d3c402220f3f7609bff6c860d9c87 /Lib/http | |
parent | 388f956c35d335446c4715c8f2c28631f3c54ab1 (diff) | |
download | cpython-4271372a7145fe4a8e44982e5b89c3c7e3637c8e.zip cpython-4271372a7145fe4a8e44982e5b89c3c7e3637c8e.tar.gz cpython-4271372a7145fe4a8e44982e5b89c3c7e3637c8e.tar.bz2 |
Fix Issue9272 - Change CGIHTTPServer to give the child program a copy of os.environ
Diffstat (limited to 'Lib/http')
-rw-r--r-- | Lib/http/server.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/Lib/http/server.py b/Lib/http/server.py index 4fa58a2..894342a 100644 --- a/Lib/http/server.py +++ b/Lib/http/server.py @@ -99,6 +99,7 @@ import socketserver import sys import time import urllib.parse +import copy # Default error message template DEFAULT_ERROR_MESSAGE = """\ @@ -994,7 +995,7 @@ class CGIHTTPRequestHandler(SimpleHTTPRequestHandler): # Reference: http://hoohoo.ncsa.uiuc.edu/cgi/env.html # XXX Much of the following could be prepared ahead of time! - env = {} + env = copy.deepcopy(os.environ) env['SERVER_SOFTWARE'] = self.version_string() env['SERVER_NAME'] = self.server.server_name env['GATEWAY_INTERFACE'] = 'CGI/1.1' @@ -1059,7 +1060,6 @@ class CGIHTTPRequestHandler(SimpleHTTPRequestHandler): for k in ('QUERY_STRING', 'REMOTE_HOST', 'CONTENT_LENGTH', 'HTTP_USER_AGENT', 'HTTP_COOKIE', 'HTTP_REFERER'): env.setdefault(k, "") - os.environ.update(env) self.send_response(200, "Script output follows") @@ -1091,7 +1091,7 @@ class CGIHTTPRequestHandler(SimpleHTTPRequestHandler): pass os.dup2(self.rfile.fileno(), 0) os.dup2(self.wfile.fileno(), 1) - os.execve(scriptfile, args, os.environ) + os.execve(scriptfile, args, env) except: self.server.handle_error(self.request, self.client_address) os._exit(127) @@ -1116,7 +1116,8 @@ class CGIHTTPRequestHandler(SimpleHTTPRequestHandler): p = subprocess.Popen(cmdline, stdin=subprocess.PIPE, stdout=subprocess.PIPE, - stderr=subprocess.PIPE + stderr=subprocess.PIPE, + env = env ) if self.command.lower() == "post" and nbytes > 0: data = self.rfile.read(nbytes) |