From owner-freebsd-hackers@FreeBSD.ORG Thu Jan 4 20:04:53 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 3D87016A412; Thu, 4 Jan 2007 20:04:53 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from server.baldwin.cx (66-23-211-162.clients.speedfactory.net [66.23.211.162]) by mx1.freebsd.org (Postfix) with ESMTP id BBC8913C45D; Thu, 4 Jan 2007 20:04:52 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from localhost.corp.yahoo.com (john@localhost [127.0.0.1]) (authenticated bits=0) by server.baldwin.cx (8.13.6/8.13.6) with ESMTP id l04K4g4p032386; Thu, 4 Jan 2007 15:04:42 -0500 (EST) (envelope-from jhb@freebsd.org) From: John Baldwin To: Oliver Fromme Date: Thu, 4 Jan 2007 14:59:17 -0500 User-Agent: KMail/1.9.1 References: <200701041803.l04I3oDo068148@lurza.secnetix.de> In-Reply-To: <200701041803.l04I3oDo068148@lurza.secnetix.de> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200701041459.18321.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [127.0.0.1]); Thu, 04 Jan 2007 15:04:45 -0500 (EST) X-Virus-Scanned: ClamAV 0.88.3/2413/Thu Jan 4 04:46:27 2007 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,AWL,BAYES_00 autolearn=ham version=3.1.3 X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on server.baldwin.cx 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 20:04:53 -0000 On Thursday 04 January 2007 13:03, Oliver Fromme wrote: > > 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 It's fixed in HEAD, I'll MFC the prototype fix for kenv() to 6.x. > > - 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? That sounds great. -- John Baldwin