Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/etc/poudriere.conf.sample
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
# root of the poudriere zfs filesystem, by default /poudriere
# ZROOTFS=/poudriere

# ZFS dataset relative to ZROOTFS that will be passed into jail using zfs-jail(8)
# The jail will have full control over this dataset
# The dataset is recreated from scratch on every jail start and is destroyed
# when jail is stopped
# Enabling this feature will set "allow.mount=1", "allow.mount.zfs=1"
# and "enforce_statfs=1" parameters for the jail
#JAILED_DATASET=

# the host where to download sets for the jails setup
# You can specify here a host or an IP
# replace _PROTO_ by http or ftp
Expand Down
30 changes: 27 additions & 3 deletions src/share/poudriere/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,7 @@ injail_tty() {
jstart() {
local mpath name network
network="${LOCALIPARGS:?}"
local allow_mount_args

case "${RESTRICT_NETWORKING-}" in
"yes") ;;
Expand All @@ -975,6 +976,12 @@ jstart() {
;;
esac

case "${JAILED_DATASET}" in
"") ;;
*)
allow_mount_args="allow.mount=1 allow.mount.zfs=1 enforce_statfs=1"
Copy link
Copy Markdown
Member

@bdrewery bdrewery Nov 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

poudriere.conf JAIL_PARAMS="allow.mount=1 allow.mount.zfs=1 enforce_statfs=1"

esac

_my_name name

mpath="${MASTERMNT:?}${MY_JOBID:+/../${MY_JOBID}}"
Expand All @@ -985,12 +992,20 @@ jstart() {
jail -c persist "name=${name:?}" \
"path=${mpath:?}" \
"host.hostname=${BUILDER_HOSTNAME-${name}}" \
${network} ${JAIL_PARAMS-}
${network} ${allow_mount_args} ${JAIL_PARAMS-}
# Allow networking in -n jail
jail -c persist "name=${name}-n" \
jail -c persist "name=${name:?}-n" \
"path=${mpath:?}" \
"host.hostname=${BUILDER_HOSTNAME-${name}}" \
${IPARGS:?} ${JAIL_PARAMS-} ${JAIL_NET_PARAMS-}
${IPARGS:?} ${allow_mount_args} ${JAIL_PARAMS-} ${JAIL_NET_PARAMS-}

if [ "${JAILED_DATASET}" ]; then
local jailed_dataset_name=${ZPOOL}${ZROOTFS}${JAILED_DATASET}_${name:?}
zfs destroy -Rf ${jailed_dataset_name} 2>/dev/null || :
zfs create -o jailed=on ${jailed_dataset_name}
zfs jail ${name:?} ${jailed_dataset_name}
zfs jail ${name:?}-n ${jailed_dataset_name}
fi
Comment on lines +1002 to +1008
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run_hook jstart post "${name}"

return 0
}

Expand Down Expand Up @@ -1035,6 +1050,10 @@ jstop() {
_my_name name
jail -r "${name:?}" 2>/dev/null || :
jail -r "${name:?}-n" 2>/dev/null || :

if [ "${JAILED_DATASET}" ]; then
zfs destroy -Rf ${ZPOOL}${ZROOTFS}${JAILED_DATASET}_${name:?} 2>/dev/null || :
fi
Comment on lines +1053 to +1056
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

run_hook jstop post "${name}"

}

eargs() {
Expand Down Expand Up @@ -10373,6 +10392,11 @@ set) ;;
case ${ZROOTFS} in
[!/]*) err 1 "ZROOTFS should start with a /" ;;
esac
: ${JAILED_DATASET=""}
case ${JAILED_DATASET} in
"") ;;
[!/]*) err 1 "JAILED_DATASET should start with a /" ;;
esac
;;
esac

Expand Down