# HG changeset patch # User Franz Glasner # Date 1726054989 -7200 # Node ID 3afebbaf613b9f342a745ffbc74293a06eb4d337 # Parent a593dce19f54f1dd4191852db9d67b2f60e1015f ftjail: mounting and unmounting in freebsd-update now handles spaces in devices/datasets and mountpoints properly. Fully supported only if textproc/jq is installed. diff -r a593dce19f54 -r 3afebbaf613b sbin/ftjail --- a/sbin/ftjail Wed Sep 11 12:59:16 2024 +0200 +++ b/sbin/ftjail Wed Sep 11 13:43:09 2024 +0200 @@ -873,7 +873,8 @@ local _directory _new_origin _etcupdate_tarball local _opt_keep _opt_old_origin - local _res _jailname _dir_mounts _dir_fn_fstab _dir_basename _dir_fn_tldir + local _res _jailname _dir_mounts _dir_fn_fstab _dir_fn_fstab2 + local _dir_basename _dir_fn_tldir local _root_dataset _root_mountpoint _root_type _root_options local _clone_extra_props _canmount_prop local _line _opt @@ -991,20 +992,19 @@ _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; } + # The fstab that is corrently mounted at relevant locations (normalized) _dir_fn_fstab="${_u_tmpdir}/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. - # + # The very same fstab -- but with spaces replaced by \040 + _dir_fn_fstab2="${_u_tmpdir}/fstab2" printf '%s' "${_dir_mounts}" >"${_dir_fn_fstab}" + # Replace all spaces with a sequence that is understood by mount + LC_ALL=C /usr/bin/sed -e 's/ /\\040/g' <"${_dir_fn_fstab}" >"${_dir_fn_fstab2}" _dir_fn_tldir="${_u_tmpdir}/tldirs" 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}'" - /sbin/umount -a -F "${_dir_fn_fstab}" -v + /sbin/umount -a -F "${_dir_fn_fstab2}" -v # # XXX TBD: Hooks to create some new top-level dirs (/srv /proc et @@ -1077,7 +1077,7 @@ # Mount again echo "Mounting all datasets rooted at \`${_directory}'" [ ! -d "${_directory}" ] && mkdir "${_directory}" - /sbin/mount -a -F "${_dir_fn_fstab}" -v + /sbin/mount -a -F "${_dir_fn_fstab2}" -v # Update and/or merge configs if [ -n "${_etcupdate_tarball}" ]; then