From owner-freebsd-hackers@FreeBSD.ORG Thu Jan 4 18:04:01 2007 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 4AFF516A403; Thu, 4 Jan 2007 18:04:01 +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 AB1ED13C43E; Thu, 4 Jan 2007 18:04:00 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (jylqnu@localhost [127.0.0.1]) by lurza.secnetix.de (8.13.4/8.13.4) with ESMTP id l04I3px9068149; Thu, 4 Jan 2007 19:03:56 +0100 (CET) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.13.4/8.13.1/Submit) id l04I3oDo068148; Thu, 4 Jan 2007 19:03:50 +0100 (CET) (envelope-from olli) From: Oliver Fromme Message-Id: <200701041803.l04I3oDo068148@lurza.secnetix.de> To: jhb@freebsd.org (John Baldwin) Date: Thu, 4 Jan 2007 19:03:50 +0100 (CET) In-Reply-To: <200701041235.37141.jhb@freebsd.org> X-Mailer: ELM [version 2.5 PL8] MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Thu, 04 Jan 2007 19:03:57 +0100 (CET) X-Mailman-Approved-At: Thu, 04 Jan 2007 21:10:23 +0000 Cc: erik.udo@gmail.com, freebsd-hackers@freebsd.org, dougb@freebsd.org Subject: Re: Init.c, making it chroot X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 04 Jan 2007 18:04:01 -0000 John Baldwin wrote: > Oliver Fromme wrote: > > I've created (and tested!) a new patch. I've tested on > > RELENG_6, but I think init(8) isn't very different on > > HEAD, so it should work there, too. > > > > Any comments are welcome. I particularly appreciate > > if others test this stuff. > > Some things I noticed: > > - Why do you have the 'ichroot_name' and 'iscript_name' variables? I would > just pass the string literal to the kenv() function, e.g. > > if (kenv(KENV_GET, "init_script", kenv_value, sizeof(kenv_value)) > 0) { > > I think that putting the constant right there is easier for someone who > is reading the code to see what is going on. In fact that's what I tried first ... Alas: warning: passing arg 2 of `kenv' discards qualifiers from pointer target type > - Rather than abusing a global runcom_script variable that you change to > get side effects when you invoke runcom(), why not change runcom() to > take a single 'char *script' as an argument and just pass _PATH_RUNCOM > or kenv_value as appropriate and get rid of the global runcom_script > variable? You are right, the global runcom_script variable does not look very clean. However, the problem is that runcom() is one of the transition action functions, i.e. it is called by the transition() function and never gets an argument. Of course it is possible to write an additional function run_script(char *script) which contains runcom's current code, and make the runcom() function a wrapper that just calls run_script(_PATH_RUNCOM). This isn't a perfectly clean solution either, but maybe it's at least a little bit better. e.g. basically: state_func_t runcom (void) { return run_script(_PATH_RUNCOM); } state_func_t run_script (char *script) { /* all the code formerly in runcom() */ } Then the init_script code would call run_script(kenv_value) instead of runcom(), of course. Would that be acceptable? Or do you have an even better solution in mind? Best regards Oliver -- 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. "If Java had true garbage collection, most programs would delete themselves upon execution." -- Robert Sewell