[Bug 194105] sysutils/ezjail with zfs_datasets does not work with /etc/rc.d/zfs

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 08 Jun 2022 05:00:39 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194105

--- Comment #5 from Bryan Drewery <bdrewery@FreeBSD.org> ---
Yup this is still relevant. A simple workaround for *startup* is to use
exec.created. exec.poststart is too late if you want rc scripts depending on
the zfs dataset. exec.start before /etc/rc might work but I didn't try.
To be clear the "zfs jail" needs to occur between jail(2) and jexec "sh
/etc/rc".

--- /tmp/jail   2022-06-07 21:56:17.886298000 -0700
+++ /etc/rc.d/jail      2022-06-07 21:56:19.863706000 -0700
@@ -213,6 +213,7 @@ parse_options()
                echo "  exec.system_user = \"root\";"
                echo "  exec.jail_user = \"root\";"
                extract_var $_jv exec_prestart exec.prestart 0 ""
+               extract_var $_jv exec_created exec.created - ""
                extract_var $_jv exec_poststart exec.poststart 0 ""
                extract_var $_jv exec_prestop exec.prestop 0 ""
                extract_var $_jv exec_poststop exec.poststop 0 ""

Then in the ezjail/jail.conf file something like this:
# Must not set zfs_datasets or /usr/local/etc/rc.d/ezjail does the "zfs jail"
too late (which is ignored but causes a warning)
export jail_backups_exec_created="zfs jail \$name backup"

There is no corresponding place in the jail stop to do "zfs unjail". It needs
to occur after /etc/rc.shutdown but before jail_remove(2). jail.*stop* are all
just wrong for this. In practice the "zfs unjail" piece does not seem important
but I could be wrong.

iocage avoids all of this by not using /etc/rc.d/jail like ezjail does. It uses
jail(8) and controls the ordering properly.

-- 
You are receiving this mail because:
You are the assignee for the bug.