Date: Thu, 4 Jan 2007 19:03:50 +0100 (CET) From: Oliver Fromme <olli@lurza.secnetix.de> To: jhb@freebsd.org (John Baldwin) Cc: erik.udo@gmail.com, freebsd-hackers@freebsd.org, dougb@freebsd.org Subject: Re: Init.c, making it chroot Message-ID: <200701041803.l04I3oDo068148@lurza.secnetix.de> In-Reply-To: <200701041235.37141.jhb@freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200701041803.l04I3oDo068148>