From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,5f38e5e28d081a6d,start X-Google-Attributes: gidfee84,public X-Google-ArrivalTime: 1994-11-15 08:57:30 PST Newsgroups: comp.unix.osf.osf1 Path: nntp.gmd.de!xlink.net!howland.reston.ans.net!cs.utexas.edu!utnut!info.physics.utoronto.ca!sysmark From: sysmark@helios.physics.utoronto.ca (Mark Bartelt) Subject: chroot(1) oddity Message-ID: Nntp-Posting-Host: helios.physics.utoronto.ca Sender: news@info.physics.utoronto.ca (System Administrator) Reply-To: mark@cita.toronto.edu Organization: Canadian Institute for Theoretical Astrophysics Date: Tue, 15 Nov 1994 14:49:23 GMT OK, I've RedTFM, but I confess that I'm still mystified by the following: WALRUS> pwd /home/sys/tmp/spam WALRUS> WALRUS> ls -l total 2 drwxr-xr-x 2 root system 512 Nov 15 09:31 etc drwxr-xr-x 2 root system 512 Nov 15 09:31 sbin WALRUS> WALRUS> ls -l */* -rwxr-xr-x 1 root system 316 Nov 15 09:31 etc/group -rw-r--r-- 1 root system 6241 Nov 15 09:31 etc/passwd -rw-r--r-- 1 root system 4096 Nov 15 09:31 etc/passwd.dir -rw-r--r-- 1 root system 25600 Nov 15 09:31 etc/passwd.pag -rwxr-xr-x 1 root system 131072 Nov 15 09:31 sbin/cat -rwxr-xr-x 1 root system 393216 Nov 15 09:31 sbin/ls -rwxr-xr-x 1 root system 221184 Nov 15 09:31 sbin/sh WALRUS> WALRUS> chroot `pwd` /sbin/sh WALRUS> WALRUS> pwd / WALRUS> ls -l total 2 drwxr-xr-x 2 0 0 512 Nov 15 09:31 etc drwxr-xr-x 2 0 0 512 Nov 15 09:31 sbin WALRUS> WALRUS> ls -l */* -rwxr-xr-x 1 0 0 316 Nov 15 09:31 etc/group -rw-r--r-- 1 0 0 6241 Nov 15 09:31 etc/passwd -rw-r--r-- 1 0 0 4096 Nov 15 09:31 etc/passwd.dir -rw-r--r-- 1 0 0 25600 Nov 15 09:31 etc/passwd.pag -rwxr-xr-x 1 0 0 131072 Nov 15 09:31 sbin/cat -rwxr-xr-x 1 0 0 393216 Nov 15 09:31 sbin/ls -rwxr-xr-x 1 0 0 221184 Nov 15 09:31 sbin/sh It is true that the manpage says Several programs may not operate properly after chroot executes. For exam- ple, the ls -l command fails to give user and group names if the current root location and the /etc/passwd file are on different file systems. However, it also goes on to say that You must ensure that all vital data files are present in the new root file system and that the relevant pathnames for the data files correspond to the new root file system. To me, this implies that things like "ls" *should* work, provided all of the necessary files it needs are in the appropriate locations in the directory to which one is chroot()ing. In this case, the files in `pwd`/etc are the ones from /etc, and the files in `pwd`/sbin are taken from /sbin, so they wouldn't be dynamically linked a.outs. So, is something broken? Or is some critical file missing from the hierarchy that I'm chroot()ing to in the example above? (And, if the latter, what have I overlooked?) As usual, many TIA. PS: The above approach (using versions of "sh", "ls", etc. which don't use shared libraries, and putting the password and group files in CHROOTDIR/etc) works fine under IRIX (and, I think, other UNIXes). Mark Bartelt 416/978-5619 Canadian Institute for mark@cita.toronto.edu Theoretical Astrophysics mark@cita.utoronto.ca "Clothes not busy being worn are busy drying." - Dylan, on laundry day [ singing "It's all right, ma (I'm only bleaching)" ]