388
# Remove SCRIPT_FILENAME. Not part of CGI spec (see SCRIPT_NAME).
390
# PATH_INFO is wrong because the script doesn't physically exist.
391
# Apache makes it relative to the "serve" app. It should actually be made
392
# relative to the student's script. intepretservice does that in the jail,
393
# so here we just clear it.
394
env['PATH_INFO'] = ''
395
env['PATH_TRANSLATED'] = ''
397
388
# CGI specifies that REMOTE_HOST SHOULD be set, and MAY just be set to
398
389
# REMOTE_ADDR. Since Apache does not appear to set this, set it to
400
391
if 'REMOTE_HOST' not in env and 'REMOTE_ADDR' in env:
401
392
env['REMOTE_HOST'] = env['REMOTE_ADDR']
394
env['PATH_INFO'] = ''
395
del env['PATH_TRANSLATED']
397
normuri = os.path.normpath(req.uri)
398
env['SCRIPT_NAME'] = normuri
403
400
# SCRIPT_NAME is the path to the script WITHOUT PATH_INFO.
404
script_name = req.uri
405
env['SCRIPT_NAME'] = script_name
401
# We don't care about these if the script is null (ie. noop).
402
# XXX: We check for /home because we don't want to interfere with
403
# CGIRequest, which fileservice still uses.
404
if script_path and script_path.startswith('/home'):
405
normscript = os.path.normpath(script_path)
407
uri_into_jail = studpath.url_to_jailpaths(os.path.normpath(req.path))[2]
409
# PATH_INFO is wrong because the script doesn't physically exist.
410
env['PATH_INFO'] = uri_into_jail[len(normscript):]
411
if len(env['PATH_INFO']) > 0:
412
env['SCRIPT_NAME'] = normuri[:-len(env['PATH_INFO'])]
407
414
# SERVER_SOFTWARE is actually not Apache but IVLE, since we are
408
415
# custom-making the CGI request.