CHRoot Problem

HI ,

I am trying to setup chrooted environment on RHEL4, for squid proxy.
I have copied the required libraries and stuff for chroot. Used the below for chroot-shell .

user is squid
[root@CHROOT-TEST ~]# grep squid /etc/passwd
squid:x:500:501::/opt/squid:/bin/chroot-shell

directory trying to jail is /opt; user entry in chrooted environment
[root@CHROOT-TEST squid]# grep squid /opt/squid/etc/passwd
squid:x:500:501::/opt:/bin/bash

[root@CHROOT-TEST ~]# more /bin/chroot-shell
#! /bin/bash
if [ "$1" = "-c" ]; then
sudo /usr/sbin/chroot /opt/$USER /bin/su - $USER $*
else
sudo /usr/sbin/chroot /opt/$USER /bin/su - $USER
fi
[root@CHROOT-TEST ~]#

/etc/sudoers entry for sudo access.

squid ALL=NOPASSWD: /usr/sbin/chroot /opt/squid /bin/su - squid

Now when I login as root[super user] and try to switch to squid user it fails.

[root@CHROOT-TEST ~]# su - squid
/bin/su: incorrect password
[root@CHROOT-TEST ~]#

Even when I try to login directly as a squid user, terminal vanishes. Seems confusing.

Would gr8ly apprecaite if someone can help me in this....

Have followed the steps in this URL for the creation, and have not specifically installed coreutils..Not sure if it will make any difference.

http://www.tjw.org/chroot-login-HOWTO/

Try to run

/usr/sbin/chroot /opt/squid /bin/su - squid

directly. Are you sure you have copyed every needed lib into /opt/squid?
Have a look also to the auth log. I know it's obvious, but I have to ask you anyway. Did you set up a password for the squid user? :slight_smile: