Re: access to proc filesystem from chrooted process

Jeff Epler (jepler@inetnebr.com)
Sat, 22 May 1999 10:23:38 -0500


On Fri, May 21, 1999 at 03:14:31PM +0100, Riley Williams wrote:
> Are you referring to some means of mounting /proc so it appears
> visible to ALL processes no matter where they're chroot'd to? If so,
> I'd love to know how.
>
> Sure, I know that the proc file system does not have to be mounted
> over /proc (although it usually is), but I'd love to know how to mount
> it so that it's visible to two processes that are respectively
> chroot'd as follows:
>
> 1. /home/ftp (aka ~ftp)
>
> 2. /usr/mirrors (aka ~mirrors)
>
> As you can see, there are no common subdirectories between those two
> processes...

craie# id
uid=0(root) gid=405(jepler)
groups=405(jepler),0(root),6(disk),10(wheel),19(floppy)
craie# /bin/pwd
/tmp/proc-test
craie# for i in a b c d e f g; do mkdir $i; mount -t proc none
/tmp/proc-test/$i; done
craie# ls -l ?/self/exe
lrwx------ 1 root jepler 0 May 22 10:22 a/self/exe ->
/bin/ls
lrwx------ 1 root jepler 0 May 22 10:22 b/self/exe ->
/bin/ls
lrwx------ 1 root jepler 0 May 22 10:22 c/self/exe ->
/bin/ls
lrwx------ 1 root jepler 0 May 22 10:22 d/self/exe ->
/bin/ls
lrwx------ 1 root jepler 0 May 22 10:22 e/self/exe ->
/bin/ls
lrwx------ 1 root jepler 0 May 22 10:22 f/self/exe ->
/bin/ls
lrwx------ 1 root jepler 0 May 22 10:22 g/self/exe ->
/bin/ls

Just mount /proc in any place you want it.

Heck, you could even do something "fancy" like
#!/bin/sh
[ -d $1/proc ] || mkdir $1/proc
mount -t proc none $1/proc
exec /sbin/real-chroot $*
umount $1/proc # only if not a daemon

Jeff

-- 
\/ http://incolor.inetnebr.com/jepler/           Jeff Epler jepler@inetnebr.com
Send some filthy mail.

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.tux.org/lkml/