LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-21-2002, 02:57 PM   #1
Nothsa
LQ Newbie
 
Registered: Nov 2002
Posts: 22

Rep: Reputation: 15
chroot troubles


Hi

Whenever I try to chroot (as root or any other user) to a directory (in this case /home/user), I get this error message:

chroot: cannot execute /bin/bash: No such file or directory


but bash IS in my /bin directory. I tried also making a /home/user/bin directory and putting bash in there, but that didn't work either.

Any suggestions?

Last edited by Nothsa; 11-21-2002 at 02:59 PM.
 
Old 11-21-2002, 04:55 PM   #2
Nothsa
LQ Newbie
 
Registered: Nov 2002
Posts: 22

Original Poster
Rep: Reputation: 15
damn you chroot! damn you!!

this problem begins to vex me greatly =)
 
Old 11-21-2002, 05:19 PM   #3
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
The command should be located in /usr/sbin

Try to execute it like this logged in as root:

/usr/sbin/chroot

Oh and its not a problem with /bin/bash.. thats your shell. That error is just stating that bash couldn't execute chroot cause most likely it don't know where its at.

Last edited by trickykid; 11-21-2002 at 05:20 PM.
 
Old 11-21-2002, 05:24 PM   #4
Thymox
Senior Member
 
Registered: Apr 2001
Location: Plymouth, England.
Distribution: Mostly Debian based systems
Posts: 4,368

Rep: Reputation: 64
Also make sure that nothing silly has happened, like for instance, that file (/usr/sbin/chroot) has not been set as unexecutable... there's no reason that it shouldn't be executable, but it is still possible!
 
Old 11-21-2002, 05:46 PM   #5
Nothsa
LQ Newbie
 
Registered: Nov 2002
Posts: 22

Original Poster
Rep: Reputation: 15
I've tried running it from /usr/sbin/chroot before and it does the same thing (yes, it is there).

I just chmod'd it to 777 and it still gives me the error, so it's not an executable permissions problem.

chroot also seems to be working, because I can do a '/usr/sbin/chroot /' and it executes with no errors (and transfers me to my / directory).

I know bash is the shell, but it seems like it's not chroot that's the problem maybe chroot is not able to find where bash is?.. I dunno, I'm guessing here).


<edit> I did this all logged in as root </edit>

Last edited by Nothsa; 11-21-2002 at 05:48 PM.
 
Old 11-21-2002, 05:57 PM   #6
Thymox
Senior Member
 
Registered: Apr 2001
Location: Plymouth, England.
Distribution: Mostly Debian based systems
Posts: 4,368

Rep: Reputation: 64
And presumably the file /bin/bash exists? If not, then type find / -name "bash" and symlink that to /bin/bash and see if it helps.

Just a thought.
 
Old 11-21-2002, 06:07 PM   #7
Nothsa
LQ Newbie
 
Registered: Nov 2002
Posts: 22

Original Poster
Rep: Reputation: 15
yeah, it's already in there
 
Old 11-21-2002, 06:10 PM   #8
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Did you populate the chroot jail using some howto or app?

If you execute
"strace -o /tmp/chroottrial-$$.log chroot <dirToChrootTo>"
you'll find near the bottom it'll say chroot(<dirToChrootTo>)
and the chdir(/). That's the point where it's going to look for a shell. execve(/bin/bash), depending on what the user has in <dirToChrootTo>/etc/passwd. The shell must reside within <dirToChrootTo>.

Go on, post a strace log, makes it easy...

Btw, I'm using Jail Chroot. Makes it easier for me to set up a chroot jail framework and I only have to tweak stuff after that a bit.

Last edited by unSpawn; 11-21-2002 at 06:11 PM.
 
Old 11-21-2002, 06:22 PM   #9
Nothsa
LQ Newbie
 
Registered: Nov 2002
Posts: 22

Original Poster
Rep: Reputation: 15
aha! I thought it sounded like it couldn't find bash... I didn't know I had to set up a shell in the dir I was chrooting to... it makes sense though ... so if I understand correctly, I just need to have a shell in the dir I'm chrooting to (bash in this case)?? (I'll give chroot jail a try)

My log follows:


execve("/usr/sbin/chroot", ["chroot", "/home/www"], [/* 23 vars */]) = 0
uname({sys="Linux", node="**MASKED**", ...}) = 0
brk(0) = 0x804b728
open("/etc/ld.so.preload", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=48773, ...}) = 0
old_mmap(NULL, 48773, PROT_READ, MAP_PRIVATE, 3, 0) = 0x40012000
close(3) = 0
open("/lib/libc.so.6", O_RDONLY) = 3
read(3, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0hU\1\000"..., 1024) = 1024
fstat64(3, {st_mode=S_IFREG|0755, st_size=1327065, ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x4001e000
old_mmap(NULL, 1171268, PROT_READ|PROT_EXEC, MAP_PRIVATE, 3, 0) = 0x4001f000
mprotect(0x40134000, 36676, PROT_NONE) = 0
old_mmap(0x40134000, 20480, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED, 3, 0x115000) = 0x40134000
old_mmap(0x40139000, 16196, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x40139000
close(3) = 0
munmap(0x40012000, 48773) = 0
brk(0) = 0x804b728
brk(0x804c728) = 0x804c728
brk(0x804d000) = 0x804d000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_LARGEFILE) = 3
fstat64(3, {st_mode=S_IFREG|0644, st_size=1830272, ...}) = 0
mmap2(NULL, 1830272, PROT_READ, MAP_PRIVATE, 3, 0) = 0x4013d000
close(3) = 0
chroot("/home/www") = 0
chdir("/") = 0
execve("/bin/bash", ["/bin/bash", "-i"], [/* 23 vars */]) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/locale.alias", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/sh-utils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/sh-utils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/sh-utils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.UTF-8/LC_MESSAGES/sh-utils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/sh-utils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/sh-utils.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, "chroot: ", 8) = 8
write(2, "cannot execute /bin/bash", 24) = 24
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, ": No such file or directory", 27) = 27
write(2, "\n", 1) = 1
_exit(1) = ?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
sudo /usr/bin/chroot /home/chroot /bin/su - xxx| /bin/su: user xxx does not exist saavik Linux - General 3 07-04-2007 10:30 AM
troubles with SATA, troubles with NVIDIA aevangelica Linux - Hardware 6 10-17-2005 02:39 AM
chroot from CD to HD rossbob Linux - Software 1 04-19-2005 05:44 AM
Chroot Obie Linux - Security 1 08-04-2004 10:46 PM
to chroot or not to chroot complus Linux - Security 4 02-29-2004 04:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:06 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration