# HG changeset patch # User Franz Glasner # Date 1714979681 -7200 # Node ID 84e43d1bd128c71f9839c829a75b25bc45bfcef2 # Parent 071f24359eef81fc7c882b4090d4b099ad6e9ad9 Move "_get_dataset_for_mountpoint()" and "_get_dataset_for_varempty()" into common.subr diff -r 071f24359eef -r 84e43d1bd128 sbin/fjail --- a/sbin/fjail Fri May 03 09:41:38 2024 +0200 +++ b/sbin/fjail Mon May 06 09:14:41 2024 +0200 @@ -95,50 +95,12 @@ ' -# Reset to standard umask -umask 0022 +_p_datadir="$(dirname "$0")"/../share/local-bsdtools +. "${_p_datadir}/common.subr" -_get_dataset_for_mountpoint() { - : 'Use `mount -t zfs -p` to determine the ZFS dataset for a given mountpoint. - - ' - local _mountpoint - local _ds _mount _rest - - _mountpoint="$1" - - mount -t zfs -p \ - | { - while IFS=' '$'\t' read -r _ds _mount _rest ; do - if [ "$_mount" = "$_mountpoint" ]; then - echo "${_ds}" - return 0 - fi - done - return 1 - } -} - - -_get_dataset_for_varempty() { - : 'Allow special handling for /var/empty which may be - mounted read-only. - - ' - local _mountpoint - local _ve_mount - - _mountpoint="$1" - - if [ "$_mountpoint" = '/' ]; then - _ve_mount='/var/empty' - else - _ve_mount="${_mountpoint}/var/empty" - fi - - _get_dataset_for_mountpoint "${_ve_mount}" -} +# Reset to standard umask +umask 0022 #: diff -r 071f24359eef -r 84e43d1bd128 sbin/ftjail --- a/sbin/ftjail Fri May 03 09:41:38 2024 +0200 +++ b/sbin/ftjail Mon May 06 09:14:41 2024 +0200 @@ -65,29 +65,6 @@ umask 0022 -_get_dataset_for_mountpoint() { - : 'Use `mount -t zfs -p` to determine the ZFS dataset for a given mountpoint. - - ' - local _mountpoint - - local _ds _mount _rest - - _mountpoint="$1" - - mount -t zfs -p \ - | { - while IFS=' '$'\t' read -r _ds _mount _rest ; do - if [ "$_mount" = "$_mountpoint" ]; then - echo "${_ds}" - return 0 - fi - done - return 1 - } -} - - #: #: Search for a running jail where it's "path" points to a given location #: diff -r 071f24359eef -r 84e43d1bd128 share/local-bsdtools/common.subr --- a/share/local-bsdtools/common.subr Fri May 03 09:41:38 2024 +0200 +++ b/share/local-bsdtools/common.subr Mon May 06 09:14:41 2024 +0200 @@ -72,3 +72,46 @@ done echo "${_res}" } + + +_get_dataset_for_mountpoint() { + : 'Use `mount -t zfs -p` to determine the ZFS dataset for a given mountpoint. + + ' + local _mountpoint + + local _ds _mount _rest + + _mountpoint="$1" + + mount -t zfs -p \ + | { + while IFS=' '$'\t' read -r _ds _mount _rest ; do + if [ "$_mount" = "$_mountpoint" ]; then + echo "${_ds}" + return 0 + fi + done + return 1 + } +} + + +_get_dataset_for_varempty() { + : 'Allow special handling for /var/empty which may be + mounted read-only. + + ' + local _mountpoint + local _ve_mount + + _mountpoint="$1" + + if [ "$_mountpoint" = '/' ]; then + _ve_mount='/var/empty' + else + _ve_mount="${_mountpoint}/var/empty" + fi + + _get_dataset_for_mountpoint "${_ve_mount}" +}