Page MenuHomeFreeBSD

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

Authored by freqlabs on May 13 2020, 8:32 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Mar 19, 10:38 AM
Unknown Object (File)
Tue, Mar 12, 1:05 AM
Unknown Object (File)
Tue, Mar 12, 1:05 AM
Unknown Object (File)
Tue, Mar 12, 1:05 AM
Unknown Object (File)
Tue, Mar 12, 1:05 AM
Unknown Object (File)
Tue, Mar 12, 1:05 AM
Unknown Object (File)
Tue, Mar 12, 1:05 AM
Unknown Object (File)
Fri, Mar 8, 4:10 AM
Subscribers

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 - subversion
Lint
Lint Skipped
Unit
Tests Skipped

Event Timeline

freqlabs edited the summary of this revision. (Show Details)

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

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 edited the summary of this revision. (Show Details)

Reserve reordering enum for a later patch.

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.

Actually upload a new diff this time :)

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!

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.

Good to go for the man page side of things.

This revision is now accepted and ready to land.May 14 2020, 8:10 PM