skip to navigation
skip to content

asylum 0.4.1

Lightweight containerization solution for Linux


A lib to use the unshare/clone syscalls from linux directly. also
provides support for seccomp for applications that have been
specifically written to use it

Quick start Guide
# Clone the repository
$ hg clone
$ cd asylum

# Built a temporary/Zero install enviroment
$ virtualenv env
$ . env/bin/activate
$ python ./ install

# Launch the program
$ sudo asylum start -HPMIN --hostname #NOTE: needs root priviliges to run
$ hostname

hostname should now spit out '' in the asylum jail and remain
unchanged in another terminal. to confirm that asylum has fully isolated
the enviroment, try setting the hostname in the asylum jail and confirm
that the hostname for your system has not changed

* Executing unsafe code
* More advanced chrooting
* OS virtualisation/bootstrapping
* Network Simulation
* Experimenting with different setups
* Preinstallation steps for new machines
* Vhosting
* Performing MITM on locally running applications

To provide several security and virtualisation primitives that can
easily be integrated into python programs.

#. Provide Strong simple primitives to existing python programs
Where possible make these drop in replacements (eg PEP-3143)
#. Provide a virtualenv like tool for creating and running virtual
#. Provide wrappers for low level syscalls

* Direct setting of hostname
* Direct mounting of filesystems without calling /sbin/mount
* Setting and dropping of capabilities
* Syscall wrapper generation for the brave
* pivot_root support for full isolation
* prctl syscall
* clone/unshare syscall support

Coming Soon
Features that are planned but have not yet come to fruition
* PEP-3143 daemon process support (
increases the security of the chroot option
* Recording of namespace state/status for querying (start/stop)
* Optional management daemon
* Optional web interface for management daemon
* Basic image setup hooks
* Command orientated cmdline args (similar to virtualenv)
* Plugin support
* Config file support
* Reconnect to running namespace (setns)

* A recent linux kernel with cgroups and namespace support
(Tested on a 2.6.37 hand compiled kernel)
* an x86 processor (32bit or 64bit), support for other archs is
available on request. this syscall constants just need to be

* python >= 3.0
* argparse module


* python >= 3.2


* python >= 2.7


* pypy >= 1.5

Compiling a namespace capable Kernel
If your linux kernel does not have the required features then you may
be able to compile your own kernel by downloading the source packages
for your distribution and compiling a kernel yourself.

if you are using a graphical tool (eg as launched by typing "make nconfig")
then you will need to ensure the following options are enabled

General Setup
--> Namespaces Support
--> UTS Namespace
--> IPC Namespace
--> User Namespace
--> PID Namespace
--> Network Namespace

General Setup
--> Control Group Support
--> Enable options as required

if invoking "make config" to set the required options or editing an existing
kernel config (eg one taken from /proc/config or /proc/config.gz) then the
config options you need to change can be obtained by running "asylum -d" to
perform auto detection of the settings and listing their name and current

you may wish to enable basic routing support (normmaly enabled by default)
as well as etun and macvlan support. seccomp support

Device Drivers
--> Network device support
--> MAC-VLAN support
-->Virtual ethernet pair device

Processor type and features
--> Enable seccomp to safely compute untrusted bytecode

The kernel documentation/manpages do not always line up with exactly what linux
does, some syscalls raise EPERM incorectly (eg pivot_root and EBUSY), where
posible i have tried to put all edge cases in the exception message or as
notes in the src however if you find new ones let me know asap at

The following example shows how to create a namespace with its own
separate network and idea of the machines hostname and domain, you
can make changes to the hostname and interfaces without affecting
your main workspace. as these are lightweight you can easily create
100's of namespaces to perform things like creating virtual networks.
for creating network 'pipes' between namespaces take a look at vtun
or refer to the documents on (coming soon).
to share the main Ethernet interface between multiple namespaces it
is recommended to use macvlan if you wish to use features such as
tcpdump or dhcp in the guest namespace, otherwise routing may suffice

$ sudo ipython
>>> import asylum
# Here we enable IPC, UTS (kernel domain name) and NET namespaces
>>> asylum.isolate(None, False, False, True, False, True, True)
>>> !ip ad sh
13: lo: <loopback> mtu 16436 qdisc noop state DOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
14: sit0: <noarp> mtu 1480 qdisc noop state DOWN
link/sit brd

>>> !hostname thisisatest
>>> !domainname

# now go to a seperate terminal and enter the following
$ hostname; domainname

# Now go back to ipython and enter the following
>>> import socket
>>> socket.gethostname()

Getting Support
I am more than willing to help people get the code up and running or get
up to speed on developing with the code, drop me a line #insane-asylum on, xmpp:// or email

if you have bug reports send them in, i am happy to fix them. same goes
for feature requests and comments on my code quality.

if you are using this in production let me know :D

* Documents on LXC and networking with unshare:  
File Type Py Version Uploaded on Size
asylum-0.4.1.tar.gz (md5) Source 2013-03-21 35KB