~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/apps/fileservice/__init__.py

  • Committer: mattgiuca
  • Date: 2008-02-05 07:33:46 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:421
apps/fileservice: Added code to call interpret on the trampoline version of
    fileservice. (Disabled at the moment as it doesn't work).
common.interpret: Bugfix on filenames starting with '/' (relating to the
    previous revision).

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
# See the documentation in lib/fileservice for details.
31
31
 
 
32
import os.path
 
33
 
 
34
import conf
32
35
import fileservice_lib
 
36
import common
 
37
import common.interpret
 
38
 
 
39
# handle_with_trampoline controls the way in which fileservice_lib is invoked.
 
40
# If False, it will simply be called directly by this handler.
 
41
# If True, the request will get marshalled into a CGI environment and the
 
42
# trampoline will invoke scripts/fileservices within the user's jail (SetUID'd
 
43
# to them). This script will then wrap the CGI environment in a replica of the
 
44
# original environment and handle it that way.
 
45
# This is a lot of overhead but it's the only way to properly ensure we are
 
46
# acting "as" that user and therefore we don't run into permissions problems.
 
47
# If set to True, it will be a lot more efficient, but there will be
 
48
# permissions issues unless all user's files are owned by the web server user.
 
49
HANDLE_WITH_TRAMPOLINE = False
 
50
 
 
51
fileservice_path = "/opt/ivle/scripts/fileservice"   # Within jail
33
52
 
34
53
def handle(req):
35
54
    """Handler for the File Services application."""
36
 
    fileservice_lib.handle(req)
 
55
    if not HANDLE_WITH_TRAMPOLINE:
 
56
        fileservice_lib.handle(req)
 
57
    else:
 
58
        interp_object = common.interpret.interpreter_objects["cgi-python"]
 
59
        user_jail_dir = os.path.join(conf.jail_base, req.username)
 
60
        common.interpret.interpret_file(req, req.username, user_jail_dir,
 
61
            fileservice_path, interp_object)