tags:

views:

56

answers:

1

As an alternately to my real question: does anyone know of a simple command line tool to make a chroot jail? I'm thinking something that will run a command and copy everything it needs to run into a given directory. I saw some directions for a tool but it had config files and seemed to be expecting me to launch it from X and neither of those work for my case.


And for the real question:

I'm trying to build a chroot jail and it's not working. This is what I get when I strace the command:

bcs@builder:~/dmd$ sudo strace sudo chroot /home/bcs/dmd/ /usr/bin/make -C src linux.mak 
...
chroot("/home/bcs/dmd/")                = 0
chdir("/")                              = 0
execve("/usr/bin/make", ["/usr/bin/make", "-C", "src", "-f", "linux.mak"], [/* 13 vars */]) = -1 ENOENT (No such file or directory)
write(2, "chroot: ", 8chroot: )                 = 8
write(2, "cannot run command `/usr/bin/mak"..., 34cannot run command `/usr/bin/make') = 34
write(2, ": No such file or directory", 27: No such file or directory) = 27
write(2, "\n", 1
)                       = 1
close(1)                                = 0
close(2)                                = 0
exit_group(127)                         = ?
bcs@builder:~/dmd$ ll /home/bcs/dmd/usr/bin/make
-rwxr-xr-x 1 bcs bcs 166112 Sep 17 00:41 /home/bcs/dmd/usr/bin/make*

it seems that the chroot can't find make even though it should be there. Any ideas what I'm missing?

BTW: This is on a recent Ubuntu box.

+2  A: 

You probably do not have the loader and/or shared libraries available to make. For instance, on my system (64-bit Debian sid), make needs this:

$ ldd /usr/bin/make
    linux-vdso.so.1 =>  (0x00007fff95fff000)
    librt.so.1 => /lib/librt.so.1 (0x00007fc97d557000)
    libc.so.6 => /lib/libc.so.6 (0x00007fc97d1f6000)
    libpthread.so.0 => /lib/libpthread.so.0 (0x00007fc97cfd9000)
    /lib64/ld-linux-x86-64.so.2 (0x00007fc97d761000)

You need to have all those files (or equivalent for your make) available in your chroot.

camh
I get more or less the same list, 3 I had, 1 didn't exist anywhere and one was missing. Now how did strace not show that one?..
BCS
After putting stuff in the correct dir, that works.
BCS
You don't need `linux-vdso.so.1`, that's not actually a real file.
caf