08 Feb'12
Python chroot
What is important to remember is that chroot will allow you cd into /, and that will correspond to the dir you chrooted in:
os.chroot(os.path.abspath(os.path.dirname(__file__)))
for opt in glob.glob("/*"):
print "\t-> %s" % opt
try:
os.chdir("/root/")
print "Chroot FAIL"
print os.getcwd()
except Exception as e:
print "Chroot OK"
Category: python