Page MenuHomeFreeBSD

jail: consistently populate the KP_JID and KP_NAME parameters
ClosedPublic

Authored by kevans on Thu, Jul 24, 6:38 PM.
Tags
None
Referenced Files
F125613571: D51502.diff
Sat, Aug 9, 11:30 PM
Unknown Object (File)
Tue, Jul 29, 12:41 AM
Unknown Object (File)
Tue, Jul 29, 12:01 AM
Unknown Object (File)
Mon, Jul 28, 5:35 PM
Unknown Object (File)
Mon, Jul 28, 3:06 PM
Unknown Object (File)
Mon, Jul 28, 3:05 PM
Unknown Object (File)
Mon, Jul 28, 2:36 PM
Unknown Object (File)
Mon, Jul 28, 12:56 PM
Subscribers

Details

Summary

The gaps here, specifically, were:

  • When we have to discover a running jail's jid from name, we should populate the missing jid param
  • When we populate jid/name from the config, if the name is a jid we wouldn't populate the name; now we do both.
  • When we create a jail, we should populate jid and name with whatever details we have now that we didn't both.

As a consequence, we can cleanup a few things:

  • vnet.interface and zfs.dataset can just always the jid
  • Trying to populate JNAME should always work now, where it would be a little crashy before if you create a jail that didn't have a name or jid on the command line
  • We can simplify the just-prior JID population now that we'll keep a stringified jid in our intparams.

This primarily fixes the below, but the issues with vnet.interface and
zfs.dataset were pre-existing.

Fixes: d8f021add40c3 ("jail: add JID, JNAME and JPATH to env [...]")

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Skipped
Unit
Tests Skipped
Build Status
Buildable 65746
Build 62629: arc lint + arc unit

Event Timeline

usr.sbin/jail/config.c
165–166

This breaks "they may explicitly be set later on." This little config file will yield 'cannot redefine parameter "name".'

47 { name=foo; persist; }

This could be moved after the "collect parameters" section. Then you can test and silently ignore if the name was already set.

usr.sbin/jail/config.c
165–166

Oh, interesting; I guess I assumed from the comment that was already there that this one would simply be overwritten if it was specified later. I'll add some more tests and fix it.

Fix name-override bit

This uses my proposed jls -c from https://reviews.freebsd.org/D51541, but I'll
happily unwind that if we don't like the idea of -c.

usr.sbin/jail/config.c
190

I think namep is redundant, since the only reason for intparams[KP_NAME] to be unset is the same condition that sets namep=KP_JID (that j->name was numeric).

usr.sbin/jail/config.c
190

Oh, good point.

Revert more of the config.c diff; amending the comment and checking for KP_NAME
later is sufficient.

This revision is now accepted and ready to land.Sat, Jul 26, 2:38 AM