newbie chroot problem - Redhat

This is a discussion on newbie chroot problem - Redhat ; Using CentOS 4.1 (RHEL equivalent) as root with bash as my shell, I reviewed the man pages and info for chroot, did ldd for /bin/bash, and got the following: # ldd /bin/bash libtermcap.so.2 => /lib/libtermcap.so.2 (0x00d77000) libdl.so.2 => /lib/libdl.so.2 (0x00c98000) ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: newbie chroot problem

  1. newbie chroot problem

    Using CentOS 4.1 (RHEL equivalent) as root with bash as my shell, I
    reviewed the man pages and info for chroot, did ldd for /bin/bash, and
    got the following:

    # ldd /bin/bash
    libtermcap.so.2 => /lib/libtermcap.so.2 (0x00d77000)
    libdl.so.2 => /lib/libdl.so.2 (0x00c98000)
    libc.so.6 => /lib/tls/libc.so.6 (0x00b48000)
    /lib/ld-linux.so.2 (0x00b2f000)
    [root@localhost /]#

    So I then created the following directory setup:

    # ls -Ral /crtest
    /crtest:
    total 24
    drwxr-xr-x 3 root root 4096 Aug 18 12:25 .
    drwxr-xr-x 26 root root 4096 Aug 18 12:48 ..
    drwxr-xr-x 4 root root 4096 Aug 18 12:22 crtest

    /crtest/crtest:
    total 32
    drwxr-xr-x 4 root root 4096 Aug 18 12:22 .
    drwxr-xr-x 3 root root 4096 Aug 18 12:25 ..
    drwxr-xr-x 2 root root 4096 Aug 18 12:23 bin
    drwxr-xr-x 3 root root 4096 Aug 17 17:15 lib

    /crtest/crtest/bin:
    total 780
    drwxr-xr-x 2 root root 4096 Aug 18 12:23 .
    drwxr-xr-x 4 root root 4096 Aug 18 12:22 ..
    -rwxr-xr-x 1 root root 772760 Feb 17 20:30 bash

    /crtest/crtest/lib:
    total 168
    drwxr-xr-x 3 root root 4096 Aug 17 17:15 .
    drwxr-xr-x 4 root root 4096 Aug 18 12:22 ..
    -rwxr-xr-x 1 root root 93256 Jun 9 20:40 ld-2.3.4.so
    lrwxrwxrwx 1 root root 11 Aug 18 12:48 ld-linux.so.2 -> ld-2.3.4.so
    -rwxr-xr-x 1 root root 11168 Jun 9 20:40 libdl-2.3.4.so
    lrwxrwxrwx 1 root root 14 Aug 18 12:48 libdl.so.2 -> libdl-2.3.4.so
    lrwxrwxrwx 1 root root 19 Aug 18 12:48 libtermcap.so.2 ->
    libtermcap.so.2.0.8
    -rwxr-xr-x 1 root root 10884 Feb 21 14:55 libtermcap.so.2.0.8
    drwxr-xr-x 2 root root 4096 Aug 17 17:10 tls

    /crtest/crtest/lib/tls:
    total 1216
    drwxr-xr-x 2 root root 4096 Aug 17 17:10 .
    drwxr-xr-x 3 root root 4096 Aug 17 17:15 ..
    -rwxr-xr-x 1 root root 1212936 Jun 9 20:40 libc-2.3.4.so
    lrwxrwxrwx 1 root root 13 Aug 18 12:48 libc.so.6 -> libc-2.3.4.so
    [root@localhost /]#

    Then, when I try chroot /crtest I get:

    # chroot /crtest
    chroot: cannot run command `/bin/bash': No such file or directory
    [root@localhost /]#

    Obviously, I am missing something here.

    Any help appreciated.

    Thanks

    Apollo

  2. Re: newbie chroot problem

    apollo wrote:

    [Snip]

    > /crtest/crtest/bin:
    > total 780
    > drwxr-xr-x 2 root root 4096 Aug 18 12:23 .
    > drwxr-xr-x 4 root root 4096 Aug 18 12:22 ..
    > -rwxr-xr-x 1 root root 772760 Feb 17 20:30 bash


    [Snip]

    > Then, when I try chroot /crtest I get:
    >
    > # chroot /crtest
    > chroot: cannot run command `/bin/bash': No such file or directory
    > [root@localhost /]#
    >
    > Obviously, I am missing something here.


    I had to look a while to spot it, but it's actually quite simple. You
    chroot to /crtest, but all that is there is *another* crtest directory,
    where there should have been your new root system. Either move the new
    root hierarchy up one level or use chroot /crtest/crtest.

    Note that running ldd on a binary is just a minimum requirement for the
    app to even start. Other libraries and configuration files may be
    required for certain functionality later on. Best of luck with whatever
    you're doing.

    --
    PeKaJe

    BOFH Excuse #368:
    Failure to adjust for daylight savings time.

  3. Re: newbie chroot problem

    Peter Jensen wrote:
    > apollo wrote:
    >
    > [Snip]
    >
    >
    >>/crtest/crtest/bin:
    >>total 780
    >>drwxr-xr-x 2 root root 4096 Aug 18 12:23 .
    >>drwxr-xr-x 4 root root 4096 Aug 18 12:22 ..
    >>-rwxr-xr-x 1 root root 772760 Feb 17 20:30 bash

    >
    >
    > [Snip]
    >
    >
    >>Then, when I try chroot /crtest I get:
    >>
    >># chroot /crtest
    >>chroot: cannot run command `/bin/bash': No such file or directory
    >>[root@localhost /]#
    >>
    >>Obviously, I am missing something here.

    >
    >
    > I had to look a while to spot it, but it's actually quite simple. You
    > chroot to /crtest, but all that is there is *another* crtest directory,
    > where there should have been your new root system. Either move the new
    > root hierarchy up one level or use chroot /crtest/crtest.
    >
    > Note that running ldd on a binary is just a minimum requirement for the
    > app to even start. Other libraries and configuration files may be
    > required for certain functionality later on. Best of luck with whatever
    > you're doing.
    >


    Opps, my bad. That happened in the course of transferred the test to a
    box with usenet access. Redid it as I had intended and reposted the problem.

    Thanks for getting me past THAT booboo.

    Apollo

+ Reply to Thread