LinuxQuestions.org
View the Most Wanted LQ Wiki articles.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices



Reply
 
Search this Thread
Old 11-11-2005, 12:03 PM   #1
seraph-seph
Member
 
Registered: Jul 2005
Location: /dev/ATX3
Distribution: Slackware 11(kernel 2.6.17.13), SuSE 10, Caldera, CentOS 4.3
Posts: 38

Rep: Reputation: 15
chroot: No such file or directory PROBLEM


Hi there.

Well I have Slackware 10.2 and i'm trying to execute a command with a diferent root directory, to be specific i'm trying to execute apache ...my problem it's simple:

I type:

Code:
chroot /chroot/server/ /usr/local/apache2/bin/httpd
the reply is chroot: cannot run command `/usr/local/apache2/bin/httpd': No such file or directory, and I know for sure that the file is there.

dir /usr/local/apache2/bin/

ab* apr-config* apxs* dbmmanage* envvars-std htdigest* httpd* rotatelogs*
apachectl* apu-config* checkgid* envvars htdbm* htpasswd* logresolve*

So I don't really know what's the problem.. so .. if anybody knows the problem .. let me know

_Seraph-Seph_
 
Old 11-11-2005, 12:17 PM   #2
Nobber
Member
 
Registered: Jun 2002
Location: Nova Scotia
Distribution: Debian (home), Kubuntu 7.04 (work)
Posts: 265

Rep: Reputation: 30
But isn't your chroot command trying to run

/chroot/server/usr/local/apache2/bin/httpd

(as seen from the regular root filesystem)?
 
Old 11-11-2005, 12:20 PM   #3
seraph-seph
Member
 
Registered: Jul 2005
Location: /dev/ATX3
Distribution: Slackware 11(kernel 2.6.17.13), SuSE 10, Caldera, CentOS 4.3
Posts: 38

Original Poster
Rep: Reputation: 15
no, the syntax is

chroot DIRECTORYWHERETOEXECUTE COMMANDTOBEEXECUTED
 
Old 11-11-2005, 12:25 PM   #4
Nobber
Member
 
Registered: Jun 2002
Location: Nova Scotia
Distribution: Debian (home), Kubuntu 7.04 (work)
Posts: 265

Rep: Reputation: 30
Yes but COMMANDTOBEEXECUTED is "relative" to the new root directory DIRECTORYWHERETOEXECUTE. I am 87.3% sure of that!
 
Old 11-11-2005, 12:38 PM   #5
seraph-seph
Member
 
Registered: Jul 2005
Location: /dev/ATX3
Distribution: Slackware 11(kernel 2.6.17.13), SuSE 10, Caldera, CentOS 4.3
Posts: 38

Original Poster
Rep: Reputation: 15
The file /chroot/server/usr/local/apache2/bin/httpd also exist.... I understand your point ... and you're right it's relaive so the httpd command file must exist too,

/chroot/server/usr/local/apache2/bin/httpd
/usr/local/apache2/bin/httpd

Both of them exist
 
Old 11-13-2005, 04:33 PM   #6
zhizaki
Member
 
Registered: Sep 2005
Location: Austin, TX
Distribution: Slackware
Posts: 31

Rep: Reputation: 15
To the best of my knowledge this is how the chroot man is used:

/usr/sbin/chroot /chroot/apache/ /usr/sbin/httpd

The first part ' /usr/sbin/chroot' is simply the full path to chroot.

The second part '/chroot/apache/' is the directory you want to become '/' for your chroot jail

The third part '/usr/sbin/httpd' is the command *WITHIN* the chroot jail that you want to execute.


I've been working on a Slackware Apache chroot package for the last couple of days, and I've come across many things in this little endevor. Remember to include things like /bin/sh and it's dependencies, as well as all necessary dependencies for everything in the apache system. Without these it doesn't work. /bin/sh alone is needed simply to execute script from within the chroot, or at least that's what my experimentation has lead me to believe. To test this theory, try to do 'ls -l' from inside the chroot jail by doing the following:

mkdir -p /chroot/bin <<< or whatever your chroot dir will be.
mkdir /chroot/lib

ldd /bin/sh << displays dependencies for the executable. Normally these are lib* files located in /lib
cp /lib/libnecssary.libs* /chroot/lib/ <<< copy them into the chroot jail

ldd /bin/ls << same as above
cp /lib/libwhatever /chroot/lib/ <<< copy any necessary libs over here too.

......Then test it by trying the following command:

chroot /chroot/ /bin/ls -l /

What you should see is a very simple ls -l of the jailed / filesystem.
 
Old 01-17-2010, 09:37 PM   #7
Bob D
LQ Newbie
 
Registered: Jan 2010
Posts: 12

Rep: Reputation: 0
Keywords: chroot update-grub

(Bottom line: /sbin/update-grub won't chroot because it's only a SCRIPT now, at least in ubuntu lucid 10.04). Are there more scripts in /sbin? Bet that won't break anything, will it? Anybody know the package name for the security update which is just a script to examine the first bytes of every expected bin in /sbin, looking for telltale "#!/bin/bash haha your bin be hours now" in the first 40 bytes of expected binaries.

Duh. The real update-grub dep-free bin is in /usr/sbin/update-grub.

#####mkdir -p /mnt/sbin
#####cp /sbin/update-grub /mnt/sbin
#####sudo chroot /mnt /sbin/update-grub

sudo mkdir -p /mnt/usr/sbin

sudo cp /usr/sbin/update-grub /mnt/usr/sbin

sudo chroot /mnt /usr/sbin/update-grub

/bin/sash is a shell having no deps(like the REAL update-grub!). You might want to put sash in your chroot jail to help figure things out.
 
Old 01-17-2010, 10:12 PM   #8
Bob D
LQ Newbie
 
Registered: Jan 2010
Posts: 12

Rep: Reputation: 0
Back in the last century, a few noids had /usr on a separate partition. That would mean all fscked up in init=/bin/sash, with no way to fix boot sector or fsck md's. Don't worry, just be happy like a window, let it all shine on through, yeah, do me like a window. I must have left my window open last night cuz boot initland tools are all on /usr partition now.

Get a usbkey with tools on it.

I am. That's what I'm doing, making a usbkey with tools. Or I'd be like a window.
 
Old 01-18-2010, 06:39 AM   #9
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 5,390

Rep: Reputation: Disabled
@Bob D

When are you going to make an actual contribution to this thread? This is Slackware, there was no talk about GRUB until you started. Slackware doesn't even install GRUB. We do not have "sash" in Slackware and why the heck would the OP have to create a USB key in order to populate his chroot environment?

Get off the dope before you answer next time. Excellent first two posts to LQ...

Eric
 
Old 01-18-2010, 06:42 AM   #10
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware & Slackware64 14.1
Posts: 7,139
Blog Entries: 52

Rep: Reputation: Disabled
It's nearly 5 years old, anyway.
 
Old 06-01-2010, 09:35 AM   #11
brickno
LQ Newbie
 
Registered: Jun 2010
Posts: 1

Rep: Reputation: 0
Thumbs up

It wasn't until I read zhizaki's post above that it all came clear. I was working on an inherited apache chroot and had a similar problem with rotatelogs.

Error on startup:
Command to Run:
/bin/chroot /chroot/apache2 /usr/local/apache2/bin/httpd
[error] (2)No such file or directory: exec of '/usr/local/apache2/bin/rotatelogs' failed

Issue fixed:
by adding /bin/sh to the chroot and checking dependencies with ldd.

HOSTNAME:/chroot/apache2 # ldd /bin/sh
linux-vdso.so.1 => (0x00007fccce79b000)
libtermcap.so.2 => /lib64/libtermcap.so.2 (0x00007fccce37d000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fccce179000)
libc.so.6 => /lib64/libc.so.6 (0x00007fcccde1c000)
/lib64/ld-linux-x86-64.so.2 (0x00007fccce580000)


Simply copy /bin/sh into /chroot/apache2/bin/
Then confirm that all libs found with ldd are also present in the chroot.
cp /lib64/libtermcap.so.2 /chroot/apache2/lib64/libtermcap.so.2
cp /lib64/libdl.so.2 /chroot/apache2/lib64/libdl.so.2
...etc

Stop apache(if running) and start again.
My thanks go to you zhizaki.
If issues persist, I suggest going through the chroot setup process step-by-step and confirm all parts are complete.
 
Old 06-02-2010, 08:31 AM   #12
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,775

Rep: Reputation: 481Reputation: 481Reputation: 481Reputation: 481Reputation: 481
I think chroot itself must also be found inside the chroot path.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
chroot: cannot run command `/tools/bin/env': No such file or directory Basel Linux From Scratch 5 06-30-2006 04:00 AM
Accessing automount directory using chroot prakashpms Linux - Security 1 06-24-2004 06:17 PM
vsftpd home directory and chroot avante Linux - Networking 4 03-17-2003 02:56 AM
chroot problem (thinks 'env' is a directory) d33pdream Linux - General 1 02-23-2003 03:11 PM
Chroot (FTP,Home Directory) Thanewbie Linux - Security 2 05-14-2001 03:49 AM


All times are GMT -5. The time now is 11:03 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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration