summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@haypocalc.com>2011-06-20 15:45:54 (GMT)
committerVictor Stinner <victor.stinner@haypocalc.com>2011-06-20 15:45:54 (GMT)
commitfb25ba9b073ddcec602700484ff5fc2b1bea1a59 (patch)
tree82bcb24c576d8a4fc99c30132f02cca2dbd2eccf /Lib
parent54e647f21511feca159a734b49878f566c72ab1d (diff)
downloadcpython-fb25ba9b073ddcec602700484ff5fc2b1bea1a59.zip
cpython-fb25ba9b073ddcec602700484ff5fc2b1bea1a59.tar.gz
cpython-fb25ba9b073ddcec602700484ff5fc2b1bea1a59.tar.bz2
Close #12289: Fix "is executable?" test in the CGI server
Use os.access(path, os.X_OK) instead of (os.stat(path).st_mode & 0o111 != 0), and ignore the test on Windows.
Diffstat (limited to 'Lib')
-rw-r--r--Lib/http/server.py8
1 files changed, 2 insertions, 6 deletions
diff --git a/Lib/http/server.py b/Lib/http/server.py
index 1d193f8..e571418 100644
--- a/Lib/http/server.py
+++ b/Lib/http/server.py
@@ -897,11 +897,7 @@ def nobody_uid():
def executable(path):
"""Test for executable file."""
- try:
- st = os.stat(path)
- except os.error:
- return False
- return st.st_mode & 0o111 != 0
+ return os.access(path, os.X_OK)
class CGIHTTPRequestHandler(SimpleHTTPRequestHandler):
@@ -1015,7 +1011,7 @@ class CGIHTTPRequestHandler(SimpleHTTPRequestHandler):
scriptname)
return
ispy = self.is_python(scriptname)
- if not ispy:
+ if self.have_fork or not ispy:
if not self.is_executable(scriptfile):
self.send_error(403, "CGI script is not executable (%r)" %
scriptname)