From: sysmark@helios.physics.utoronto.ca (Mark Bartelt)
Subject: chroot(1) oddity
Date: Tue, 15 Nov 1994 14:49:23 GMT [thread overview]
Message-ID: <CzBD6C.8xz@info.physics.utoronto.ca> (raw)
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)" ]
next reply other threads:[~1994-11-15 14:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1994-11-15 14:49 Mark Bartelt [this message]
1994-11-15 20:02 ` SUMMARY: chroot(1) oddity Mark Bartelt
1994-11-22 20:22 ` Joerg Czeranski
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox