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

« back to all changes in this revision

Viewing changes to ivle/interpret.py

  • Committer: William Grant
  • Date: 2009-01-20 06:00:55 UTC
  • mto: This revision was merged to the branch mainline in revision 1090.
  • Revision ID: grantw@unimelb.edu.au-20090120060055-iuvd8hycor67acfa
ivle.rpc.decorators: Add (new package, too). Has a couple of decorators to
    apply most security policy in userservice, making it significantly shorter
    and easier to audit.
www/apps/userservice: Use the decorators to protect all actions whose existing
    policy can be easily replaced with them.

Show diffs side-by-side

added added

removed removed

Lines of Context:
410
410
    # Additional environment variables
411
411
    username = studpath.url_to_jailpaths(req.path)[0]
412
412
    env['HOME'] = os.path.join('/home', username)
413
 
 
414
 
class ExecutionError(Exception):
415
 
    pass
416
 
 
417
 
def execute_raw(user, jail_dir, working_dir, binary, args):
418
 
    '''Execute a binary in a user's jail, returning the raw output.
419
 
 
420
 
    The binary is executed in the given working directory with the given
421
 
    args. A tuple of (stdout, stderr) is returned.
422
 
    '''
423
 
 
424
 
    tramp = location_cgi_python
425
 
    tramp_dir = os.path.split(location_cgi_python)[0]
426
 
 
427
 
    # Fire up trampoline. Vroom, vroom.
428
 
    proc = subprocess.Popen(
429
 
        [tramp, str(user.unixid), jail_dir, working_dir, binary] + args,
430
 
        stdin=subprocess.PIPE, stdout=subprocess.PIPE,
431
 
        stderr=subprocess.PIPE, cwd=tramp_dir, close_fds=True)
432
 
    exitcode = proc.wait()
433
 
 
434
 
    if exitcode != 0:
435
 
        raise ExecutionError('subprocess ended with code %d, stderr %s' %
436
 
                             (exitcode, proc.stderr.read()))
437
 
    return (proc.stdout.read(), proc.stderr.read())