From owner-freebsd-hackers@FreeBSD.ORG Thu Dec 28 12:37:22 2006 Return-Path: X-Original-To: freebsd-hackers@FreeBSD.ORG Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 68BDC16A412 for ; Thu, 28 Dec 2006 12:37:22 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (lurza.secnetix.de [83.120.8.8]) by mx1.freebsd.org (Postfix) with ESMTP id CCAF913C475 for ; Thu, 28 Dec 2006 12:37:21 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (hsrqxa@localhost [127.0.0.1]) by lurza.secnetix.de (8.13.4/8.13.4) with ESMTP id kBSCbF3c047392; Thu, 28 Dec 2006 13:37:20 +0100 (CET) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.13.4/8.13.1/Submit) id kBSCbE2n047391; Thu, 28 Dec 2006 13:37:14 +0100 (CET) (envelope-from olli) Date: Thu, 28 Dec 2006 13:37:14 +0100 (CET) Message-Id: <200612281237.kBSCbE2n047391@lurza.secnetix.de> From: Oliver Fromme To: freebsd-hackers@FreeBSD.ORG, erik.udo@gmail.com In-Reply-To: <4592C91C.2040801@gmail.com> X-Newsgroups: list.freebsd-hackers User-Agent: tin/1.8.2-20060425 ("Shillay") (UNIX) (FreeBSD/4.11-STABLE (i386)) X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Thu, 28 Dec 2006 13:37:20 +0100 (CET) Cc: Subject: Re: Init.c, making it chroot X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd-hackers@FreeBSD.ORG, erik.udo@gmail.com List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 28 Dec 2006 12:37:22 -0000 Erik Udo wrote: > How can i make init chroot after executing /etc/rc, and executing > /etc/rc again in the chrooted enviroment? > > For this to work, i'd like to know at what point do i call chroot(), > becouse init.c uses fork() at the point where it runs the rc script. > > The thing is, i want to run a whole system in a chrooted enviroment in > this livecd i'm making. But the command "chroot /mnt/root /etc/rc" > returns after the /etc/rc has been run, dropping me back from the > chrooted enviroment. And if it doesn't, init never starts the multiuser > mode. That's exactly the problem I had when I created a combined DVD-ROM with FreeBSD and DragonFly BSD on it. For them to share the same ISO-9660, at least one of them needed to be chrooted. I decided to add the feature to DragonFly BSD's init(8) because the DragonFly people seemed to be easier to convince of the usefulness. ;-) Indeed, the feature was committed quickly. I didn't try to send-pr a similar patch for FreeBSD. It shouldn't be too difficult to port it, though: http://www.dragonflybsd.org/cvsweb/src/sbin/init/init.c The chroot() patch has been committed with r1.6. It uses kenv to specify the chroot directory, so it can easily be set by the loader(8), e.g. using a custom boot menu. Best regards Oliver PS: I see NetBSD has a similar feature, too. Maybe FreeBSD should join the crowd and adopt it. ;-) -- Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing Dienstleistungen mit Schwerpunkt FreeBSD: http://www.secnetix.de/bsd Any opinions expressed in this message may be personal to the author and may not necessarily reflect the opinions of secnetix in any way. "Python tricks" is a tough one, cuz the language is so clean. E.g., C makes an art of confusing pointers with arrays and strings, which leads to lotsa neat pointer tricks; APL mistakes everything for an array, leading to neat one-liners; and Perl confuses everything period, making each line a joyous adventure . -- Tim Peters