Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] Why can't chroot find bash?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Installing Gentoo
View previous topic :: View next topic  
Author Message
mauricev
Apprentice
Apprentice


Joined: 22 Mar 2004
Posts: 153

PostPosted: Wed Oct 31, 2007 8:08 pm    Post subject: [SOLVED] Why can't chroot find bash? Reply with quote

On a 64-bit system, I am trying to create a chroot environment, which was prepared by the jail (1.9-r1) utility, and I'm running into /bin/bash...no such file or directory complaint and I don't see any reason why this is happening.

When I run ltrace on chroot, I get

Code:

chdir("/")                                                                 = 0
getenv("SHELL")                                                            = "/bin/bash"
execvp(0x7fff4626c652, 0x7fff4626a4f8, 0x402ad8, 2, 76)                    = 0xffffffff
__errno_location()                                                         = 0x2af764d99690
__errno_location()                                                         = 0x2af764d99690
__ctype_get_mb_cur_max(0x503d20, 256, 0x7fff4626c652, -1, 5)               = 6
dcgettext(0, 0x402b82, 5, -1, 5)                                           = 0x402b82
dcgettext(0, 0x402b84, 5, 1, 0x7fff4626a1c0)                               = 0x402b84
strlen("'")                                                                = 1
dcgettext(0, 0x402ae3, 5, 0x402b84, 0x7fff4626a1c0)                        = 0x402ae3
error(0, 2, 0x402ae3, 0x503d20, 0x7fff4626a390chroot: cannot run command `/bin/bash': No such file or directory


where /home/halllvd/planaria is intended new root location.

It really appears that execvp simply cannot find the bash executable.

If I run chroot on the system's real root, it has no trouble finding and it and going from there:

Code:

chdir("/")                                                                 = 0
getenv("SHELL")                                                            = "/bin/bash"
execvp(0x7fffde097675, 0x7fffde095348, 0x402ad8, 2, 76 <unfinished ...>
__libc_start_main(0x419760, 2, 0x7fff0cb7be28, 0x487890, 0x487880 <unfinished ...>
__sigsetjmp(0x5bdb40, 1, 0x7fff0cb7be40, 0x487890, 0x2b1e9e687260)         = 0
open("/dev/tty", 2050, 01)                                                 = 3



Of course, bash is there:
Code:

-rwxr-xr-x 1 root root 763896 2007-10-31 14:15 /home/halllvd/planaria/bin/bash

And I can use it to launch a shell as with /bin/bash.

In the working version, it looks like libc is being executed, but it also seems to be in the right place:
Code:

-rwxr-xr-x 1 root root 1301648 2007-10-31 14:15 /home/halllvd/planaria/lib/libc.so.6


chroot is from coreutils, which is version 6.9-r1.


Last edited by mauricev on Wed Oct 31, 2007 11:18 pm; edited 1 time in total
Back to top
View user's profile Send private message
mauricev
Apprentice
Apprentice


Joined: 22 Mar 2004
Posts: 153

PostPosted: Wed Oct 31, 2007 11:18 pm    Post subject: Reply with quote

I figured it out.

/lib/64/ld-linux-x86-64.so.2 references a library used by bash. But for some reason, it did not get copied by the jail utility. So I had manually copied it, but I didn't realize that it's just a symlink to ld-2.6.1.so, which had not been copied at all.

It's not clear why jail failed to copy it, because it was a symlink, because it is in the symlinked lib64 directory? Unfortunately, it doesn't look like anyone is maintaining it.

Anyway, execvp is actually reporting that it can't find that library, not that it can't find bash.

So the gist of this that libraries can be linked through symlinked files and that every library file must be an actual file.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Installing Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum