2
# Copyright (C) 2007-2008 The University of Melbourne
4
# This program is free software; you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation; either version 2 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program; if not, write to the Free Software
16
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
# This app is a wrapper around the diff script run through the trampoline
28
import common.interpret
32
# handle_with_trampoline controls the way in which fileservice_lib is invoked.
33
# If False, it will simply be called directly by this handler.
34
# If True, the request will get marshalled into a CGI environment and the
35
# trampoline will invoke scripts/fileservices within the user's jail (SetUID'd
36
# to them). This script will then wrap the CGI environment in a replica of the
37
# original environment and handle it that way.
38
# This is a lot of overhead but it's the only way to properly ensure we are
39
# acting "as" that user and therefore we don't run into permissions problems.
40
# If set to True, it will be a lot more efficient, but there will be
41
# permissions issues unless all user's files are owned by the web server user.
42
HANDLE_WITH_TRAMPOLINE = True
44
diffservice_path = "/opt/ivle/scripts/diffservice" # Within jail
47
"""Handler for the File Services application."""
48
req.styles = ["media/diff/diff.css"] # CSS styles
49
req.write_html_head_foot = True # Have dispatch print head and foot
52
if not HANDLE_WITH_TRAMPOLINE:
56
req.throw_redirect(path.join(req.uri,req.user.login));
57
interp_object = common.interpret.interpreter_objects["cgi-python"]
58
user_jail_dir = os.path.join(conf.jail_base, req.user.login)
59
common.interpret.interpret_file(req, req.user.login, user_jail_dir,
60
diffservice_path, interp_object)