From owner-p4-projects@FreeBSD.ORG Tue Jun 20 13:59:20 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 2A60F16A47E; Tue, 20 Jun 2006 13:59:20 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C6BB516A47B; Tue, 20 Jun 2006 13:59:19 +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 34B6243D46; Tue, 20 Jun 2006 13:59:19 +0000 (GMT) (envelope-from jhb@freebsd.org) Received: from zion.baldwin.cx (zion.baldwin.cx [192.168.0.7]) (authenticated bits=0) by server.baldwin.cx (8.13.4/8.13.4) with ESMTP id k5KDxBKL027879; Tue, 20 Jun 2006 09:59:17 -0400 (EDT) (envelope-from jhb@freebsd.org) From: John Baldwin To: Divacky Roman Date: Tue, 20 Jun 2006 09:16:32 -0400 User-Agent: KMail/1.9.1 References: <200606170857.k5H8vYVk017130@repoman.freebsd.org> <200606191002.26358.jhb@freebsd.org> <20060620091807.GA99542@stud.fit.vutbr.cz> In-Reply-To: <20060620091807.GA99542@stud.fit.vutbr.cz> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200606200916.32572.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH authentication, not delayed by milter-greylist-2.0.2 (server.baldwin.cx [192.168.0.1]); Tue, 20 Jun 2006 09:59:17 -0400 (EDT) X-Virus-Scanned: ClamAV 0.87.1/1550/Mon Jun 19 13:01:35 2006 on server.baldwin.cx X-Virus-Status: Clean X-Spam-Status: No, score=-4.4 required=4.2 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.1.0 X-Spam-Checker-Version: SpamAssassin 3.1.0 (2005-09-13) on server.baldwin.cx Cc: Roman Divacky , Perforce Change Reviews Subject: Re: PERFORCE change 99406 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 20 Jun 2006 13:59:20 -0000 On Tuesday 20 June 2006 05:18, Divacky Roman wrote: > On Mon, Jun 19, 2006 at 10:02:25AM -0400, John Baldwin wrote: > > On Saturday 17 June 2006 04:57, Roman Divacky wrote: > > > http://perforce.freebsd.org/chv.cgi?CH=99406 > > > > > > Change 99406 by rdivacky@rdivacky_witten on 2006/06/17 08:56:59 > > > > > > Change the emulpath sysctl to be per-prison. > > > > > > ==== //depot/projects/soc2006/rdivacky_linuxolator/compat/linux/linux_mib.c#3 (text+ko) ==== > > > > > > @@ -90,7 +90,7 @@ > > > static int > > > linux_sysctl_linux_emul_path(SYSCTL_HANDLER_ARGS) > > > { > > > - char emul_path[LINUX_NAME_MAX]; > > > + static char emul_path[LINUX_NAME_MAX]; > > > int error; > > > Elf32_Brandinfo **brandinfo; > > > > > > @@ -99,10 +99,39 @@ > > > if (error || req->newptr == NULL) > > > return (error); > > > error = linux_set_emul_path(req->td, emul_path); > > > - for (brandinfo = &linux_brandlist[0]; *brandinfo != NULL; > > > - ++brandinfo) > > > - if (elf32_insert_brand_entry(*brandinfo) < 0) > > > - error = EINVAL; > > > + { > > > + static Elf32_Brandinfo linux_brand = { > > > + ELFOSABI_LINUX, > > > + EM_386, > > > + "Linux", > > > + emul_path, > > > + "/lib/ld-linux.so.1", > > > + &elf_linux_sysvec, > > > + NULL, > > > + BI_CAN_EXEC_DYN, > > > + }; > > > + static Elf32_Brandinfo linux_glibc2brand = { > > > + ELFOSABI_LINUX, > > > + EM_386, > > > + "Linux", > > > + emul_path, > > > + "/lib/ld-linux.so.2", > > > + &elf_linux_sysvec, > > > + NULL, > > > + BI_CAN_EXEC_DYN, > > > + }; > > > + > > > + Elf32_Brandinfo *local_linux_brandlist[] = { > > > + &linux_brand, > > > + &linux_glibc2brand, > > > + NULL > > > + }; > > > + > > > + for (brandinfo = &local_linux_brandlist[0]; *brandinfo != NULL; > > > + ++brandinfo) > > > + if (elf32_insert_brand_entry(*brandinfo) < 0) > > > + error = EINVAL; > > > + } > > > return (error); > > > } > > > > I don't think this is going to work because the brand lists aren't > > per-prison, they are one shared list. That is, once you create a > > jail and try to change the path, the insert's will add new entries > > to the end of the list, but an earlier entry for another jail > > might handle the binary instead. Also, elf32_insert_brand_entry() > > hm... so there's no (easy) way to do it per-prison, right? Not really. I think if people want to use different linuxulators for different jails they should just use different chroot's with different /compat/linux contents to be honest. > > saves the pointer you pass to it, and your pointers are for variables > > that are on the stack which will become garbage when this function > > returns. > > the variable is declared static so it should work Ah, I had looked for static but missed it. That means the setting isn't per-jail though. This path is used to lookup rtld when executing the ELF binary. Since these variables are static, each time you execute a Linux binary it would use whichever prefix was set last for _all_ jails. -- John Baldwin