[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: chroot weirdness with hostnames



On Sat, 2007-10-20 at 19:34 -0700, Todd A. Jacobs wrote:
> I've created a chroot and placed "sid" into the /etc/debian_chroot file
> inside the jail. If I use schroot as a mortal, I see the chroot
> hostname, but if I change to the chroot as root, or su to root inside
> the chroot itself, I see the original hostname.
> 
> Why isn't the chrooted-root account seeing the /etc/debian_chroot name
> at the bash prompt?

The following assumes that you are referring to the hostname displayed
as part of your shell prompt.

I believe that if you check the respective .bashrc of these accounts,
you will find that the "mortal" account contains something like this:

# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "$debian_chroot" -a -r /etc/debian_chroot ]; then
    debian_chroot=$(cat /etc/debian_chroot)
fi

# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color)
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
    ;;
*)
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
    ;;
esac
 	


Whereas the root account does not. Add these lines to the root .bashrc,
and your root prompt will also reflect the current chroot.

-davidc

-- 
gpg-key: http://www.zettazebra.com/files/key.gpg

Attachment: signature.asc
Description: This is a digitally signed message part


Reply to: