HomeFreeBSD

jail: consistently populate the KP_JID and KP_NAME parameters

Description

jail: consistently populate the KP_JID and KP_NAME parameters

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 use 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 [...]")
Reviewed by: jamie

(cherry picked from commit 02944d8c4969ffe97fcf84cb2ccb672e828c1d04)

Details

Provenance
kevansAuthored on Jul 26 2025, 3:13 AM
Parents
rG28b8f26beff9: jail: tests: cleanup the commands test a bit
Branches
Unknown
Tags
Unknown