[Python-bugs-list] [ python-Bugs-467430 ] CGIHTTPServer - 2 issues and/or bugs

noreply@sourceforge.net noreply@sourceforge.net
Wed, 03 Oct 2001 01:09:05 -0700


Bugs item #467430, was opened at 2001-10-03 01:09
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=467430&group_id=5470

Category: Python Library
Group: Python 2.1.1
Status: Open
Resolution: None
Priority: 5
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: CGIHTTPServer - 2 issues and/or bugs

Initial Comment:

1) First, the easy one.  I believe the following
self.error_message calls should be replaced with
self.log_message calls ... since no error actually has
occured.

*** /opt/arseed/tfs-lib/lib/python2.1/CGIHTTPServer.py	Tue Oct  2 20:35:04 2001
--- /home/norton/CGIHTTPServer.py	Wed Oct  3 17:07:05 2001
***************
*** 227,233 ****
                  cmdline = "%s %s" % (interp, cmdline)
              if '=' not in query and '"' not in query:
                  cmdline = '%s "%s"' % (cmdline, query)
!             self.log_error("command: %s", cmdline)
              try:
                  nbytes = int(length)
              except:
--- 227,233 ----
                  cmdline = "%s %s" % (interp, cmdline)
              if '=' not in query and '"' not in query:
                  cmdline = '%s "%s"' % (cmdline, query)
!             self.log_message("command: %s", cmdline)
              try:
                  nbytes = int(length)
              except:
***************
*** 242,248 ****
              if sts:
                  self.log_error("CGI script exit
status %#x", sts)
              else:
!                 self.log_error("CGI script exited OK")
  
          else:
              # Other O.S. -- execute script in this
process
--- 242,248 ----
              if sts:
                  self.log_error("CGI script exit
status %#x", sts)
              else:
!                 self.log_message("CGI script exited OK")
  
          else:
              # Other O.S. -- execute script in this
process
***************
*** 267,273 ****
              except SystemExit, sts:
                  self.log_error("CGI script exit
status %s", str(sts))
              else:
!                 self.log_error("CGI script exited OK")
  
  
  nobody = None
--- 267,273 ----
              except SystemExit, sts:
                  self.log_error("CGI script exit
status %s", str(sts))
              else:
!                 self.log_message("CGI script exited OK")
  
  
  nobody = None

2) Secondly, I have created my own CGIHTTP handler
class that re-uses the CGHITTPServer
CGIHTTPRequestHandler class.  I have modified Zope's
ZPublisher.Client code to redirect file:// urls to this
CGIHTTP handler so that external cgi executables can be
proxied by zope. I have attached my handler to this
request (only if you are curious).

Anyway, I feel the following patch should be applied to
the standard python lib.  I faced troubles with
os.fork, os.dup2, and reading from self.rfile in the
child process if the self.rfile is not flushed as well
prior to forking.

*** Python-2.1.1/Lib/CGIHTTPServer.py	Sat Sep 29 15:52:51 2001
--- Python-2.1.1/Lib/CGIHTTPServer.py	Tue Oct  2 19:55:14 2001
***************
*** 192,197 ****
--- 192,198 ----
              if '=' not in decoded_query:
                  args.append(decoded_query)
              nobody = nobody_uid()
+             self.rfile.flush() # Always flush before
forking
              self.wfile.flush() # Always flush before
forking
              pid = os.fork()
              if pid != 0:


----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=467430&group_id=5470