Page MenuHomeFreeBSD

jail: Add exec.prepare and exec.release command hooks
ClosedPublic

Authored by freqlabs on May 13 2020, 8:32 PM.

Details

Summary

This change introduces new jail command hooks that run before and after any other actions.

The exec.prepare hook can be used for example to invoke a script that checks if the jail's root exists, creating it if it does not. Since arbitrary variables in jail.conf can be passed to the command, it can be pretty useful for templating jails.

An example use case for exec.release would be to remove the filesystem of an ephemeral jail.

The names "prepare" and "release" are borrowed from the names of similar hooks in libvirt.

Diff Detail

Repository
rS FreeBSD src repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

freqlabs created this revision.May 13 2020, 8:32 PM
freqlabs requested review of this revision.May 13 2020, 8:32 PM
freqlabs edited the summary of this revision. (Show Details)
jamie added a comment.May 13 2020, 8:43 PM

It would make sense for this to be two separate commits - one for the reordering of IP_*.

jamie added a comment.May 13 2020, 8:46 PM

Might it also be useful to include something similar on the stop side, run after taking down the IP addresses? I can't think of a use offhand, unless one wants to leave absolutely no trace of jails, and remove everything that was added in exec.prepare.

freqlabs updated this revision to Diff 71737.May 13 2020, 9:17 PM
freqlabs edited the summary of this revision. (Show Details)

Reserve reordering enum for a later patch.

freqlabs updated this revision to Diff 71738.May 13 2020, 9:30 PM
freqlabs retitled this revision from jail: Add exec.prepare command hook to jail: Add exec.prepare and exec.release command hooks.
freqlabs edited the summary of this revision. (Show Details)

Add suggested exec.release hook as well.

freqlabs updated this revision to Diff 71739.May 13 2020, 9:33 PM

Actually upload a new diff this time :)

debdrup added a comment.EditedMay 13 2020, 9:38 PM

For what it's worth (not much, since I'm not yet a doc commiter), the manual page looks good.

Might it also be useful to include something similar on the stop side, run after taking down the IP addresses? I can't think of a use offhand, unless one wants to leave absolutely no trace of jails, and remove everything that was added in exec.prepare.

This is a great idea, as I like to clean up after myself when I'm done with temporary jails.

For what it's worth (not much, since I'm not yet a doc commiter), the manual page looks good.

Channelling my inner bcr, I must remember to bump the date before committing!

bcr added a subscriber: bcr.May 14 2020, 7:52 AM

For what it's worth (not much, since I'm not yet a doc commiter), the manual page looks good.

Channelling my inner bcr, I must remember to bump the date before committing!

Ha, you just made my day.

bcr accepted this revision as: manpages.May 14 2020, 8:11 AM

Good to go for the man page side of things.

jamie accepted this revision.May 14 2020, 8:10 PM
This revision is now accepted and ready to land.May 14 2020, 8:10 PM
mmacy accepted this revision.May 14 2020, 11:32 PM
This revision was automatically updated to reflect the committed changes.