449
449
'trampoline/trampoline.c'], dry)
451
451
# Create the jail and its subdirectories
452
# Note: Other subdirs will be made by copying files
452
453
action_mkdir('jail', dry)
453
action_mkdir('jail/bin', dry)
454
action_mkdir('jail/lib', dry)
455
action_mkdir('jail/usr/bin', dry)
456
action_mkdir('jail/usr/lib', dry)
457
action_mkdir('jail/opt/ivle', dry)
458
454
action_mkdir('jail/home', dry)
459
455
action_mkdir('jail/tmp', dry)
461
# Copy all console files into the jail
457
# Copy all console and operating system files into the jail
462
458
action_copylist(install_list.list_console, 'jail/opt/ivle', dry)
464
# TODO: Copy operating system files into the jail
459
copy_os_files_jail(dry)
466
461
# Compile .py files into .pyc or .pyo files
467
462
compileall.compile_dir('www', quiet=True)
467
def copy_os_files_jail(dry):
468
"""Copies necessary Operating System files from their usual locations
469
into the jail/ directory of the cwd."""
470
# Currently source paths are configured for Ubuntu.
471
copy_file_to_jail('/lib/ld-linux.so.2', dry)
472
copy_file_to_jail('/lib/tls/i686/cmov/libc.so.6', dry)
473
copy_file_to_jail('/lib/tls/i686/cmov/libdl.so.2', dry)
474
copy_file_to_jail('/lib/tls/i686/cmov/libm.so.6', dry)
475
copy_file_to_jail('/lib/tls/i686/cmov/libpthread.so.0', dry)
476
copy_file_to_jail('/lib/tls/i686/cmov/libutil.so.1', dry)
477
copy_file_to_jail('/usr/bin/python2.5', dry)
478
# TODO: ln -s jail/usr/bin/python2.5 jail/usr/bin/python
479
action_copytree('/usr/lib/python2.5', 'jail/usr/lib/python2.5', dry)
481
def copy_file_to_jail(src, dry):
482
"""Copies a single file from an absolute location into the same location
483
within the jail. src must begin with a '/'. The jail will be located
484
in a 'jail' subdirectory of the current path."""
485
action_copyfile(src, 'jail' + src, dry)
472
487
def install(args):
473
488
# Get "dry" and "nojail" variables from command line
474
489
(opts, args) = getopt.gnu_getopt(args, "n", ['dry', 'nojail'])
585
600
shutil.copyfile(src, dst)
602
def action_symlink(src, dst, dry):
603
"""Creates a symlink in a given location. Creates all parent directories
606
dstdir = os.path.split(dst)[0]
607
if not os.path.isdir(dstdir):
608
action_mkdir(dstdir, dry)
609
print "ln -s", src, dst
587
613
def action_chown_setuid(file, dry):
588
614
"""Chowns a file to root, and sets the setuid bit on the file.
589
615
Calling this function requires the euid to be root.