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