Bug 154484

Summary: [patch] request for new functionality. jail zfs dataset on jail start up by /etc/rc.d/jail
Product: Base System Reporter: Valery Smirnov <freebsd-pr>
Component: confAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed Overcome By Events    
Severity: Affects Only Me CC: bdrewery, netchild
Priority: Normal Keywords: patch
Version: Unspecified   
Hardware: Any   
OS: Any   
See Also: https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194105
Attachments:
Description Flags
jail.patch none

Description Valery Smirnov 2011-02-03 11:30:09 UTC
No way to define zfs dataset to use it whithin jail on jail start up by /etc/rc.d/jail

Fix: 

I've written simple patch to add this functionality. This patch is in attachment. This patch realy work, but it is only sample =)
How-To-Repeat: /etc/rc.d/jail start
Comment 1 Mark Linimon freebsd_committer freebsd_triage 2011-02-03 12:35:46 UTC
State Changed
From-To: open->feedback

sorry, looks like the patch got stripped.  Can you re-send?
Comment 2 valery 2011-02-03 12:50:56 UTC
 Yes, please.

 Sorry for double sent.

 On Thu, 3 Feb 2011 12:36:05 GMT, linimon@FreeBSD.org wrote:
> Synopsis: [patch] request for new functionality. jail zfs dataset on
> jail start up by /etc/rc.d/jail
>
> State-Changed-From-To: open->feedback
> State-Changed-By: linimon
> State-Changed-When: Thu Feb 3 12:35:46 UTC 2011
> State-Changed-Why:
> sorry, looks like the patch got stripped.  Can you re-send?
>
> http://www.freebsd.org/cgi/query-pr.cgi?pr=154484

-- 
 Best regards
 mailto: freebsd-pr@smirnov.tv
 Valery V.Smirnov
Comment 3 Mark Linimon freebsd_committer freebsd_triage 2011-02-03 21:14:10 UTC
State Changed
From-To: feedback->open

patch received.
Comment 4 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:00:26 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 5 Bryan Drewery freebsd_committer freebsd_triage 2022-06-08 05:09:51 UTC
We need "zfs jail" between jail(2) and "jexec sh /etc/rc". exec.created fits there. This works:
  exec.created = "zfs jail $name pool/dataset"
For rc.d/jail though I had to use this patch:

--- /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 ""


There is no good place for a "zfs unjail" though.
We need "zfs unjail" between "jexec sh /etc/rc.shutdown" and jail_remove(2).


I think most of the patch here does not apply anymore and jail(8) handles executing commands itself. If we add a spot between stop and IP__OP that executes in the system it should work. Very incomplete example of where to start on a proper patch:

diff --git usr.sbin/jail/jail.c usr.sbin/jail/jail.c
index 63096146f176..13bbfe5f69e3 100644
--- usr.sbin/jail/jail.c
+++ usr.sbin/jail/jail.c
@@ -114,6 +114,7 @@ static const enum intparam stopcommands[] = {
     IP_EXEC_PRESTOP,
     IP_EXEC_STOP,
     IP_STOP_TIMEOUT,
+    IP_EXEC_STOPPED,
     IP__OP,
     IP_EXEC_POSTSTOP,
     IP_MOUNT_PROCFS,
Comment 6 Graham Perrin freebsd_committer freebsd_triage 2022-10-17 12:38:51 UTC
Keyword: 

    patch
or  patch-ready

– in lieu of summary line prefix: 

    [patch]

* bulk change for the keyword
* summary lines may be edited manually (not in bulk). 

Keyword descriptions and search interface: 

    <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>
Comment 7 Alexander Leidinger freebsd_committer freebsd_triage 2024-01-19 08:36:35 UTC
Native zfs dataset support was added to jail(8) in -current (_FreeBSD_version 1500011).