You are not logged in.

#1 2013-07-14 01:12:52

vyu223
Member
Registered: 2013-02-18
Posts: 24

[solved] Tor chroot failed, no such file or directory

I've followed the Arch Tor wiki up to the point where I enter the command

# chroot /opt/torchroot /usr/bin/tor

I get the error message,

chroot: failed to run command ‘/usr/bin/tor’: No such file or directory

Of course, /usr/bin/tor exists in both / and in /opt/torchroot/ I am using a 64-bit system, so I did set a symlink from /opt/torchroot/lib64 to /opt/torchroot/usr/lib/ and copy /usr/lib/ld-linux-x86-64.so* to /opt/torchroot/usr/lib/ I modified the script to include those actions; the script is as so:

#!/bin/bash
export TORCHROOT=/opt/torchroot

mkdir -p $TORCHROOT
mkdir -p $TORCHROOT/etc/tor
mkdir -p $TORCHROOT/dev
mkdir -p $TORCHROOT/usr/bin
mkdir -p $TORCHROOT/usr/lib
mkdir -p $TORCHROOT/var/lib

ln -s /usr/lib  $TORCHROOT/lib
ln -s $TORCHROOT/usr/lib $TORCHROOT/lib64
cp /etc/hosts           $TORCHROOT/etc/
cp /etc/host.conf       $TORCHROOT/etc/
cp /etc/localtime       $TORCHROOT/etc/
cp /etc/nsswitch.conf   $TORCHROOT/etc/
cp /etc/resolv.conf     $TORCHROOT/etc/
cp /etc/tor/torrc       $TORCHROOT/etc/tor/

cp /usr/bin/tor         $TORCHROOT/usr/bin/
cp /lib/libnss* /lib/libnsl* /lib/ld-linux.so* /lib/libresolv* /lib/libgcc_s.so* $TORCHROOT/usr/lib/
cp /usr/lib/ld-linux-x86-64.so* $TORCHROOT/usr/lib/
cp $(ldd /usr/bin/tor | awk '{print $3}'|grep "^/") $TORCHROOT/usr/lib/
cp -r /var/lib/tor      $TORCHROOT/var/lib/
chown -R tor:tor $TORCHROOT/var/lib/tor

sh -c "grep ^tor /etc/passwd > $TORCHROOT/etc/passwd"
sh -c "grep ^tor /etc/group > $TORCHROOT/etc/group"

mknod -m 644 $TORCHROOT/dev/random c 1 8
mknod -m 644 $TORCHROOT/dev/urandom c 1 9
mknod -m 666 $TORCHROOT/dev/null c 1 3

The closest thread I can find on this issue is here, but the OP's output is completely different from mine, so I do not expect to have the same problem. Some searching on Google has given me some ideas. I have some suspicions:

-Something is wrong with the chroot jail I created (most likely)
-I had made sure to be careful to handle the most recent news item on the Arch homepage correctly, but it's possible the binary move could have something to do with my problem.
-I'm using linux-ck from the AUR; I don't know if this may have something to do with it

I've verified that /opt/torchroot/usr/lib/ld-linux-x86-64.so.2 exists. I have a feeling that I'm missing something very simple here, but I'm stumped. I'd greatly appreciate if someone can point me in the right direction.

Last edited by vyu223 (2013-07-14 09:28:26)

Offline

#2 2013-07-14 05:31:03

cargoan
Member
Registered: 2013-07-13
Posts: 20

Re: [solved] Tor chroot failed, no such file or directory

...
# ln -s $TORCHROOT/usr/lib $TORCHROOT/lib64  
ln -s /usr/lib $TORCHROOT/lib64
...

Offline

#3 2013-07-14 06:28:39

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: [solved] Tor chroot failed, no such file or directory

I am fairly certain that you cannot symlink to somewhere that is going to be beyond the reach of the chroot.  That is, $TORCHROOT is going to be the new /, so how is it going to get to the directories below that root?  I think you'll have to use bind mounts to achieve this... or create the necessary directory structure and hard link everything that is necessary.

Offline

#4 2013-07-14 09:20:18

cargoan
Member
Registered: 2013-07-13
Posts: 20

Re: [solved] Tor chroot failed, no such file or directory

... but it works! ...then I found a better solution: create links with relative paths.

ln -sr $TORCHROOT/usr/lib  $TORCHROOT/lib
ln -sr $TORCHROOT/usr/lib  $TORCHROOT/lib64

Offline

#5 2013-07-14 09:27:55

vyu223
Member
Registered: 2013-02-18
Posts: 24

Re: [solved] Tor chroot failed, no such file or directory

Thanks cargoan, your solution works (I tried the first one), and along with WonderWoofy's explanation I now have a better understanding of links and chroot. Following the link to /usr/lib inside the chroot jail goes to /usr/lib inside the chroot jail, which is /opt/torchroot/usr/lib outside of the chroot jail.

Offline

Board footer

Powered by FluxBB