export JAIL=/home/jail
#Make all dirs
mkdir -p $JAIL/dev $JAIL/lib $JAIL/etc $JAIL/opt/ $JAIL/proc
#copy hosts file
cp /etc/hosts $JAIL/etc/hosts
#copy libs required by java (1.6.20)
cp /lib/ld-linux-x86-64.so.2 /lib/libc.so.6 /lib/libdl.so.2 /lib/libgcc_s.so.1 /lib/libm.so.6 /lib/libnsl.so.1 /lib/libpthread.so.0 /lib/librt.so.1 $JAIL/lib/
#needed by my Java app
cp /usr/lib/libstdc++.so.5 $JAIL/lib/
#Although you link this to your "real" /lib, in your jail, it will be the lib directory in your jail.
ln -s /lib $JAIL/lib64
#Mount proc
sudo mount -t proc /proc $JAIL/proc
#create devices
sudo mknod -m 666 $JAIL/dev/random c 1 8
sudo mknod -m 666 $JAIL/dev/null c 1 3
sudo mknod -m 666 $JAIL/dev/zero c 1 5
Now just copy/install java, then start it with:
sudo chroot $JAIL /opt/java/bin/java -version
Assuming that /opt/java is where you installed java.
If java does not launch, make sure with ldd, that all so files are in the $JAIL/lib dir.
I got
chroot: failed to run command `/opt/java/bin/java': No such file or directory
Because the lib64 directory was not linked to /lib.
I see quite a few people like this blog post, please leave a comment ... thanks.
I see quite a few people like this blog post, please leave a comment ... thanks.
Aucun commentaire:
Enregistrer un commentaire