81
82
# Just get the first 3 characters of sys.version.
82
83
PYTHON_VERSION = sys.version[0:3]
84
# Operating system files to copy over into the jail.
85
# These will be copied from the given place on the OS file system into the
86
# same place within the jail.
89
'/lib/tls/i686/cmov/libc.so.6',
90
'/lib/tls/i686/cmov/libdl.so.2',
91
'/lib/tls/i686/cmov/libm.so.6',
92
'/lib/tls/i686/cmov/libpthread.so.0',
93
'/lib/tls/i686/cmov/libutil.so.1',
96
# These 2 files do not exist in Ubuntu
97
#'/etc/ld.so.preload',
98
#'/etc/ld.so.nohwcap',
104
'/usr/bin/python%s' % PYTHON_VERSION,
105
# Needed by fileservice
106
'/lib/libcom_err.so.2',
107
'/lib/libcrypt.so.1',
108
'/lib/libkeyutils.so.1',
109
'/lib/libresolv.so.2',
112
'/usr/lib/libapr-1.so.0',
113
'/usr/lib/libaprutil-1.so.0',
114
'/usr/lib/libdb-4.4.so',
115
'/usr/lib/libexpat.so.1',
116
'/usr/lib/libgcrypt.so.11',
117
'/usr/lib/libgnutls.so.13',
118
'/usr/lib/libgpg-error.so.0',
119
'/usr/lib/libgssapi_krb5.so.2',
120
'/usr/lib/libk5crypto.so.3',
121
'/usr/lib/libkrb5.so.3',
122
'/usr/lib/libkrb5support.so.0',
123
'/usr/lib/liblber.so.2',
124
'/usr/lib/libldap_r.so.2',
125
'/usr/lib/libneon.so.26',
126
'/usr/lib/libpq.so.5',
127
'/usr/lib/libsasl2.so.2',
128
'/usr/lib/libsqlite3.so.0',
129
'/usr/lib/libsvn_client-1.so.1',
130
'/usr/lib/libsvn_delta-1.so.1',
131
'/usr/lib/libsvn_diff-1.so.1',
132
'/usr/lib/libsvn_fs-1.so.1',
133
'/usr/lib/libsvn_fs_base-1.so.1',
134
'/usr/lib/libsvn_fs_fs-1.so.1',
135
'/usr/lib/libsvn_ra-1.so.1',
136
'/usr/lib/libsvn_ra_dav-1.so.1',
137
'/usr/lib/libsvn_ra_local-1.so.1',
138
'/usr/lib/libsvn_ra_svn-1.so.1',
139
'/usr/lib/libsvn_repos-1.so.1',
140
'/usr/lib/libsvn_subr-1.so.1',
141
'/usr/lib/libsvn_wc-1.so.1',
142
'/usr/lib/libtasn1.so.3',
143
'/usr/lib/libxml2.so.2',
144
# Needed by matplotlib
145
'/usr/lib/i686/cmov/libssl.so.0.9.8',
146
'/usr/lib/i686/cmov/libcrypto.so.0.9.8',
147
'/lib/tls/i686/cmov/libnsl.so.1',
148
'/usr/lib/libz.so.1',
149
'/usr/lib/atlas/liblapack.so.3',
150
'/usr/lib/atlas/libblas.so.3',
151
'/usr/lib/libg2c.so.0',
152
'/usr/lib/libstdc++.so.6',
153
'/usr/lib/libfreetype.so.6',
154
'/usr/lib/libpng12.so.0',
155
'/usr/lib/libBLT.2.4.so.8.4',
156
'/usr/lib/libtk8.4.so.0',
157
'/usr/lib/libtcl8.4.so.0',
158
'/usr/lib/tcl8.4/init.tcl',
159
'/usr/lib/libX11.so.6',
160
'/usr/lib/libXau.so.6',
161
'/usr/lib/libXdmcp.so.6',
162
'/lib/libgcc_s.so.1',
165
'/lib/libnss_dns.so.2',
166
'/lib/libnss_mdns4_minimal.so.2',
171
'/etc/nsswitch.conf',
172
'/lib/libnss_files.so.2',
174
# Symlinks to make within the jail. Src mapped to dst.
176
'python%s' % PYTHON_VERSION: 'jail/usr/bin/python',
178
# Trees to copy. Src mapped to dst (these will be passed to action_copytree).
180
'/usr/lib/python%s' % PYTHON_VERSION:
181
'jail/usr/lib/python%s' % PYTHON_VERSION,
182
'/usr/share/matplotlib': 'jail/usr/share/matplotlib',
183
'/etc/ld.so.conf.d': 'jail/etc/ld.so.conf.d',
184
'/usr/share/nltk': 'jail/usr/share/nltk',
187
85
class ConfigOption:
188
86
"""A configuration option; one of the things written to conf.py."""
189
87
def __init__(self, option_name, default, prompt, comment):
246
144
file system):""",
248
146
# In the local file system, where is the Terms of Service document located."""))
147
config_options.append(ConfigOption("motd_path",
148
"/home/informatics/motd.html",
149
"""Location where the Message of the Day document is stored (on the local
152
# In the local file system, where is the Message of the Day document
153
# located. This is an HTML file (just the body fragment), which will
154
# be displayed on the login page. It is optional."""))
249
155
config_options.append(ConfigOption("public_host", "public.localhost",
250
156
"""Hostname which will cause the server to go into "public mode",
251
157
providing login-free access to student's published work:""",
1034
954
# Create the jail and its subdirectories
1035
955
# Note: Other subdirs will be made by copying files
1036
action_mkdir('jail', dry)
1037
action_mkdir('jail/home', dry)
1038
action_mkdir('jail/tmp', dry)
1040
# Chmod the tmp directory to world writable
1041
action_chmod_w('jail/tmp', dry)
956
action_runprog('./buildjail.sh', [], dry)
1043
958
# Copy all console and operating system files into the jail
1044
959
action_copylist(install_list.list_scripts, 'jail/opt/ivle', dry)
1045
copy_os_files_jail(dry)
1046
960
# Chmod the python console
1047
961
action_chmod_x('jail/opt/ivle/scripts/python-console', dry)
1048
962
action_chmod_x('jail/opt/ivle/scripts/fileservice', dry)
1078
def copy_os_files_jail(dry):
1079
"""Copies necessary Operating System files from their usual locations
1080
into the jail/ directory of the cwd."""
1081
# Currently source paths are configured for Ubuntu.
1082
for filename in JAIL_FILES:
1083
copy_file_to_jail(filename, dry)
1084
for src, dst in JAIL_LINKS.items():
1085
action_symlink(src, dst, dry)
1086
for src, dst in JAIL_COPYTREES.items():
1087
action_copytree(src, dst, dry)
1089
992
def copy_file_to_jail(src, dry):
1090
993
"""Copies a single file from an absolute location into the same location
1091
994
within the jail. src must begin with a '/'. The jail will be located
1172
1075
if write_ivle_lib_pth:
1173
1076
action_append(ivle_pth, ivle_lib)
1079
# Create the ivle working revision record file
1080
action_mkdir(os.path.join(ivle_install_dir, 'version'), dry)
1081
ivle_revision_record_file = os.path.join(ivle_install_dir, 'version/ivle-revision.txt')
1084
conf = open(ivle_revision_record_file, "w")
1086
conf.write( "# IVLE code revision listing generated by running 'svn status -v ..' from " + os.getcwd() + "\n#\n\n")
1089
except IOError, (errno, strerror):
1090
print "IO error(%s): %s" % (errno, strerror)
1093
os.system("svn status -v .. >> %s" % ivle_revision_record_file)
1095
print "Wrote IVLE code revision status to %s" % ivle_revision_record_file
1177
1099
def updatejails(args):
1188
1110
print >>sys.stderr, "(I need to chown some files)."
1191
# Update the template jail directory in case it hasn't been installed
1113
# Update the staging jail directory in case it hasn't been installed
1193
action_copytree('jail', os.path.join(jail_base, 'template'), dry)
1115
action_copytree('jail', os.path.join(jail_base, '__staging__'), dry)
1195
1117
# Re-link all the files in all students jails.
1196
1118
for dir in os.listdir(jail_base):
1197
if dir == 'template': continue
1119
if dir == '__staging__': continue
1198
1120
# First back up the student's home directory
1199
1121
temp_home = os.tmpnam()
1200
1122
action_rename(os.path.join(jail_base, dir, 'home'), temp_home, dry)
1201
1123
# Delete the student's jail and relink the jail files
1202
action_linktree(os.path.join(jail_base, 'template'),
1124
action_linktree(os.path.join(jail_base, '__staging__'),
1203
1125
os.path.join(jail_base, dir), dry)
1204
1126
# Restore the student's home directory
1205
1127
action_rename(temp_home, os.path.join(jail_base, dir, 'home'), dry)