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

« back to all changes in this revision

Viewing changes to platform/scripts/safe-python

  • Committer: drtomc
  • Date: 2007-12-05 21:24:33 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:5
Fix a bunch of glitches that Ivo and I found yesterday.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/python
 
1
#!/usr/local/bin/python
2
2
 
3
3
import os
4
4
import sys
5
5
import re
6
6
import resource
7
7
 
8
 
jailBase = '/home/infomatics/jails/'
 
8
jailBase = '/home/informatics/jails/'
9
9
siteBase = '/home/informatics/www/'
10
10
 
11
11
def findUser(login):
32
32
    for (r,l) in limits:
33
33
        resource.setrlimit(r,l)
34
34
 
35
 
def runit(login, script):
 
35
def runit(login):
 
36
    os.environ['DOCUMENT_ROOT'] = '/'
 
37
    os.environ['SCRIPT_FILENAME'] = re.sub(siteBase + login + '/',
 
38
                        '/home/' + login + '/svn/' + login + '/trunk/',
 
39
                        os.environ['SCRIPT_FILENAME'])
 
40
    script = os.environ['SCRIPT_FILENAME']
36
41
    user = findUser(login)
37
42
    uid = int(user[2])
38
43
    os.chdir(jailBase + login)
41
46
    throttle()
42
47
    os.execlp("/usr/bin/python", "python", script)
43
48
 
44
 
os.environ['DOCUMENT_ROOT'] = '/'
45
 
os.environ['SCRIPT_FILENAME'] = re.sub(siteBase, '/home/',
46
 
                                        os.environ['SCRIPT_FILENAME'])
47
 
 
48
49
m = re.match('^/([^/]*)/', os.environ['SCRIPT_NAME'])
49
50
if m is None:
50
51
    exit(1)
51
52
login = m.group(1)
52
53
 
53
 
runit(login, os.environ['SCRIPT_FILENAME'])
 
54
runit(login)