pythondjangosecuritychrootjail

How to chroot Django


Can one run Django in a chroot? Notably, what's necessary in order to set up (for example) /var/www as a chroot'd directory and then have Django run in that chroot'd directory?

Thank you - I'm grateful for any input.


Solution

  • You will have to add a Python interpreter to that directory and add Django to it ofcourse.

    After you've got the environment set-up you will have to create a wrapper script that does something like os.chroot('/var/www/') and you're done :)

    To create a sandboxed/chrooted environment for Python try one of the following options: http://wiki.python.org/moin/Asking%20for%20Help/How%20can%20I%20run%20an%20untrusted%20Python%20script%20safely%20%28i.e.%20Sandbox%29?highlight=%28chroot%29 The PyPy option seems to be getting popular since Google started using it with the App-Engine.