* chroot(1) oddity
@ 1994-11-15 14:49 Mark Bartelt
1994-11-15 20:02 ` SUMMARY: " Mark Bartelt
1994-11-22 20:22 ` Joerg Czeranski
0 siblings, 2 replies; 3+ messages in thread
From: Mark Bartelt @ 1994-11-15 14:49 UTC (permalink / 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)" ]
^ permalink raw reply [flat|nested] 3+ messages in thread* SUMMARY: chroot(1) oddity
1994-11-15 14:49 chroot(1) oddity Mark Bartelt
@ 1994-11-15 20:02 ` Mark Bartelt
1994-11-22 20:22 ` Joerg Czeranski
1 sibling, 0 replies; 3+ messages in thread
From: Mark Bartelt @ 1994-11-15 20:02 UTC (permalink / raw)
I've had a few replies to my query from earlier today re chroot(1). None
of them were completely on-target, but one was close (see below). I had
one suggestion that /etc/svc.conf was needed in the chrooted directory,
but by the time that suggestion arrived, I'd already had a look at that
possibility (a sensible one, since svc.conf has a "passwd=" entry, so who
knows what might happen if svc.conf were missing?), but it turns out that
it isn't needed. (One can actually infer this without checking, by doing
an "ls -l" (from a non-chrooted environment, of courrse), and then doing a
"ls -lu /etc/svc.conf", and noticing that its atime doesn't change.)
The best suggestion came from Joseph McGuire (joe@alpha.vyne.com), who said
I beleive that you need to create the (dir and) file
CHROOTDIR/bin/sia/siainitgood. [ ... ]
Actually, he meant /etc/sia/siainitgood. As it turns out, that's not quite
enough (it's necessary but not sufficient). What you *really* need in the
chrooted environment for "ls" to map numeric uids and gids to user and group
names is the following:
etc/group
etc/passwd.dir
etc/passwd.pag
etc/sia/bsd_matrix.conf
etc/sia/matrix.conf
etc/sia/siainitgood
I had the first three; Joe suggestd the last. But you also need those .conf
files in the etc/sia directory (matrix.conf is a symlink to bsd_matrix.conf).
By the way, in case anyone thinks that this is a pretty trivial problem to be
worrying about, this isn't actually what prompted the original posting in the
first place. The *real* problem is that we have an application which we want
to run chroot'ed, and it couldn't run because calls to getpwuid() failed, and
in the course of investigating *that* problem, I discovered that even things
like the "ls" example failed.
Anyway, all is now working happily. Thanks for the suggestions, everyone!
Mark Bartelt 416/978-5619
Canadian Institute for mark@cita.toronto.edu
Theoretical Astrophysics mark@cita.utoronto.ca
"Sheep not busy being shorn are busy frying" - Dylan, at a NZ lamb barbecue
[ singing "It's all right, ma (I'm only bleating)" ]
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: chroot(1) oddity
1994-11-15 14:49 chroot(1) oddity Mark Bartelt
1994-11-15 20:02 ` SUMMARY: " Mark Bartelt
@ 1994-11-22 20:22 ` Joerg Czeranski
1 sibling, 0 replies; 3+ messages in thread
From: Joerg Czeranski @ 1994-11-22 20:22 UTC (permalink / raw)
Mark Bartelt (sysmark@helios.physics.utoronto.ca) wrote:
> [...]
> 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
>
> [...]
>
> 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.
I think /etc/svc.conf is missing. It tells getpwuid(3) where to look
for user names (YP or /etc or both).
joerg
--
Joerg Czeranski EMail czeranski@informatik.tu-clausthal.de
Osteroeder Strasse 55 czeranski@rz.tu-clausthal.de
D 38678 Clausthal-Zellerfeld WWW http://www.rz.tu-clausthal.de/~injc/
1
2
3 [these lines added to decept our news server]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1994-11-22 20:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1994-11-15 14:49 chroot(1) oddity Mark Bartelt
1994-11-15 20:02 ` SUMMARY: " Mark Bartelt
1994-11-22 20:22 ` Joerg Czeranski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox