137
141
shutil.rmtree(jail_site_packages)
138
142
shutil.copytree(ivle_site_packages, jail_site_packages)
144
# Make /tmp and /var/lock un-world-writable. /tmp will be mounted over,
145
# and /var/{lock,tmp} should die.
146
for path in ('tmp', 'var/lock', 'var/tmp'):
147
path = os.path.join(build_path, path)
148
os.chmod(path, os.stat(path).st_mode & ~stat.S_IWOTH)
150
# Verify that nothing in the jail is world-writable.
151
# We don't want students to write into places that others can see.
152
for path, dirs, files in os.walk(build_path):
154
d = os.path.join(path, dname)
155
if os.path.islink(d):
157
if os.stat(d).st_mode & stat.S_IWOTH:
161
f = os.path.join(path, fname)
162
if os.path.islink(f):
164
if os.stat(f).st_mode & stat.S_IWOTH:
165
if (os.path.dirname(f) == os.path.join(build_path, 'dev') and
166
os.path.basename(f) in ('ptmx', 'null', 'tty', 'full', 'zero',
140
173
if os.spawnvp(os.P_WAIT, 'rsync', ['rsync', '-a', '--delete',
141
174
build_path + '/', ivle.conf.jail_system]) != 0:
142
175
print >> sys.stderr, "Jail copying failed."