PERFORCE change 99406 for review
John Baldwin
jhb at freebsd.org
Tue Jun 20 13:59:20 UTC 2006
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 at 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
More information about the p4-projects
mailing list