Mercurial > hgrepos > FreeBSD > ports > sysutils > local-bsdtools
diff sbin/ftjail @ 555:2fda9ab57359
Normalize the output of _get_mounts_at_directory() to use TABs as field separators only.
This is a precondition for properly handling SPACE chars in datasets and/or
mountpoints.
BUGS: Handling of spaces not yet done.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Wed, 11 Sep 2024 12:34:32 +0200 |
| parents | 847ae246f3cc |
| children | a593dce19f54 |
line wrap: on
line diff
--- a/sbin/ftjail Wed Sep 11 12:11:52 2024 +0200 +++ b/sbin/ftjail Wed Sep 11 12:34:32 2024 +0200 @@ -965,7 +965,7 @@ # mountpoint in ZFS. # Also check that it is a clone proper. # - IFS=' '$'\t' read -r _root_dataset _root_mountpoint _root_type _root_options _line <<EOF4tHGCSS + IFS=$'\t' read -r _root_dataset _root_mountpoint _root_type _root_options _line <<EOF4tHGCSS ${_dir_mounts} EOF4tHGCSS [ "${_root_mountpoint}" != "${_directory}" ] && { echo "ERROR: found root mountpoint does not match given directory" 1>&2; return 1; } @@ -992,9 +992,15 @@ _u_tmpdir="$(env TMPDIR=/var/tmp mktemp -d -t ftjail_${_dir_basename})" [ -z "${_u_tmpdir}" ] && { echo "ERROR: cannot create unique temp dir" 1>&2; return 1; } _dir_fn_fstab="${_u_tmpdir}/fstab" - echo -n "${_dir_mounts}" >>"${_dir_fn_fstab}" + # + # XXX FIXME: handle spaces in device and mountpoint names: replace + # with a literal `\040'. Note that ${_dir_mounts} is + # normalized already: it uses TAB characters as field + # separator exclusively. + # + printf '%s' "${_dir_mounts}" >>"${_dir_fn_fstab}" _dir_fn_tldir="${_u_tmpdir}/tldirs" - find "${_directory}" -depth 1 -type d 2>/dev/null | sort >>"${_dir_fn_tldir}" + LC_ALL=C /usr/bin/find "${_directory}" -depth 1 -type d 2>/dev/null | LC_ALL=C /usr/bin/sort >>"${_dir_fn_tldir}" # Unmount in reverse order: unmount can do it for us echo "Unmounting all datasets mounted at \`${_directory}'"
