[issue1684] CGIHTTPServer does not chdir prior to executing the CGI script

Fazal Majid report at bugs.python.org
Fri Dec 21 22:57:22 CET 2007


New submission from Fazal Majid:

The CGI specification does not specify the working directory the CGI is
invoked in, but the usual behavior is to use the directory containing
the script.

CGIHTTPServer should either change working directory by default (see
patch below), or offer a hook to be called before the exec() call to the
CGI.


*** /usr/local/lib/python2.4/CGIHTTPServer.py   Tue Apr  4 11:13:23 2006
--- kCGIHTTPServer.py   Fri Dec 21 13:31:40 2007
***************
*** 227,232 ****
--- 227,233 ----
                      pass
                  os.dup2(self.rfile.fileno(), 0)
                  os.dup2(self.wfile.fileno(), 1)
+                 os.chdir(os.path.dirname(scriptfile))
                  os.execve(scriptfile, args, os.environ)
              except:
                  self.server.handle_error(self.request,
self.client_address)

----------
components: Library (Lib)
messages: 58955
nosy: majid
severity: normal
status: open
title: CGIHTTPServer does not chdir prior to executing the CGI script
type: behavior
versions: Python 2.5

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1684>
__________________________________


More information about the Python-bugs-list mailing list